akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
vector<int> adj[MAXN];
int have[MAXN];
int ans[MAXN];

int deg[MAXN];
bool alive[MAXN];
int q[MAXN],qhead,qtail;

ll solve() {
	if(n==1) return 0;
	sort(have,have+n);
	REP(i,n) deg[i]=SZ(adj[i]),alive[i]=true;
	REP(i,n) if(deg[i]==1) q[qhead++]=i;
	ll ret=0; int pos=0;
	while(qtail<qhead) {
		int at=q[qtail++];
		ans[at]=have[pos++];
		if(deg[at]==1) ret+=ans[at];
		alive[at]=false;
		REPSZ(i,adj[at]) { int to=adj[at][i]; if(!alive[to]) continue; --deg[to]; if(deg[to]==1) q[qhead++]=to; }
	}
	return ret;
}


void run() {
	scanf("%d",&n);
	REP(i,n-1) { int a,b; scanf("%d%d",&a,&b); --a,--b; adj[a].PB(b); adj[b].PB(a); }
	REP(i,n) scanf("%d",&have[i]);
	printf("%lld\n",solve());
	REP(i,n) { if(i!=0) printf(" "); printf("%d",ans[i]); } puts("");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;

class unionfind {
public:
	vector<int> par;
	vector<int> rnk;

	unionfind(int N) :par(N),rnk(N) {//コンストラクタ
		for (int i = 0; i < N; i++) {
			par[i] = i;
			rnk[i] = 0;
		}
	}

	int root(int x) {//データｘが属する木の根を再帰で得る:root(x)={ｘの木の根}
		if (par[x] == x)return x;
		return par[x] = root(par[x]);

	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;//ｘとｙの根が同じ（＝同じ木にある）時はそのまま
		if (rnk[rx] < rnk[ry]) {
			par[rx] = ry;//xとyの根が同じでない（＝同じ木にない）時：ｘの根をｒｘをｙの根につける
		}
		else if (rnk[rx] > rnk[ry]) {
			par[ry] = rx;
		}
		else {
			par[rx] = ry;
			rnk[ry]++;
		}
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

};


map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for (ll i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;//
	return res;
}

bool IsPrime(ll num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y,x%y);
}


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

	ll A, B;
	cin >> A >> B;
	ll G = gcd(A, B);

	map<ll, ll> mp = prime_factor(G);
	
	ll ans = 1;
	for (auto ite = mp.begin(); ite != mp.end(); ite++) {
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cassert>
using namespace std;
using vi = vector<int>;
#define MAXN 100005

long n;
vi as;

long get_ge_med(int x) {
    vi bs(2 * MAXN);
    int s = MAXN;
    long total = n * (n + 1) / 2;
    int t = 0;
    bs[MAXN] = 1;
    for (int i = 0; i < n; i++) {
        if (as[i] >= x) {
            s++;
            t -= bs[s];
        } else {
            t += bs[s];
            s--;
        }
        bs[s]++;
        total -= t;
    }
    return total;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as.push_back(a);
    }
    
    vi vs(as);
    long t = n * (n + 1) / 2;
    sort(vs.begin(), vs.end());
    int l = 0, r = n - 1;
    if (get_ge_med(vs[r]) >= t / 2) {
        cout << vs.back() << endl;
        return 0;
    }
    while (l < r - 1) {
        int m = (l + r) / 2;
        if (get_ge_med(vs[m]) >= t / 2) {
            l = m;
        } else {
            r = m;
        }
    }
    cout << vs[l] << endl;
}


Measured memory_bytes: 1912
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let n: i32 = read();
    let a: i32 = read();
    let b: i32 = read();

    println!("{} {}", min(a, b), max(0, a + b - n))
}


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

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  sort(A.begin(), A.end());
  A.push_back(0); // dummy

  int cnt = 0;
  int pos = 0;
  for (int i = 1; i <= N; ++i) {
    if (A[i] == A[i - 1])
      continue;
    ++cnt;
    pos = i;
  }

  if (cnt % 2 == 0)
    cout << cnt - 1 << endl;
  else
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin>>N;
long long K;
cin>>K;
long long counter=0;
long long r=1;
long long po=0;
double answer=0;
for(long long i=1; i<=N;i++){
while(r<K){
r*=2;
po++;}
answer+=pow(0.5,po);
r=i+1;
po=0;}
answer/=N;
cout << fixed << setprecision(10);
cout<<answer<<endl;}


Measured memory_bytes: 256
N = input()
K = int(input())
l = len(N)
if K == 1:
    a = int(N[0])
    ans1 = 9*(l-1)+a
if K == 2:
    a=int(N[0])
    ans2 =(a-1)*9*(l-1)
    state = 0
    for n in N[1:]:
        if state:
            ans2 += 9
            continue
        if int(n) != 0:
            state = 1
        n = int(n)
        ans2 += n
    for i in range(2,l):
        ans2 += 81*(i-1)
    if l < K:
        ans2 = 0
if K == 3:
    a = int(N[0])
    ans3 = (a-1)*81*(l-1)*(l-2)/2
    state = 0
    for i in range(1,l):
        n = int(N[i])
        if state:
            ans3 += 81*(l-i-1)
            continue
        if n !=0:
            state = 1
        else:
            continue
        S = 0
        for j in range(i+1,l):
            m = int(N[j])
            if S:
                ans3 += n*9
                continue
            if m != 0:
                S = 1
            ans3 += (n-1)*9+m
    for i in range(3,l):
        ans3 += 729*(i-1)*(i-2)/2
    if l < K:
        ans3 = 0
if K == 1:
    print(ans1)
if K == 2:
    print(int(ans2))
if K == 3:
    print(int(ans3))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(void){
string a;
cin>>a;
if(a[0]==a[1]){
if(a[2]==a[3]&&a[0]!=a[2])cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

else if(a[0]==a[2]){
if(a[1]==a[3]&&a[0]!=a[1])cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
else if(a[0]==a[3]){
if(a[2]==a[1]&&a[0]!=a[2])cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200010
#define ll long long
int a[maxn]={-1,0},n,i;
ll ans=0;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]-a[i-1]>1)
		{
			ans=0;
			break;
		}
		if (a[i]-a[i-1]==1) ans++;
			else ans+=(ll)a[i];
	}
	printf("%lld",ans-1LL);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0;i<m;i++)
    cin>>b.at(i);
  int o=0;
  for(int i=0;i<n;i++){
    int s=c;
    for(int j=0;j<m;j++){
      int a;
      cin>>a;
      s+=a*b.at(j);
    }
    if(s>0)
      o++;
  }
  cout<<o<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<unordered_map>
#include<stack>

using namespace std;

int main(){
    int n,k,q;
    int a;
    cin >> n >> k >> q;
    int tq = q;
    vector<int> scores(n,0);
    while( tq-- ){
        cin >> a ;
        scores[a-1]++;
    }
    for( auto s : scores ){
        cout << ((s<=(q-k))?"No":"Yes") << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
H, W = list(map(int, input().split()))

mn = min(H, W)
if H % 3 == 0 or W % 3 == 0:
	print(0)
else:
	mn = min(H, W)

	L = []

	l1 = []
	l1.append(H * (W // 3))
	if H % 2 == 0:
		l1.append((H / 2) * (W - (W // 3)))
	else:
		l1.append((H // 2) * (W - (W // 3)))
		l1.append((H // 2 + 1) * (W - (W // 3)))
	L.append(max(l1) - min(l1))

	l2 = []
	l2.append(H * (W // 3 + 1))
	if H % 2 == 0:
		l2.append((H / 2) * (W - (W // 3 + 1)))
	else:
		l2.append((H // 2) * (W - (W // 3 + 1)))
		l2.append((H // 2 + 1) * (W - (W // 3 + 1)))
	L.append(max(l2) - min(l2))

	l3 = []
	l3.append(W * (H // 3))
	if W % 2 == 0:
		l3.append((W / 2) * (H - (H // 3)))
	else:
		l3.append((W // 2) * (H - (H // 3)))
		l3.append((W // 2 + 1) * (H - (H // 3)))
	L.append(max(l3) - min(l3))

	l4 = []
	l4.append(W * (H // 3 + 1))
	if W % 2 == 0:
		l4.append((W / 2) * (H - (H // 3 + 1)))
	else:
		l4.append((W // 2) * (H - (H // 3 + 1)))
		l4.append((W // 2 + 1) * (H - (H // 3 + 1)))
	L.append(max(l4) - min(l4))

	mnmn = min(L)

	mn2 = min(L)

	print(int(min(mn, mn2)))

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

int main(void) {
    long n;
    cin >> n;
    vector<long> a(n);
    for(auto &e: a) cin >> e;
    sort(a.begin(), a.end());

    long m = a[n-1];

    if(m == 1) {
        cout << (n==2 ? "Possible" : "Impossible") << endl;
        return 0;
    }
    if(m%2 == 0) {
        bool ok = true;
        for(long i=m/2 + 1; i<=m; i++)
            ok &= (upper_bound(a.begin(), a.end(), i) - lower_bound(a.begin(), a.end(), i)) >= 2;
        ok &= a[0] == m/2;
        ok &= a[1] > m/2;

        cout << (ok ? "Possible" : "Impossible") << endl;
    } else {
        bool ok = true;
        for(long i=(m+1)/2; i<=m; i++)
            ok &= (upper_bound(a.begin(), a.end(), i) - lower_bound(a.begin(), a.end(), i)) >= 2;
        ok &= a[0] == (m+1)/2;
        ok &= a[1] == (m+1)/2;
        ok &= a[2] > (m+1)/2;

        cout << (ok ? "Possible" : "Impossible") << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> c(m);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        c.emplace_back(a,b);
    }
    reverse(c.begin(), c.end());
    UnionFind uf(n);
    vector<ll> ans(m);
    ll mx = (ll)n*(n-1)/2;
    ans[0] = mx;
    rep(i,m-1) {
        int a = c[i].first, b = c[i].second;
        if (uf.same(a,b)) {
            ans[i+1] = ans[i];
            //uf.unite(a,b);
            continue;
        }
        ans[i+1] = ans[i] - ll(uf.size(a))*uf.size(b);
        uf.unite(a,b);
        if (ans[i+1] == 0) break;
    }
    reverse(ans.begin(), ans.end());
    rep(i,m) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5940
package main

import (
	"fmt"
)

func main() {
	var A, B int
	var ans string
	fmt.Scan(&A, &B)

	if A%3 == 0 || B%3 == 0 || (A+B)%3 == 0 {
		ans = "Possible"
	} else {
		ans = "Impossible"
	}

	fmt.Println(ans)
}

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

typedef long long ll;

int main() {
    int X, N, p;
    cin >> X >> N;
    set<int> s;
    rep(i, N) {
        cin >> p;
        s.insert(p);
    }
    rep(i, 200) {
        if (s.find(X - i) == s.end()) {
            cout << X - i << "\n";
            return 0;
        }
        if (s.find(X + i) == s.end()) {
            cout << X + i << "\n";
            return 0;
        }
    }
}

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

typedef long long ll;
const int maxn = 1e5 + 10;
int n;
ll C, mx, x[maxn], v[maxn], a[maxn], b[maxn];

int main() {
    scanf("%d %lld", &n, &C);
    for (int i = 1; i <= n; i++) {
        scanf("%lld %lld", &x[i], &v[i]);
        a[i] = a[i - 1] + x[i - 1] - x[i] + v[i];
    }
    x[n + 1] = C;
    for (ll i = n; i >= 1; i--) {
        b[i] = b[i + 1] + x[i] - x[i + 1] + v[i];
    }
    for (int i = 2; i <= n; i++) {
        a[i] = max(a[i], a[i - 1]);
    }
    for (int i = n - 1; i >= 1; i--) {
        b[i] = max(b[i], b[i + 1]);
    }
    for (int i = 1; i <= n; i++) {
        mx = max(mx, a[i]), mx = max(mx, b[i]);
        mx = max(mx, a[i] - x[i] + b[i + 1]);
        mx = max(mx, b[i] - (C - x[i]) + a[i - 1]);
    }
    printf("%lld\n", mx);
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 10005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    ll x;
    cin>>x;
    cout<<(x*x);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


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

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
        int n,sum=0;
        cin>>n;
        int max=0;
        int l[n];
        rep(i,n){
                cin>>l[i];
                sum+=l[i];
                if (max<l[i]) max=l[i];
        }
  		sum -=max;
  	//	cout << sum << max << endl;
        if(sum>max) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;


signed main(){
    while(1){
        int n, m;
        cin >> n >> m;
        if(n + m == 0) break;
        vector<int> h(n + 1), w(m + 1);
        rep(i, 1, n + 1) cin >> h[i];
        rep(i, 1, m + 1) cin >> w[i];
        rep(i, 1, n + 1) h[i] += h[i - 1];
        rep(i, 1, m + 1) w[i] += w[i - 1];
        vector<int> hh, ww;
        rep(i, 0, n + 1){
            rep(j, i + 1, n + 1){
                hh. push_back(h[j] - h[i]);
            }
        }
        rep(i, 0, m + 1){
            rep(j, i + 1, m + 1){
                ww. push_back(w[j] - w[i]);
            }
        }
        sort(all(hh));
        sort(all(ww));
        int ans = 0;
        rep(i, 0, hh.size()){
            int id = upper_bound(all(ww), hh[i]) - lower_bound(all(ww), hh[i]);
            ans += id;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 36896
# input as list
a,b,c = [list(input()) for i in range(3)]
 
# set initial
temp = 'a'
 
# loop start
while True:
    if temp == 'a':
        if len(a) == 0:
            print('A')
            break
        else:
            temp = a.pop(0)
    elif temp == 'b':
        if len(b) == 0:
            print('B')
            break
        else:
            temp = b.pop(0)
    elif temp == 'c':
        if len(c) == 0:
            print('C')
            break
        else:
            temp = c.pop(0)
 
#eo

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

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

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

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

  if (b + c > a) {
    cout << b + c - a << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


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

int main() {
  
  string S, T;
  cin >> S >> T;
  
  if(T.size() != S.size()+1) cout << "No" << endl;
  
  else {
    
    for(int i = 0; i < S.size(); i++) {
      
      if(S.at(i) != T.at(i)) {
        cout << "No" << endl;
        break;
      }
      
      else {
        if(i == S.size() -1) cout << "Yes" << endl;
        else continue;
      }
      
    }
    
  }
  
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    ld btc = 0, yens = 0;
    for (int i = 0; i < n; i++) {
        ld x; cin >> x;
        string s; cin >> s;
        if (s[0] == 'J') {
            yens += x;
        } else {
            btc += x;
        }
    }
    ld rate = (ld) 380000;
    cout << yens + btc * rate << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll H, W;
    cin >> H >> W;
    ll mass = 0;
    if(H == 1 || W == 1){cout << 1 << endl;}
    else{
        if(H % 2 == 0){
            mass += W*(H/2);
        }else{
            if(W % 2 == 1){
                mass += W*(H/2) + (W/2+1);
            }else{
                mass += W*(H/2) + (W/2);
            }
        }
        cout << mass << endl;
    }
}

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

int main() {
  char a,b,c,d;
  string x;
  cin >> x;
  
  a=x[0],b=x[1],c=x[2],d=x[3];
  
  if((a==b&&b==c)||(b==c&&c==d)){
      cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int n,k,c;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}    
	c=(n-1)%(k-1);
	if(c==0){
		cout << (n-1)/(k-1) << endl;
	}
	else{
		cout << (n-1)/(k-1)+1 << endl;
	}
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    string s;
    while(cin >> s) {
        int ans = s.length();
        bool flag = false;
        for(int i = 1, len = s.length(); i < len; ++i) {
            if(flag) { flag = false; }
            else if(s[i] == s[i-1]) { ans --; flag = true; i += 1; }
            else { flag = false; }
        }
        // ans ++;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

int main()
{
	ll a, b;
	cin >> a >> b;

	ll g = gcd(a, b);
	ll x = g;
	ll p = 2;
	ll cnt = 0;

	do
	{
		if (x % p == 0) {
			cnt++;
			while (x % p == 0)
			{
				x /= p;
			}
		}
		p++;
		if (x == 1)
			break;
		if (p * p > g) {
			if (x > 1)
				cnt++;
			break;
		}
	} while (true);
	cout << (cnt + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll a, b;
  cin >> a >> b;
  ll x;
  cin >> x;
  ll ans = b/x-a/x;
  if(a%x==0)ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
b1,b2,b3=map(int,input().split())
if b1 == 1 and b2 == 0 and b3 == 0:
    print('Close')
elif b1 == 0 and b2 == 1 and b3 == 0:
    print('Close')
elif b1 == 1 and b2 == 1 and b3 == 0:
    print('Open')
elif b1 == 0 and b2 == 0 and b3 == 1:
    print('Open')
else:
    print('Close')


Measured memory_bytes: 5596
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int bo = 100;
    for(char c = 'a'; c <= 'z'; c++)
    {
        char s2[n];
        bool ok = 1;
        for(int i = 0; i < n; i++)
        {
            s2[i] = s[i];
            if(s[i] != c)
            {
                ok = 0;
            }
        }
        int ctr = 0;
        int cn = n;
        while(!ok)
        {
            cn--;
            ctr++;
            ok = 1;
            for(int i = 0; i < cn; i++)
            {
                if(s2[i] == c)
                {
                    continue;
                }
                s2[i] = s2[i + 1];
                if(s2[i] != c)
                {
                    ok = 0;
                }
            }
        }
        bo = min(bo, ctr);
    }
    cout << bo << endl;
    cin >> bo;
}


Measured memory_bytes: 256
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

n = int(input())
S = [int(x) for x in input().split()]
#S = list(map(int,input().split()))
q = int(input())
T = [int(x) for x in input().split()]
#T = list(map(int,input().split()))

ans = 0
for key in T:
    if key in S:
        ans += 1
print("%d"%(ans))


Measured memory_bytes: 7948
n, k = map(int, input().split())
a = list(map(int, input().split()))
plus, zero, minus = [], [], []
for x in a:
	if x > 0:
		plus.append(x)
	elif x == 0:
		zero.append(x)
	else:
		minus.append(x)
m, z, p = len(minus), len(zero), len(plus)
mm, zz, pp = m * p, z * (m + p) + (z * (z - 1)) // 2, (m * (m-1)) // 2 + (p * (p-1)) // 2
plus.sort()
plus2 = plus[::-1]
minus.sort()
minus2 = minus[::-1]
#print(mm, zz, pp)

if mm + zz >= k and mm < k:
	print(0)
elif mm >= k:
	ok, ng = -10**19, 0
	while ng-ok > 1:
		x = (ng+ok)//2
		res = 0
		l = 0
		for c in plus:
			if l == m:
				res += m
			elif minus[l] * c >= x:
				res += l
			else:
				while minus[l] * c < x:
					l += 1
					if l == m:
						break
				res += l
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)
else:
	ok, ng = 0, 10**19
	while ng-ok > 1:
		x = (ng+ok)//2
		lm, lp = 0, 0
		res = 0
		for c in minus:
			if c*c < x:
				res -= 1
			if lm == m:
				res += m
			elif minus2[lm] * c >= x:
				res += lm
			else:
				while minus2[lm] * c < x:
					lm += 1
					if lm == m:
						break
				res += lm
		for c in plus2:
			if c*c < x:
				res -= 1
			if lp == p:
				res += p
			elif plus[lp] * c >= x:
				res += lp
			else:
				while plus[lp] * c < x:
					lp += 1
					if lp == p:
						break
				res += lp
		res //= 2
		res += zz + mm
		#print(x, res)
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)


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

ll f(ll b, ll n){
    if(n < b) return n;
    return n % b + f(b, n / b);
}

int main(){
    ll n, s;
    cin >> n >> s;
    if(s >= n){
        cout << (s == n ? n + 1 : -1) << endl;
        return 0;
    }
    for(ll i = 2; i * i <= n; i++){
        if(s == f(i, n)){
            cout << i << endl;
            return 0;
        }
    }
    for(ll i = sqrt(n); i >= 1; i--){
        if((n - s) % i != 0) continue;
        if(f((n - s) / i + 1, n) == s){
            cout << (n - s) / i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  
  if (A <= (B * 2)) {
    cout << 0 << endl;
  } else {
    cout << A - (B * 2) << endl;
  }
  
  return 0;
}

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

int main()
{
    int n;
    bool was=false;
    cin >> n;
    vector<long long> a(n+1);
    vector<long long> b(n);
    long long sum=0;
    for(int i=0; i<n+1; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    for(int i=0; i<n; i++){
        sum+=min(a[i]+a[i+1], b[i]);
        a[i+1]=min(a[i]+a[i+1]-b[i], a[i+1]);
        a[i+1]=a[i+1]>0?a[i+1]:0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
/*
power code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX 1000000000LL
#define MAX_N 200001
using namespace std;
typedef long long ll;
typedef long double ld;
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

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

bool comp(ll a, ll b){
    return a>b;
}


void solve(){
    ll n,k;
    cin>>n>>k;
    ll m=n%k;
    cout<<min(m, k-m)<<endl;
}
int main(){



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

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string>
using namespace std;
 
int main(){
    int n,m,q;

    
    scanf("%d %d %d", &n,&m,&q);
    int lr[n+1][n+1];
    int c[n+1][n+1];

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

    for(int i=0; i<m; i++){
        int l,r;
        scanf("%d %d", &l, &r);
        lr[l][r]++;
    }

    for(int i=0; i<=n; i++){
        c[i][0] = lr[i][0];
        for(int j=1; j<=n; j++){
            c[i][j] = c[i][j-1] + lr[i][j];
        }
    }

/*
    for(int i=0; i<=n; i++){
        for(int j=1; j<=n; j++){
            printf("%d %d %d\n", i,j,lr[i][j]);
            printf("%d %d %d\n", i,j,c[i][j]);
        }
    }
*/

    for(int i=0; i<q; i++){
        int pp,qq;
        scanf("%d %d", &pp, &qq);
        int ans = 0;
        for(int j=pp; j<=qq; j++){
            ans += c[j][qq] - c[j][pp-1];
        }
        printf("%d\n", ans);
    }

}

Measured memory_bytes: 2816
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vector<int> v;
  int size = 1;

  FOR(i, 1, n)
  {
    if (s[i - 1] == s[i])
    {
      size++;
    }
    else
    {
      v.push_back(size);
      size = 1;
    }
    if (i == n - 1)
    {
      v.push_back(size);
    }
  }

  int ans = 0;
  if (v.size() / 2 <= k)
  {
    cout << n - 1 << endl;
    return 0;
  }

  cout << n - (v.size() - 2 * k) << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; int k; cin>>s>>k;
	set<string>st;
	for(int i=0;i<s.size();++i){
		for(int j=1;j<=min(5,(int)s.size()-i);++j){
			st.insert(s.substr(i,j));
		}
	}
	for(auto&&i:st){
		if(--k==0){
			cout<<i<<"\n"s;
			return 0;
		}
	}
}


Measured memory_bytes: 4752
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;
	string s, t;
	cin >> n;
	cin >> s >> t;
	string ans = "";

	rep(i, n) {
		ans.push_back(s[i]);
		ans.push_back(t[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
	int N; cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; ++i)
		cin >> p[i];
	vector<int> a(N), b(N);
	for (int i = 0; i < N; ++i) {
		a[i] = 20020 * (i + 1);
		b[i] = 20020 * (N - i);
	}
	for (int i = 0; i < N; ++i)
		a[p[i] - 1] += i;
	for (auto ai : a)
		cout << ai << " ";
	cout << endl;
	for (auto bi : b)
		cout << bi << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<list>
#include<string>
#include<unordered_map>
#include<set>
#include<limits.h>
#include<string.h>
#include<functional>
#include<map>
#include<unordered_set>
#define int long long
using namespace std;

signed main() {
	int n, a, b; cin >> n >> a >> b;
	vector<vector<int>>V;
	for (int i = 1; i <= (n - 1) / b + 1; i++) {
		vector<int>v;
		for (int j = b; j >= 1; j--) {
			if ((i-1)*b + j <= n) {
				v.push_back((i-1)*b + j);
			}
		}
		V.push_back(v);
	}
	if (V.size() > a) {
		puts("-1");
		return 0;
	}
	int sum = a - V.size();
	for (int i = 1; i < V.size(); i++) {
		if (V[i].size() - 1 <= sum) {
			reverse(V[i].begin(), V[i].end());
			sum -= V[i].size() - 1;
		}
		else if (sum) {
			auto c = V[i].begin();
			for (int j = 0; j < sum + 1; j++)c++;
			reverse(V[i].begin(), c);
			sum = 0;
			break;
		}
	}
	if (sum) { puts("-1"); return 0; }
	sum = 0;
	for (int i = 0; i < V.size(); i++) {
		if (i)cout << " ";
		for (int j = 0; j < V[i].size(); j++) {
			if (j)cout << " ";
			cout << V[i][j];
		}
	}
	cout << endl;
}

Measured memory_bytes: 22316
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll k,n;
int32_t main(){
cin>>k;
cin>>n;
for(ll i=n-k+1;i<=n+k-1;i++)
    cout<<i<<' ';
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll l, r, d; cin >> l >> r >> d;
  ll ans = 0;
  for(ll i = l;i <= r;i ++)
  {
    if(i % d == 0) ans++;
  }
  fin(ans);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 3620
n, s = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353
U = 3010
dp = [0] * (U + 1)
dp[0] = 1
for a in A:
    dp2 = [0] * (s + 1)
    for j in range(s + 1):
        dp2[j] = dp[j] * 2
        if j >= a:
            dp2[j] += dp[j - a]
        dp2[j] %= MOD
    dp = dp2

print(dp[s])

Measured memory_bytes: 68676
#include<iostream>
using namespace std;
int mul_num(int a)
{
    int temp=1,x;
    while(a!=0)
    {
        x = a%10;
        if(x>=2){
        temp= temp*x;
        }
        else
        {
           return 0;
        }
        a=a/10;
    }
    return temp;
}
int main()
{
    int day,month;
    cin>> month>>day;
    int start=22, mul,coun=0;
    while(start<=day)
    {
        mul = mul_num(start);
        if(mul<=month&&mul>=4)
        {
            coun++;
        }
        start++;
    }
   cout<<coun<<endl;
}



Measured memory_bytes: 256
import sys
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]

N, A, B = ri_()
print(min(A * N, B))

Measured memory_bytes: 38384
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
      int a = scan.nextInt();
      int b = scan.nextInt();

      double f = 1.0 * a / b  ;

    System.out.println(a / b+" "+a % b+" "+String.format("%.8f",f));
  }
}


Measured memory_bytes: 26392
package main

import (
	"fmt"
)

func solve(a, b int) int {
	switch {
	case a < 6:
		return 0
	case a <= 12:
		return b / 2
	default:
		return b
	}
}

func main() {
	var a, b int
	fmt.Scanln(&a, &b)
	ans := solve(a, b)
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>
#define TMAX 100001
#define THALF 70000
int main(void){
    int N, T, in, out, sw, max=0, i, j;
	int time[TMAX];
    scanf("%d%d", &N, &T);
	scanf("%d%d", &in, &out);
	sw = (THALF > out-in ? 1 : 2);
	switch(sw){
		case 1:
			for(j=0; j<T; j++){
				*(time+j) = 0;
			}
  			for(j=in; j<out; j++){
               	*(time+j) += 1;
            }
			for(i=1; i<N; i++){
				scanf("%d%d", &in, &out);
 		    	for(j=in; j<out; j++){
               		*(time+j) += 1;
           		}
    		}
		    for(j=0; j<T; j++){
		        max = (max < *(time+j) ? *(time+j) : max);
		    }
			break;
		case 2:
			for(j=0; j<T; j++){
				*(time+j) = N;
			}
			for(j=0; j<in; j++){
				*(time+j) -= 1;
			}
			for(j=out; j<=T; j++){
				*(time+j) -= 1;
			}
			for(i=1; i<N; i++){
				scanf("%d%d", &in, &out);
				for(j=0; j<in; j++){
					*(time+j) -= 1;
				}
				for(j=out; j<=T; j++){
					*(time+j) -= 1;
				}
			}
			for(j=0; j<T; j++){
				max = (max < *(time+j) ? *(time+j) : max);
			}
			break;
		default:
			break;
	}
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

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

  int n;
  cin >> n;
  vector<int> l(n);

  rep(i,n) cin >> l[i];
  int ans = 0;

  sort(l.begin(), l.end());
  
  rep(i,n){
      for(int j = i+1;j < n; j++){
          for(int k = j+1;k < n; k++){
              if((l[i]<l[j]+l[k])&&(l[j]<l[i]+l[k])&&(l[k]<l[i]+l[j])) ans++;
              else break;
          }
      }
  }
  
  cout << ans;

    return 0;
}

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

int main() {
    bool cards[4][14];
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j <= 13; j++) {
            cards[i][j] = false;
        }
    }
    /*
    以下のような対応付けで考える
    0: S
    1: H
    2: C
    3: D
    */

    int n, cardNum;
    char type;
    cin >> n;

    // カードの状態を表す入力値の処理
    for (int i = 0; i < n; i++) {
        char type;
        cin >> type >> cardNum;

        if (type == 'S')
            cards[0][cardNum] = true;
        if (type == 'H')
            cards[1][cardNum] = true;
        if (type == 'C')
            cards[2][cardNum] = true;
        if (type == 'D')
            cards[3][cardNum] = true;
    }

    // カードを出力する
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j <= 13; j++) {
            if (cards[i][j])
                continue;
            if (i == 0)
                type = 'S';
            if (i == 1)
                type = 'H';
            if (i == 2)
                type = 'C';
            if (i == 3)
                type = 'D';
            cout << type << " " << j << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  cin >> n;
  cin >> s;
  ll cur = 0;
  ans = 1;
  rep(i, 2 * n) {
    if (s[i] == 'B') {
      if (cur % 2) {
        if (!cur) {
          cout << "0" << endl;
          return 0;
        }
        else {
          (ans *= cur) %= mod;
          cur--;
        }
      }
      else cur++;
    }
    else {
      if (cur % 2) cur++;
      else {
        if (!cur) {
          cout << "0" << endl;
          return 0;
        }
        else {
          (ans *= cur) %= mod;
          cur--;
        }
      }
    }
  }
  if (cur) {
    cout << "0" << endl;
    return 0;
  }
  FOR(i, 1, n + 1) (ans *= i) %= mod;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int T,i,j,k,l,N,K;
    vector<ll int> H;
    cin>>N>>K;
    for (i=0; i<N; i++) {
        cin>>j;
        H.push_back(j);
    }
    
    sort(H.begin(), H.end(), greater<>());
    ll int sum=0;
    for (i=K; i<N; i++) {
        sum += H[i];
    }
    
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

vector<vector<bool>> cht(string s) {
	vector<vector<bool>> res;
	vector<bool> buf;
	rep(i, s.size()) {
		if (s[i] == 'b')buf.push_back(1);
		else if (s[i] == '/') {
			res.push_back(buf);
			buf.clear();
		}
		else {
			rep(j, s[i] - '0')buf.push_back(0);
		}
	}
	res.push_back(buf);
	return res;
}

string chs(vector<vector<bool>> t) {
	string res;
	rep(i, t.size()) {
		ll cnt = 0;
		rep(j, t[i].size()) {
			if (t[i][j]) {
				string ss = "0";
				if (cnt != 0) {
					ss[0] += cnt;
					res += ss;
				}
				res += "b";
				cnt = 0;
			}
			else cnt++;
		}
		string ss = "0";
		if (cnt != 0) {
			ss[0] += cnt;
			res += ss;
		}
		if (i != t.size() - 1)res += "/";
	}
	return res;
}

string s;

int main() {
	while (cin >> s&&s != "#") {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--;
		b--;
		c--;
		d--;
		vector<vector<bool>> tt = cht(s);
		tt[a][b] = 0;
		tt[c][d] = 1;
		cout << chs(tt) << endl;
	}
}

Measured memory_bytes: 3184
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
#define FOR(x, to) for(x=0; x<(to); x++)

 int main(){
    string S;
    cin >> S;
    int a = stoi(S) / 100, b = stoi(S) % 100;
   
    if(a >= 13 && b >= 13){
        cout << "NA" << endl;
        return 0;
    }
    if(a == 0 && b == 0){
        cout << "NA" << endl;
        return 0;
    }
    if(a == 0 && b >= 13){
        cout << "NA" << endl;
        return 0;
    }
    if(b == 0 && a >= 13){
        cout << "NA" << endl;
        return 0;
    }
    

    if(a >= 13 || a == 0){
        cout << "YYMM" << endl;
        return 0;
    }
    if(b >= 13 || b == 0){
        cout << "MMYY" << endl;
        return 0;
    }
    
    cout << "AMBIGUOUS" << endl;
    return 0;
 }

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

struct UnionFind{
  Int n;
  vector<Int> r,p;
  UnionFind(){}
  UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  s="a"+s+"a";

  UnionFind uf(s.size()-1);
  vector<Int> v(s.size()-1);
  for(Int i=0;i<(Int)s.size()-1;i++) v[i]=s[i]-s[i+1]+26;
  
  Int n;
  cin>>n;
  for(Int i=0;i<n;i++){
    Int l,r;
    cin>>l>>r;
    l--;
    uf.unite(l,r);
  }

  for(Int i=0;i<(Int)s.size()-1-(1+i);i++)
    uf.unite(i,(Int)s.size()-1-(1+i));

  vector<Int> ans(s.size()-1,0);
  for(Int i=0;i<(Int)s.size()-1;i++)
    ans[uf.find(i)]+=v[i];

  //for(Int x:ans) cout<<x<<endl;

  Int flg=0;
  for(Int x:ans) flg|=x%26;

  cout<<(flg?"NO":"YES")<<endl;
  return 0;
}


Measured memory_bytes: 3580