akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,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-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll 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-'0');ch=getchar();}
    return x*f;
}

int n,m,f[N][N],col[N][N];
char s[N];

int main()
{
    n=read();m=read();
    rep(i,1,n)
    {
        scanf("%s",s+1);
        rep(j,1,m) col[i][j]=(s[j]=='#');
    }
    memset(f,0x3f,sizeof(f));
    f[1][1]=col[1][1];
    rep(i,1,n) rep(j,1,m)
    {
        if ((i==1) && (j==1)) continue;
        if (i>1)
        {
            int tmp=f[i-1][j];
            if ((!col[i-1][j]) && (col[i][j])) tmp++;
            f[i][j]=min(f[i][j],tmp);
        }
        if (j>1)
        {
            int tmp=f[i][j-1];
            if ((!col[i][j-1]) && (col[i][j])) tmp++;
            f[i][j]=min(tmp,f[i][j]);
        }
    }
    printf("%d",f[n][m]);
    return 0;
}

Measured memory_bytes: 3992
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main() {
  int n;
  string s1, s2;
  cin >> n >> s1 >> s2;
  ll ans = 3;
  for(int i = 0; i < n; i++) {
    if(i < n - 1 && s1[i] == s1[i + 1]) {
      if(i > 0 && s1[i - 1] == s2[i - 1] || i == 0) {
        ans *= 2;
        ans %= MOD;
      } else if(i > 0 && s1[i - 1] != s2[i - 1]) {
        ans *= 3;
        ans %= MOD;
      }
    } else if(i > 0) {
      if(s1[i - 1] == s2[i - 1]) {
        ans *= 2;
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>

using namespace std;

void input_vector(vector<int> &v, int n) {
  int a;
  for(int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
}

void print_vector(vector<int> v) { 
  for(int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main(void) {
  int n, m;
  vector<int> a,b;

  cin >> n;
  input_vector(a, n);

  cin >> m;
  input_vector(b, m);

  int flag=0;
  int i;
	for(i = 0; i < min(n, m); i++) {
		if(b[i] > a[i]) {
			flag = 1;
			break;
		}
		else if(a[i] > b[i]) 
      break;
	}
	if(i == n && i < m)
		flag = 1;
	cout<< flag << endl;
  
}


Measured memory_bytes: 3180
#include<stdio.h>
	int main() {
		int X, A, B;
		scanf("%d%d%d", &X, &A, &B);

		if (B-A<=0) {
			printf("delicious");
		}
		else if (B-A<=X) {
			printf("safe");
		}
		else {
			printf("dangerous");
		}

		return 0;
	}


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

using namespace std;

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

typedef complex<double> point;
struct line { point p, q; };

double dot(point a, point b) { return real(conj(a) * b); }

point projection(const line &l, const point &p)
{
	double t = dot(p - l.p, l.p - l.q) / norm(l.p - l.q);
	return l.p + t * (l.p - l.q);
}

point read(){
	double x, y; cin >> x >> y;
	return point(x, y);
}

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

	point p, q;
	p = read(), q = read();
	line l = {p, q};

	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		point r = read();
		point a = projection(l, r);
		cout.precision(15);
		cout << fixed << a.real() << " " << a.imag() << endl;
	}

	return 0;
}

Measured memory_bytes: 1324
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s, t;
    cin >> s >> t;
    map<char, int> m1;
    map<char, int> m2;
    for(int i = 0; i < s.size(); i++){
        m1[s[i]]++;
    }
    for(int i = 0; i < t.size(); i++){
        m2[t[i]]++;
    }
    map<char, int> :: iterator it;
    string r = "";
    for(it = m1.begin(); it!=m1.end(); it++){
        for(int i = 0; i < it->second; i++){
            r+=it->first;
        }
    }
    map<char, int> :: reverse_iterator it2;
    string w = "";
    for(it2 = m2.rbegin(); it2 != m2.rend(); it2++){
        for(int i = 0; i < it2->second; i++){
            w+=it2->first;
        }
    }
    if(r < w){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    
    if sum(a) > sum(b):
        print("No")
    else:
        do = sum(b)-sum(a)
        ca,cb = 0,0
        for x,y in zip(a,b):
            if x > y:
                cb += x-y
            else:
                if (y-x)%2 == 0:
                    ca += (y-x)//2
                else:
                    ca += (y+1-x)//2
                    cb += 1
        if ca-cb >= 0:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 4340
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong dp[10][10];

int dig(llong x) {
    llong d = 0;
    while (x) {
        d++;
        x /= 10;
    }

    return d;
}

int suc(llong x) {
    return x % 10;
}

int pred(llong x) {
    llong r = x;
    while (x) {
        r = x;
        x /= 10;
    }

    return r;
}

void calc(llong x) {
    llong k = suc(x);

    dp[pred(x)][suc(x)]++;
}

int main() {
    cin >> n;
    for (llong i = 1; i <= n; i++) {
        calc(i);
    }

    llong ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += dp[i][j] * dp[j][i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m;
  cin>>n>>m;
  set<ll> xs, ys;
  vector<tuple<ll,ll,ll>> vl, hl;
  REP(i,n) {
    ll a,b,c;
    cin>>a>>b>>c;
    xs.insert(a);
    xs.insert(b);
    ys.insert(c);
    vl.emplace_back(a,b,c);
  }
  REP(i,m) {
    ll a,b,c;
    cin>>a>>b>>c;
    xs.insert(a);
    ys.insert(b);
    ys.insert(c);
    hl.emplace_back(a,b,c);
  }
  vecll vxs(ALL(xs));
  vecll vys(ALL(ys));
  int xc = size(vxs)+1;
  int yc = size(vys)+1;
  map<ll, ll> to_xid, to_yid;
  REP(i,xc-1) to_xid[vxs[i]] = i+1;
  REP(i,yc-1) to_yid[vys[i]] = i+1;
  int v = xc * yc;
  vector<int> g(v);
  array<int, 4> di = {1, 0, -1, 0};
  array<int, 4> dj = {0, -1, 0, 1};
  auto id = [&] (int i, int j) {
    return i * xc + j;
  };
  REP(i,yc) {
    REP(j,xc) {
      REP(k,4) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if (ni < 0 || ni >= yc || nj < 0 || nj >= xc) continue;
        g[id(i,j)] |= 1 << k;
      }
    }
  }
  for(auto&&[a,b,c]:vl) {
    ll s = to_xid.at(a);
    ll t = to_xid.at(b);
    ll y = to_yid.at(c);
    FOR(x,s,t) {
      g[id(y-1,x)] &= ~(1 << 0);
      g[id(y,x)] &= ~(1 << 2);
    }
  }
  for(auto&&[a,b,c]:hl) {
    ll x = to_xid.at(a);
    ll s = to_yid.at(b);
    ll t = to_yid.at(c);
    FOR(y,s,t) {
      g[id(y,x-1)] &= ~(1 << 3);
      g[id(y,x)] &= ~(1 << 1);
    }
  }
  auto xzero = upper_bound(ALL(vxs), 0) - begin(vxs);
  auto yzero = upper_bound(ALL(vys), 0) - begin(vys);
  vector<bool> vis(v, false);
  queue<int> q;
  q.push(id(yzero,xzero));
  vis[id(yzero,xzero)] = true;
  while (!q.empty()) {
    int idx = q.front();
    q.pop();
    int to = g[idx];
    int i = idx / xc;
    int j = idx % xc;
    REP(k,4) {
      if ((to>>k)&1) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if (!vis[id(ni,nj)]) {
          vis[id(ni,nj)] = true;
          q.push(id(ni,nj));
        }
      }
    }
  }
  ll sum = 0;
  REP(i,yc){
    REP(j,xc) {
      if (vis[id(i,j)]) {
        if (i == 0 || i == yc-1 || j == 0 || j == xc-1) {
          cout<<"INF\n";
          return 0;
        }
        sum += (vys[i] - vys[i-1]) * (vxs[j] - vxs[j-1]);
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 40172
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

const int MAXN = 200000;

int N, A[MAXN + 5];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%d", &A[i]);
	std::sort(A + 1, A + N + 1);
	for (int i = 1; i <= N - 1; i++)
		if (A[i] == A[i + 1])
			return puts("NO"), 0;
	puts("YES");
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define Pii pair<int, int>
#define ll long long
#define mod 1000000007
#define N 10001
#define S 2000
ll Qpow(ll x, ll n) {
    ll s = 1;
    while (n) {
        if (n & 1) s = s * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return s;
}
ll inv(ll x) { return Qpow(x, mod - 2); }
ll fac[N], ifac[N];
ll C(int x, int y) { return fac[x] * ifac[x - y] % mod * ifac[y] % mod; }
void Prepare() {
    fac[0] = 1;
    for (ll i = 1; i < N; i++) fac[i] = fac[i - 1] * i % mod;
    ifac[N - 1] = inv(fac[N - 1]);
    for (ll i = N - 1; i; i--) ifac[i - 1] = ifac[i] * i % mod;
}
Pii P[S * S];
int d[S << 1 | 1][S << 1 | 1], n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &P[i].first, &P[i].second);
    Prepare();
    for (int i = 1; i <= n; i++) d[S - P[i].first][S - P[i].second]++;
    for (int dis = 1; dis <= S << 2; dis++)
        for (int i = max(0, dis - (S << 1)); i <= min(S << 1, dis); i++) {
            int j = dis - i;
            if (i) d[i][j] = (d[i][j] + d[i - 1][j]) % mod;
            if (j) d[i][j] = (d[i][j] + d[i][j - 1]) % mod;
        }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int x = P[i].first, y = P[i].second;
        ans = (ans + d[x + S][y + S]) % mod;
        ans = (ans - C(2 * x + 2 * y, 2 * x) + mod) % mod;
    }
    printf("%lld\n", ans * inv(2) % mod);
    return 0;
}

Measured memory_bytes: 65920
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N), D(N + 1);
  REP(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  D[0] = 0;
  REP(i, N) D[i + 1] = D[i] + A[i];

  int idx = -1;
  REP(i, N - 1) {
    if (2 * D[i] < A[i]) {
      idx = i;
    }
  }
  cout << N - idx << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;


int main(void) {
	string s;
	cin >> s;
	string ss = s.substr(0, 4);
	int year = atoi(ss.c_str());
	ss = s.substr(5, 2);
	int month = atoi(ss.c_str());
	ss = s.substr(8, 2);
	int day = atoi(ss.c_str());
//	cout << year << " " << month << " " << day << endl;
	
	if (year > 2019) {
		cout << "TBD" << endl; return 0;
	}
	if (year == 2019) {
		if (month > 4) {
			cout << "TBD" << endl; return 0;
		}
	}
	cout << "Heisei" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Queue;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");
		int a[] = new int[100005];

		for (int i = 0; i < n; i++) {
			int value = Integer.parseInt(str[i]) + 1;

			a[value]++;
			a[value + 1]++;
			a[value - 1]++;
		}

		SegmentTree st = new SegmentTree(a);
		int ans = st.query(0, 100005);
		System.out.println(ans);
	}
}

class SegmentTree {

	// 元の配列もMAX_VALUEで初期化
	// MIN_VALUE,Math.maxで最大値を得られる

	int N;
	int[] origin;
	int[] tree;

	int INT_MAX = Integer.MIN_VALUE;

	SegmentTree(int[] original) {
		this.origin = Arrays.copyOf(original, original.length);
		int n = origin.length;
		this.N = 1;
		while (N < n)
			N *= 2;
		this.tree = new int[N * 2];
		for (int i = 0; i < N * 2; i++) {
			tree[i] = INT_MAX;
		}
		build();
	}

	// O(N)
	void build() {
		for (int i = 0; i < origin.length; i++) {
			update(i, origin[i]);
		}
	}

	// i番目の値をxに更新 O(log N)
	void update(int i, int x) {
		i += N - 1;
		tree[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			tree[i] = marge(tree[i * 2 + 1], tree[i * 2 + 2]);
		}
	}

	// O(log N);
	int query(int start, int end) {
		return query(start, end, 0, 0, N);
	}

	// [a, b)の最小値、l, rにはノードkに対応する区間を与える
	private int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)
			return INT_MAX;

		if (a <= l && r <= b) {
			return tree[k];
		} else {
			int lv = query(a, b, 2 * k + 1, l, (l + r) / 2);
			int rb = query(a, b, 2 * k + 2, (l + r) / 2, r);
			return marge(lv, rb);
		}
	}

	private int marge(int l, int r) {
		return Math.max(l, r);
	}

}


Measured memory_bytes: 37972
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265358979323846
int main(){
int n,m;
cin>>n>>m;
long long int sum=0;
int a[m];
for(int i=0;i<m;i++){
	cin>>a[i];sum+=a[i];
}
int ans=n-sum;
if(ans<0) cout<<"-1";
else cout<<ans;
}

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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    ll n;
    cin >> n;
    vector<ll> w(n);
    for(auto &e: w) cin >> e;

    ll s = 0, t = 0;
    for(auto &e: w) t += e;

    ll r = 1e9;
    for(auto &e: w)
        s += e, t -= e, r = min(r, abs(t-s));
    cout << r << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0) {
				break;
			}
			int n = sc.nextInt();
			boolean[][] c = new boolean[a+1][b+1];
			for(int i=0;i<n;i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				c[x][y] = true;
			}
			int[][] dp = new int[a+1][b+1];
			dp[0][1] = 1;
			for(int i=1;i<=a;i++) {
				for(int j=1;j<=b;j++) {
					if (!c[i][j]) {
						dp[i][j] = dp[i-1][j] + dp[i][j-1];
					}
				}
			}
			System.out.println(dp[a][b]);
		}
	}

}

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

int main() 
{
    int a,b;
    cin >> a >> b;
    bool res = true;
    for (int i=0; i<a+b+1; i++)
    {
        char c;
        cin >> c;
        if (i==a && c!='-')
            res = false;
        if (i!=a && c=='-')
            res = false;
    }
    cout << (res?"Yes":"No");    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
b = [0 for _ in range(10**6+1)]
ans = 0
for i in range(n):
  x = a[i]
  if b[x]:
    continue
  if i != n-1:
    if a[i+1] != x:
      ans += 1
      #print(x)
  else:
    ans += 1
  now = x
  while True:
    try:
      b[now] = 1
      now += x
    except:
      break
#print(a)
print(ans)

Measured memory_bytes: 164764
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+7;
ll a[maxn];
int main(){
    ll n,x;
    ll ans=0;
    cin>>n>>x;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n;i++){
        if(a[i]+a[i-1]>x){
            ans+=a[i]+a[i-1]-x;
            a[i]=max(x-a[i-1],(ll)0);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int gcd(long long a, long long b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}


int main() {
	
	long long a, b, c, d;cin >> a >> b >> c >> d;
	a = a - 1;
	long long B, A;
	B = b - (b / c + b / d) + b / ((c * d) / gcd(c, d));  
	A = a - (a / c + a / d) + a / ((c * d) / gcd(c, d));

	cout << B - A << endl;


}

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

int main(){
  int N;
  cin >> N;
  
  int sum =0;
  int num =N;
  while(num>0){
    int n = num %10;
    sum += n;
    num = num/10;
  }
  if(N%sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s, t;
    cin >> n >> s >> t;
    vi type;
    for (int i = 0; i < n; ) {
        if (i != n-1 && s[i] == s[i+1]) {
            type.pb(0);
            i += 2;
        } else {
            type.pb(1);
            i++;
        }
    }
    mint ans = 1;
    rep(i, sz(type)) { 
        if (i == 0) {
            if (type[i] == 0) {
                ans *= 3 * 2;
            } else {
                ans *= 3;
            }
        } else if (type[i] == 0) {
            if (type[i-1] == 0) {
                ans *= 3;
            } else {
                ans *= 2;
            }
        } else {
            if (type[i-1] == 0) {
                ans *= 1;
            } else {
                ans *= 2;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  pair<int, int> a[n], b[n];
  for (int i = 0; i < n; i ++) cin >> a[i].second >> a[i].first;
  for (int i = 0; i < n; i ++) cin >> b[i].first >> b[i].second;
  sort(a, a + n);
  reverse(a, a + n);
  sort(b, b + n);

  int ans = 0;
  bool used[n];
  for (int i = 0; i < n; i ++) used[i] = false;
  for (int i = 0; i < n; i ++) {
    for (int j = 0 ; j < n; j ++) {
      if (used[j]) continue;
      if (a[j].second < b[i].first && a[j].first < b[i].second) {
        ans ++;
        used[j] = true;
        break;
      }
    }
  }

  cout << ans << endl;
}


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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

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

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        x--;
        a[x]++;
    }
    for (int i = 0; i < n; i++) {
        if (k - q + a[i] > 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

    return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

void print_ans(vector<i64> ans)
{
    rep(i,0,ans.size()){
        cout << ans[i];
        if(i==ans.size()-1) cout << endl;
        else cout << " ";
    }
}

void solve(){
    i64 N;
    cin >> N;

    if(N==3){
        cout << "2 5 63" << endl;
        return;
    }

    if(N==4){
        cout << "2 5 20 63" << endl;
        return;
    }

    if(N==5){
        cout << "2 4 6 3 9" << endl;
        return;
    }

    vector<i64> ans;
    i64 k=0,s=0;
    while(ans.size()<N){
        if(ans.size()<N) ans.push_back(6*k+2), s+=2;
        if(ans.size()<N) ans.push_back(6*k+3), s+=3;
        if(ans.size()<N) ans.push_back(6*k+4), s+=4;
        if(ans.size()<N) ans.push_back(6*k+6), s+=6;
        ++k;
    }

    s%=6;
    if(s==0){
        print_ans(ans);
        return;
    }

    if(s==2){
        ans.erase(find(ans.begin(), ans.end(), 8));
        ans.push_back(ans.back()/6*6+6);
        print_ans(ans);
        return;
    }

    if(s==3){
        ans.erase(find(ans.begin(), ans.end(), 9));
        ans.push_back(ans.back()/6*6+6);
        print_ans(ans);
        return;
    }

    if(s==5){
        ans.erase(find(ans.begin(), ans.end(), 9));
        ans.push_back(6*(k-1)+4>ans.back()?6*(k-1)+4:6*k+4);
        print_ans(ans);
        return;
    }

    assert(false);
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

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

    int H[N];
    int max_H = 0;
    int count = 0;
    REP(i, N)
    {
        cin >> H[i];
        if (max_H <= H[i])
        {
            max_H = H[i];
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()
left = A + B
right = C + D
if left > right:
    print("Left")
elif left == right:
    print("Balanced")
else:
    print("Right")
# 16:02

Measured memory_bytes: 5396
let n = Scanf.scanf " %d" (+) 0
let vs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let css = Array.make_matrix 2 100001 0
let _ = Array.iteri (fun i v -> css.(i mod 2).(v) <- css.(i mod 2).(v) + 1) vs
let cssi = Array.map (fun cs -> Array.mapi (fun i c -> c, i) cs) css
let (e0, em), e1, (o0, om), o1 = List.iter (fun i -> Array.sort (fun x y -> compare y x) cssi.(i)) [0; 1];
  cssi.(0).(0), fst cssi.(0).(1), cssi.(1).(0), fst cssi.(1).(1)
let _ = Printf.printf "%d\n" @@ if em = om then n - max (e0 + o1) (e1 + o0) else n - e0 - o0

Measured memory_bytes: 12672
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        while(true){
 
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
 
            if(op.equals("?"))break;
 
            int ans = 0;
 
            switch(op){
            case "+":
                ans = a+b;
                break;
            case "-":
                ans = a-b;
                break;
            case "*":
                ans = a*b;
                break;
            case "/":
                ans = a/b;
                break;
            }
 
            System.out.printf("%d\n", ans);
        }
    }
}



Measured memory_bytes: 26276
#include<stdio.h>
int n;
int p[10], q[10];
int a, b;
int ans;
int comp(int s[], int t[])
{
	int i;
	for (i = 0; i < n; i++)
	{
		if (s[i] < t[i])
			return -1;
		if (s[i] > t[i])
			return 1;
	}
	return 0;
}
void f(int s[], int ss, int t[], int tt)
{
	int i, j;
	if (tt == 0)
	{
		if (comp(s, p) * comp(s, q) <= 0)
			ans++;
		return;
	}
	int c[10];
	for (i = 0; i < tt; i++)
	{
		for (j = 0; j < i; j++)
			c[j] = t[j];
		for (j = i + 1; j < tt; j++)
			c[j - 1] = t[j];
		s[ss] = t[i];
		f(s, ss + 1, c, tt - 1);
	}
	return;
}
int main()
{
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++)
		scanf("%d", &p[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &q[i]);
	ans = -1;
	int c[10], d[10];
	for (i = 0; i < n; i++)
		c[i] = i + 1;
	f(d, 0, c, n);
	printf("%d\n", ans);
	return 0;
}

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

struct route
{
	int A; //道の片側の展望台
	int B; //道のもう片側の展望台
};

int main()
{
	int N; //展望台の数
	int M; //道の数
	cin >> N >> M;

	vector<long> H(N); //展望台の高さ
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	
	vector<route> AB(M); //道のセット
	vector<bool> ishigh(N, true); //道でつながったどの展望台より高いか
	for (int i = 0; i < M; i++)
	{
		cin >> AB[i].A >> AB[i].B;

		if (H[AB[i].A - 1] == H[AB[i].B - 1])
		{
			ishigh[AB[i].A - 1] = ishigh[AB[i].B - 1] = false;
		}
		else if(H[AB[i].A - 1] > H[AB[i].B - 1])
		{
			ishigh[AB[i].B - 1] = false;
		}
		else
		{
			ishigh[AB[i].A - 1] = false;
		}
	}

	int result = 0;
	for (int i = 0; i < N; i++)
	{
		if (ishigh[i])
			result++;
	}
	cout << result << endl;


	return 0;
}



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

typedef long long LL;

const int N=100000;

int n,a[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
}

int ans0,ans[N+9][2];

void Get_ans(){
  sort(a+1,a+n+1);
  if (a[n-1]<=0){
	ans0=a[n];
	for (int i=1;i<n;++i){
	  ans[i][0]=ans0;ans[i][1]=a[i];
	  ans0-=a[i];
	}
	return;
  }
  ans0=a[n];
  for (int i=1;i<n-1;++i)
	if (a[n-i]>0){
	  ans[i][0]=a[1];ans[i][1]=a[n-i];
	  a[1]-=a[n-i];
	}else{
	  ans[i][0]=ans0;ans[i][1]=a[n-i];
	  ans0-=a[n-i];
	}
  ans[n-1][0]=ans0;ans[n-1][1]=a[1];
  ans0-=a[1];
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans0);
  for (int i=1;i<n;++i)
	printf("%d %d\n",ans[i][0],ans[i][1]);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 4928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    vector<int> a(4);
    rep(i, 4) a[i] = s[i] - '0';
    int ans = 0;
    rep(i, 1<<3) {
        int now = a[0];
        rep(j, 3) {
            if (i>>j&1) now += a[j+1];
            else now -= a[j+1];
        }
        if (now==7) {
            ans = i;
            break;
        }
    }
    rep(i, 4) {
        cout << a[i];
        if (i<3) {
            if (ans>>i&1) cout << '+';
            else cout << '-';
        }
    }
    cout << "=7" << endl;
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int ary[n];

    map<int, int> omp;
    map<int, int> emp;
    
    rep(i,n)
    {
      int v;
      cin >> v;

      if (i%2)
      {
        auto itr = emp.find(v);
        if (itr != emp.end()) {
          emp[v]++;
        }
        else
        {
          emp[v] = 1;
        }
      }
      else
      {
        auto itr = omp.find(v);
        if (itr != omp.end()) {
          omp[v]++;
        }
        else
        {
          omp[v] = 1;
        }
      }
    }
    int emax = 0;
    int esecond = 0;
    int emaxchar;
    int omax = 0;
    int osecond = 0;
    int omaxchar;

    for (auto itr=emp.begin();itr!=emp.end();++itr)
    {
      if (emax <= itr->second)
      {
        esecond = emax;
        emax = itr->second;
        emaxchar = itr->first;
      }
      else
      {
        esecond = max(esecond, itr->second);
      }
      
    }
    for (auto itr=omp.begin();itr!=omp.end();++itr)
    {
      if (omax <= itr->second)
      {
        osecond = omax;
        omax = itr->second;
        omaxchar = itr->first;
      }
      else
      {
        osecond = max(osecond, itr->second);
      }
      
    }
    // cout << "omax: " << omax << endl;
    // cout << "osecond: " << osecond << endl;
    // cout << "emax: " << emax << endl;
    // cout << "esecond: " << esecond << endl;
    if (omaxchar != emaxchar)
    {
      cout << n - (omax + emax) << endl;
    }
    else
    {
      cout << n - omax - max(osecond, esecond) << endl;
    }
    

}


Measured memory_bytes: 4992
// clang-format off
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <queue>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
constexpr ll MOD = 1000000007;



int main(){

    int a, b;
    cin >> a >> b;
    if(a + b >= 24){
        cout << a + b - 24 << endl;
    } else {
        cout << a+ b << endl;
    }
    
    return 0;
}


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

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


Measured memory_bytes: 3092
used[9];
  
dfs(int step, int s)
{
    int i, res;
  
    if (!step) return (s == 0);
    if (s < 0) return (0);
    if (s > (step * (step + 1)) / 2 * 9) return (0);
      
    res = 0;
    for (i = 0; i <= 9; ++i){
        if (!used[i]){
            used[i] = 1;
            res += dfs(step - 1, s - (i * step));
            used[i] = 0;
        }
    }
    return (res);
}
  
main(n, v)
{
  
    while (~scanf("%d %d", &n, &v)){
        printf("%d\n", dfs(n, v));
    }
    return (0);
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
using namespace std;
const int INF = 10000000;
void swap(int& a, int& b) {
  int t = a;
  a = b;
  b = t;
}
int main () {
  int N, M;
  cin >> N >> M;
  int use[9];
  for (int i = 0; i < M; i ++) cin >> use[i];
  for (int i = 0; i < M; i ++) {
    for (int i = 1; i < M; i ++) {
      if (use[i] < use[i - 1]) swap(use[i], use[i - 1]);
    }
  }
  //for (int i = 0; i < M; i ++) cout << use[i] << ' ';
  cout << endl;
  int num[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int dp[100000];
  for (int i = 0; i < 7; i ++) dp[i] = -INF;
  dp[7] = 0;
  for (int i = 8; i < N + 8; i ++) {
    dp[i] = dp[i - num[use[0]]] + 1;
    for (int j = M - 1; j >= 0; j --) {
      if (dp[i] < dp[i - num[use[j]]] + 1)dp[i] = dp[i - num[use[j]]] + 1;
    }
  }
  //for (int i = 0; i < N + 7; i ++) cout << dp[i] << endl;
  int k = N + 7;
  int a = dp[k];
  //cout << a;
  for (int i = 0; i < a; i ++) {
    for (int j = M - 1; j >= 0; j --) {
      if (dp[k] == dp[k - num[use[j]]] + 1) {
        cout << use[j];
        k -= num[use[j]];
        break;
      }
    }
  }
  cout << endl;
}
    
  



Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int a,b,c,d,e,f,g;
	std::cin >> a >> b >> c >> d >> e >> f >> g;
	if(b==0&&d<=1&&e<=1&&a<=1) {
		if(a==1&&d==1&&e==1) {
			print(3);
			return 0;
		}
		print(0);
		return 0;
	}
	int k=0;
	k+=b;
	if(a>2) {
		k+=((a-1)/2)*2;
		a-=((a-1)/2)*2;
	}
	if(d>2) {
		k+=((d-1)/2)*2;
		d-=((d-1)/2)*2;
	}
	if(e>2) {
		k+=((e-1)/2)*2;
		e-=((e-1)/2)*2;
	}
	int c2 = 0;
	if(a==2) c2++;
	if(d==2) c2++;
	if(e==2) c2++;
	if(c2==2) {
		print(k+4);
		return 0;
	}
	if(c2==3) {
		print(k+6);
		return 0;
	}
	if(a>0&&d>0&&e>0) {
		print(k+3);
		return 0;
	}
	if(c2==1) {
		print(k+2);
		return 0;
	}
	print(k);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc081/tasks/abc081_b 

bool isAllEven(ll arr[], int N) {
    REP(i, N) {
        if (arr[i] % 2 != 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int N; cin >> N;
    ll arr[N];
    REP(i, N) cin >> arr[i];

    int cnt = 0;
    while(isAllEven(arr, N)) {
        cnt++;
        REP(i, N) {
            arr[i] = arr[i] /2;
        }
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	if ( (A < 10) && (B < 10)){
		cout << A*B << "\n";
	} else {
		cout << -1 << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
def solve(n, p):
    q = [n] * n
    q[0] = p[0]
    for i in range(1, n):
        q[i] = min(q[i-1], p[i])
    ans = 0
    for i in range(n):
        if p[i] <= q[i]:
            ans += 1
    return ans

n = int(input())
p = list(map(int, input().split()))
print(solve(n, p))

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (bit & (1LL << i))

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> using VVVV = std::vector<std::vector<std::vector<std::vector<T>>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

    string S, T;
    cin >> S >> T;

    VV<int> dp(S.size() + 1, V<int>(T.size() + 1));
    FOR(i, 1, S.size() + 1) {
        FOR(j, 1, T.size() + 1) {
            if (S[i - 1] == T[j - 1]) {
                chmax(dp[i][j], dp[i - 1][j - 1] + 1);
            }
            else {
                chmax(dp[i][j], max(dp[i][j - 1], dp[i - 1][j]));
            }
        }
    }

    string ans = "";
    int i = S.size(), j = T.size();
    while (i > 0 and j > 0) {
        if (S[i - 1] == T[j - 1]) {
            ans += S[i - 1];
            i--;
            j--;
        }
        else {
            if (dp[i - 1][j] > dp[i][j - 1]) {
                i--;
            }
            else {
                j--;
            }
        }
    }

    reverse(ALL(ans));
    print(ans);

	return 0;
}

Measured memory_bytes: 35584
import Control.Monad
import Data.List
main = do
  [_,k] <- map read . words <$> getLine
  xs <- map read . words <$> getLine
  print $ minimum (map solve $ pair k xs)
 
pair k xs = zip xs (drop (k-1) xs)
solve (a,b)
  | a < 0 && b < 0  = (abs a)
  | a < 0 && 0 <= b = 2*(min (abs a) b) + max (abs a) b
  | otherwise       = b

Measured memory_bytes: 75132
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

vector<int> par_road(200000), rnk_road(200000, 0), par_train(200000), rnk_train(200000, 0);

void init(int n) {
    for (int i = 0; i < n; i++) {
        par_road[i] = i;
        par_train[i] = i;
    }
}

int root (char a, int i) {
    if (a == 'r') return i == par_road[i] ? i : par_road[i] = root('r' ,par_road[i]);
    else return i == par_train[i] ? i : par_train[i] = root('t' ,par_train[i]);
}

bool same(char a, int i, int j) {
    if (a == 'r') return root('r', i) == root('r', j);
    else return root('t', i) == root('t', j);
}

void unite(char a, int i, int j) {
    if (a == 'r') {
        i = root('r', i);
        j = root('r', j);
        if (rnk_road[i] < rnk_road[j]) {
            par_road[i] = j;
        } else {
            par_road[j] = i;
            if (rnk_road[i] == rnk_road[j]) rnk_road[i]++;
        }
    }
    else {
        i = root('t', i);
        j = root('t', j);
        if (rnk_train[i] < rnk_train[j]) {
            par_train[i] = j;
        } else {
            par_train[j] = i;
            if (rnk_train[i] == rnk_train[j]) rnk_train[i]++;
        }
    }
}

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k, l; cin >> n >> k >> l;
    
    init(n);
    for (int a = 0; a < k; a++) {
        int p, q; cin >> p >> q; p--; q--;
        unite('r', p, q);
    }
    for (int a = 0; a < l; a++) {
        int p, q; cin >> p >> q; p--; q--;
        unite('t', p, q);
    }
    
    vector<vector<int>> roots(n, vector<int>(2));
    map<vector<int>, int> cnt;
    
    for (int i = 0; i < n; i++) {
        roots[i] = {root('r', i), root('t', i)};
        cnt[roots[i]]++;
    }
    
    for (int i = 0; i < n; i++) {
        if (i != n - 1) cout << cnt[roots[i]] << ' ';
        else cout << cnt[roots[i]] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 34304
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	long long p=1;
	for(int i=2; i<=n; i++)
		p=p*i%MOD;
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 256