akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n;
	cin>>n;
	long long a[n],sum=0;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		sum+=a[i];
	}
	long long x=0,ans=1000000000000000000LL;
	for(int i=0;i<n;i++){
		x+=a[i];
		if(i+1<n) ans=min(ans,abs(sum-2*x));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

        String message = turn(a,d) >= turn(c, b) ? "Yes" : "No";
        System.out.println(message);
    }
    static int turn(int hp, int atk) {
        return hp / atk + (hp % atk == 0 ? 0 : 1);
    }
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  REP(i,k){
    if(a>=b && a>=c){
      a *= 2;
    }else if(b>=a && b>=c){
      b *= 2;
    }else{
      c *= 2;
    }
  }
  cout << a+b+c << endl;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    int now = 1;
    REP(i,n){
        if(now<k){
            now *=2;
        }else{
            now += k;
        }
    }
    cout << now << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int x,a,b;
    cin >> x >> a >> b;
    int n;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        if(s == "nobiro"){
            x += a;
        }else if(s == "tidime"){
            x += b;
        }else{
            x = 0;
        }
        if(x < 0)x = 0;
    }
    cout << x << endl;
}



Measured memory_bytes: 3204
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,r,o;
	cin>>n>>r;
	if(n>=10){
		o=r;
	}else{
		o=r+(100*(10-n));
	}
	cout<<o;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define PI  3.141592653589793
int main(void){
    double r, L, S;
    scanf("%lf", &r);
    0 < r < 10,000;
    
    
    L=2*r*PI;
    S=r*r*PI;
    
    printf("%f %f\n",S,L);
        
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;++i) {
    cin >> h[i];
  }
  bool ok = true;
  for(int i=n-2;i>=0;--i) {
    if(h[i] > h[i+1] + 1) {
      ok = false;
      break;
    } else if(h[i] > h[i+1]) {
      h[i]--;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
using namespace std;
 
 int main (){
     int a,b,c,count=0;
     cin >> a >> b >> c;
     int i;
     for (i=a;i<=b;i++){
         if (c%i==0){
             count++;
         }
     }
     cout << count << endl;

 }


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

int main() {
	int n, m;
	cin >> n >> m;
	if(n % 2){
		if(n == 1){
			cout << m << endl;
		}
		else{
			REP(i,(n+1)/2){
				if(i)
					cout << " ";
				cout << "0";
			}
			FOR(i,(n+1)/2,n){
				cout << " " << m;
			}
		}
	}
	else{
		REP(i,n/2+1){
			if(i)
				cout << " ";
			cout << "0";
		}
		FOR(i,n/2+1,n){
			cout << " " << m;
		}
	}
	cout << endl;
	return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long L){
    int digits = 0;
    rep(i,0,21) {
        if ((1<<i) > L) {
            digits = i;
            break;
        }
    }
    vector<vector<ll>> answer;
    rep(i,1,digits) {
        answer.push_back({i, i+1, 0});
        answer.push_back({i, i+1, 1LL<<(i-1)});
    }
    rrep(i,1,digits) {
        if (L-(1LL<<(i-1)) >= (1LL<<(digits-1))) {
            answer.push_back({i, digits, L-(1LL<<(i-1))});
            L -= 1LL << (i-1);
        }
    }
    cout << digits << " " << answer.size() << endl;
    rep(i,0,answer.size()) {
        cout << answer[i][0] << " " << answer[i][1] << " " << answer[i][2] << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long L;
    scanf("%lld",&L);
    solve(L);
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int main() {
    long long n, m, sum = 0, n1 = 0, n2 = 0, n3 = 0;
    cin >> n >> m;
    vector<long long> s(m);
    vector<long long> c(m);
    map<int, int> cnt;
    if (m == 0) {
        if (n == 1) {
            cout << 0 << endl;
            return 0;
        }
        if (n == 2) {
            cout << 10 << endl;
            return 0;
        }
        if (n == 3) {
            cout << 100 << endl;
            return 0;
        }
    }
    for (long long i = 0; i < m; i++) {
        cin >> s[i];
        cin >> c[i];
        if (s[i] == 1) {
            n1 = c[i];
        }
        if (s[i] == 2) {
            n2 = c[i];
        }
        if (s[i] == 3) {
            n3 = c[i];
        }
        // cout << "hoge" << endl;
    }
    for (long long i = 0; i < m; i++) {
        if (cnt.count(s[i])) {
            if (cnt[s[i]] != c[i]) {
                cout << -1 << endl;
                return 0;
            }
        }
        cnt[s[i]] = c[i];
    }
    if (n == 1) {
        if (s[0] == 1 && c[0] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    if (cnt.count(1) && cnt[1] == 0) {
        cout << -1 << endl;
        return 0;
    }
    if (n == 3) {
        if (n1 == 0 && cnt.count(1) == 0) {
            n1 = 1;
        }
        cout << n1 * 100 + n2 * 10 + n3 << endl;
    }
    if (n == 2) {
        if (n1 == 0 && cnt.count(1) == 0) {
            n1 = 1;
        }
        cout << n1 * 10 + n2 << endl;
    }
    if (n == 1) {
        cout << n1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <string>
#include <map>
using namespace std;

int main(void) 
{
    string s;
    cin >> s;
    string rs(s.rbegin(), s.rend());
    int ten = 1;
    int prev = 0;
    std::map<int,int> rem;
    rem[0] = 1;
    for (int i = 0; i < rs.size(); i++)
    {
        int id = (prev + (rs[i] - '0')*ten)%2019;
        ten = ten * 10 % 2019;
        rem[id]++;
        prev = id;
    }

    int ans = 0;
    for (int i = 0; i < 2019; i++)
    {
        int tmp = rem[i];
        ans += tmp *(tmp - 1) / 2;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3900
N = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))
T = sum(t)
ans = [0]

for i in range(N):
  ans[-1] = min(ans[-1],v[i])
  for j in range(t[i]*2):
    ans.append(v[i])

ans[-1] = 0

for i in range(2*T):
  ans[i+1]=min(ans[i]+0.5,ans[i+1])

for i in range(2*T,0,-1):
  ans[i-1]=min(ans[i]+0.5,ans[i-1])

print(sum(ans)/2)

Measured memory_bytes: 9444
#include<iostream>
#include<array>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = a + b;
	int r = c + d;
	if (l > r) {
		cout << "Left" << endl;
	}
	else if (r > l) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
def main():
    H, W = list(map(int, input().split()))
    ww = W // 2
    hh = H // 2
    ans = 10 ** 11
    max_min = lambda x, y, z: max(x, y, z) - min(x, y, z)
    if W % 3  == 0 or H % 3 == 0:
        print(0)
        exit()
    if H > 3:
        ans = min(ans, W)
    if W > 3:
        ans = min(ans, H)
    for h in range(1, H):
        s0 = h * W
        s1 = (H - h) * ww
        s2 = (H - h) * (W - ww)
        ans = min(ans, max_min(s0, s1, s2))
    for w in range(1, W):
        s0 = w * H
        s1 = (W - w) * hh
        s2 = (W - w) * (H - hh)
        ans = min(ans, max_min(s0, s1, s2))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
var
    n,i,ans:longint;
    a,b:array[1..1000]of longint;
begin
    readln(n);
    for i:=1 to n do
    begin
        readln(a[i],b[i]);
        inc(ans,b[i]-a[i]+1);
    end;
    writeln(ans);
end.


Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


fn main() {
    input!{
        n:usize,
        h:[i32;n]
    }

let mut a = 1;
let mut ret = vec![0 ; n];
let mut result = "Yes";

for (i,b) in  h.iter().enumerate(){
    ret[i] = if b > &a { b-1} else {*b};
    mydbg!(ret[i]);
    if a > ret[i] {
        result = "No";
        break;
    }
    a = ret[i];
}
   
   println!("{}",result);


}


Measured memory_bytes: 6396
N,K = map(int,input().split())

X = []
Y = []
Z = []

for i in range(N):
  x,y = map(int,input().split())
  X.append(x)
  Y.append(y)
  Z.append([x,y])
  
Y.sort()
X.sort()
ans = 10**100

for t in range(N):
  for u in range(N):
    for r in range(N):
      for l in range(N):
        T = Y[N-t-1]
        U = Y[u]
        R = X[N-r-1]
        L = X[l]
        
        if T <= U or R <= L:
          continue
        
        cnt = 0
        for i in range(N):
          xi = Z[i][0]
          yi = Z[i][1]
          if xi >= L and xi <= R and yi >= U and yi <= T:
            cnt += 1
        if cnt >= K:
          M = int( (T-U) * (R-L) )
          ans = min(ans,M)
          
print(ans)

Measured memory_bytes: 49116
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,lim; cin>>n>>lim;
	int c,t;
	int cost=1e7;
	while(n--)
	{
		cin>>c>>t;
		//cout<<c<<" "<<t<<" "<<cost<<"\n";
		if(t<=lim && c<cost) cost=c;
	}
	if(cost==1e7) cout<<"TLE\n";
	else cout<<cost<<"\n";
	return 0;
}

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


inline int read()
{
	int num=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {num=(num<<1)+(num<<3)+ch-'0'; ch=getchar();}
	return num*f;
}
int main()
{
	int n=read();
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		int cnt=n/i;
		if(n%i==0) cnt--;
		ans+=cnt;		
	}		
	printf("%d ",ans);
	
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll all=1,minus=1;
    REP(i,n){
        int num;
        cin>>num;
        if(num%2==0) minus*=2;
        all*=3;
    }
    cout<<all-minus<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int fir[100010],dis[200010],nxt[200010],id,d[100010];
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int que[100010],hd,tl,W[100010];
char S[100010];
bool del[100010];
int dist[100010],rt;
void DFS(int x,int fa=-1){
	for(int i=fir[x];i;i=nxt[i]){
		if(dis[i]==fa)continue;
		dist[dis[i]]=W[dis[i]]+dist[x];
		DFS(dis[i],x);
	}
	if(dist[x]>dist[rt])rt=x;
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),a,b;if(!n)puts("0"),exit(0);
	for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a),++d[a],++d[b];
	scanf("%s",S+1);
	for(int i=1;i<=n;++i)if(d[i]<=1&&S[i]=='B')que[tl++]=i,del[i]=1;
	while(hd^tl){
		int x=que[hd++];
		for(int i=fir[x];i;i=nxt[i])if(--d[dis[i]]<=1&&S[dis[i]]=='B'&&!del[dis[i]])que[tl++]=dis[i],del[dis[i]]=1;
	}
	if(hd==n)puts("0"),exit(0);
	if(hd==n-1)puts("1"),exit(0);
	int ans=-2;
	for(int i=1;i<=n;++i)if(!del[i])ans+=2+((S[i]=='W'^(d[i]&1))),W[i]=(S[i]=='W'^(d[i]&1))*2;
	dist[1]=W[1];DFS(1);dist[rt]=W[rt];DFS(rt);
	printf("%d\n",ans-dist[rt]);
	return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e6+233;

int a[maxn];
int main() {
	int k;
	cin>>k;
	int flag=0;
	a[1] = 7%k;
	for(int i=2;i<= k;i++) {
		a[i]=(a[i-1]*10+7)%k;
	}
	for(int i=1;i<=k;i++){
		if(a[i]==0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int K;
bool dfs(int N, int A, int B, int C) {
    if (N == K) return A < B && B < C;

    if (A < B && B < C) return true;

    bool res = false;
    res |= dfs(N+1, A*2, B, C);
    res |= dfs(N+1, A, B*2, C);
    res |= dfs(N+1, A, B, C*2);

    return res;
}

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

    if (dfs(0, A, B, C)) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3600
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N; cin >> N;
    for(ll n = 1; n <= 3500; n++)
    {
        for(ll h = 1; h <= 3500; h++)
        {
            ll Nhn = N*h*n;
            ll hn4 = h*n*4;
            ll Nn = N*n;
            ll Nh = N*h; 
            ll d = hn4 - Nn - Nh;
            if(d != 0 && Nhn % d == 0)
            {
                if(Nhn / d < 0) continue;
                cout << n << " " << h << " " << Nhn / d << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    cout << N*N << endl;
}

Measured memory_bytes: 256
function Main(s) {
  var s = s.split("\n").map(e => e.split(" ").map(e => e*1));
  var dp = new Array(s[0] + 1);
  dp[0] = 0;
  for (var i = 1; i <= s[0]; i++) {
    if (i === 1) {
      dp[i] = s[i];
    } else {
      var x = Math.max(s[i][0] + dp[i-1][1], s[i][0] + dp[i-1][2]);
      var y= Math.max(s[i][1] + dp[i-1][0], s[i][1] + dp[i-1][2]);
      var z = Math.max(s[i][2] + dp[i-1][0], s[i][2] + dp[i-1][1]);
      dp[i] = [x, y, z];
    }
  }
  console.log(Math.max(dp[s[0]][0], dp[s[0]][1], dp[s[0]][2]));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 63460
import java.util.Scanner;

public class Main {
    private static Scanner scan = new Scanner(System.in);
    public static void main(String[] args) {
        String S = scan.next();
        long count = 0;
        long x = 0;
        for (int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'W'){
                count+=x;
            }else{
                x++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 27472
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        int[] nums = new int[n];
        for(int i = 0; i < n; i++) {
            String line1 = sc.nextLine();
            nums[i] = Integer.parseInt(line1);
        }
    
        for(int i = 0; i < n; i++) {
            boolean sosuu = true;
            if(nums[i] <= 1) {
                sosuu = false;
            }
            for(int j = 2; j <= Math.sqrt(nums[i]); j++) {
                if(nums[i] % j == 0) {
                    sosuu = false;
                }
            }
            if(nums[i] == 2) {
                sosuu = true;
            }
            if(sosuu) {
                ans++;
            }
        }
        System.out.println(ans);
        
        
    }
 }
 


Measured memory_bytes: 57672
function pint(s)   { return parseInt(s);   }
function pfloat(s) { return parseFloat(s); }
function even(s)   { return (s % 2) === 0; }
function odd(s)    { return (s % 2) === 1; }
Array.prototype.sortNumAsc  = function ()  { return this.sort((a, b) => (a - b)); }
Array.prototype.sortNumDesc = function ()  { return this.sort((a, b) => (b - a)); }
Array.prototype.sortStrAsc  = function ()  { return this.sort();                  }
Array.prototype.sortStrDesc = function ()  { return this.sort().reverse();        }
Array.prototype.without     = function (x) { return this.filter(e => e !== x);    }
function main(lines) {
  var arr = lines[0].split(' ').map(pint);
  var T = arr[0];
  var A = arr[1];
  var S = arr[2];
  var t = T;
  var a = A;
  var s = S;
  var times = 0;
  while (even(t) && even(a) && even(s)) {
    times++;
    var t2 = a / 2 + s / 2;
    var a2 = t / 2 + s / 2;
    var s2 = t / 2 + a / 2;
    t = t2; a = a2; s = s2;
    if (t === T && s === S && a === A) { console.log(-1); return; }
  }
  console.log(times);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n').map(l => l.trim()));

Measured memory_bytes: 21192
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	a,b,c,k = readline() |> split |> parseMap
  if a>=k
    println(k)
    elseif a+b>=k
		println(a)
	else
		println(a-(k-a-b))
	end
end

main()

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

int main(){
  int N,M;
  cin >> N >> M;
  vector <int> K(N);
  map <int,int> m;
  int a;
  int n=0;
  for(int i=0;i<N;i++){
    cin >> K.at(i);
    for(int j=0;j<K.at(i);j++){
      cin >> a;
      if(m.count(a)){
        m.at(a)++;
      }else{
        m[a]=1;
      }
    }
  }
  for(auto p : m){
    if(p.second==N){
      n++;
    }
  }
  cout << n << endl;
  return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int a,b,c,k;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	while(k--){
		if(b <= a) {
			b *= 2;
			continue;
		}
		if(c <= b){
			c *= 2;
			continue;
		}
	}
	if(a < b && b < c){printf("Yes\n");}
	else{printf("No\n");}
	
	return 0;
};

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

const int maxn = 110000;

set<int> b;
set<int>::iterator it;

struct Triple {
	int a, b, c;
	Triple(int a = 0, int b = 0, int c = 0) : a(a), b(b), c(c) {}
};

vector<Triple> res;
int n, k;

inline bool solve() {
	res.clear();
	int f = 1;
	for(int i = k; i < 2 * n + k; ++ i) b.insert(i);
	int v = 2 * n + k - 1;
	for(int j = k + 3 * n - 1; j >= k + 2 * n; -- j) {
		if(b.find(v) == b.end()) {
			for(int i = j; i >= k + 2 * n; -- i) res.emplace_back(i - 2 * n, i - n, i);
			break;
		} else {
			it = b.find(j - v);
			if(it == b.end()) {
				f = 0;
				break;
			}
			res.emplace_back(v, *it, j);
			b.erase(it); b.erase(v);
			if((k + 3 * n - 1 - j) & 1)  {
				v += n - 1;
			} else {
				v -= n;
			}
		}
	}
	return f;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> k;
	int ans = 0;
	if(k <= n) {
		if(solve()) ans = 1;
	}
	if(ans) for(auto tr : res) cout << tr.a << ' ' << tr.b << ' ' << tr.c << "\n";
	else cout << "-1\n";
	return 0;
}

Measured memory_bytes: 12740
import java.util.*;
import java.awt.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int q = sc.nextInt();
        int m = 100000;
        boolean[] isPrime = new boolean[m+1];
        boolean[] nextPrime = new boolean[m+1];
        for (int i = 1; i <= m; i++) {
            if (prime(i)) {
                isPrime[i] = true;

                int tmp = i * 2 - 1;
                if (tmp <= m && prime(tmp)) {
                    nextPrime[tmp] = true;
                }
            }
        }

        int[] sum_count = new int[m+1];
        for (int i = 1; i <= m; i++) {
            sum_count[i] = sum_count[i-1];

            if (isPrime[i] && nextPrime[i]) {
                sum_count[i] += 1;
            }
        }

        int[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < q; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        for (int i = 0; i < q; i++) {
            if (l[i] == 1) {
                System.out.println(sum_count[r[i]]);
            } else {
                System.out.println(sum_count[r[i]] - sum_count[l[i]-1]);
            }
        }
    }

    public static boolean prime(int x) {
        if (x == 1) return false;
        if (x == 2) return true;

        for (int i = 2; i <= (int)Math.sqrt(x) + 1; i++) {
            if (x % i == 0) return false;
        }
        return true;
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod


int n;
int a[2005];
int dp[2005][2005];


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) dp[i][i] = a[i];
    rep2(w, 1, n)rep(i, n) {
        int l = i, r = i + w;
        if (w % 2 == 1) {
            if (w == n - 1) {
                dp[l][r % n] = max(dp[l][(r - 1 + n) % n], dp[(l + 1) % n][r % n]);
            }
            else {
                if (a[(l - 1 + n) % n] < a[r % n]) {
                    dp[l][r % n] = dp[l][(r - 1 + n) % n];
                }
                if (a[(r + 1) % n] < a[l]) {
                    dp[l][r % n] = max(dp[l][r % n], dp[(l + 1) % n][r % n]);
                }
            }
        }
        else {
            dp[l][r % n] = max(dp[(l + 1) % n][r % n] + a[l], dp[l][(r - 1 + n) % n] + a[r % n]);
        }
    }
    ll ans = 0LL;
    rep(i, n) ans = max(ans, dp[i][(i + n - 1) % n]);
    cout << ans << endl;
}

Measured memory_bytes: 34532
class BIT:
    def __init__(self, n):
        self.node = [ 0 for _ in range(n+1) ]

    def add(self, idx, w):
        i = idx
        while i < len(self.node) - 1:
            self.node[i] += w
            i |= (i + 1)

    def sum_(self, idx):
        ret, i = 0, idx-1
        while i >= 0:
            ret += self.node[i]
            i = (i & (i + 1)) - 1
        return ret

    def sum(self, l, r):
        return self.sum_(r) - self.sum_(l)


n = int(input())
s = list(input())
q = int(input())

tree = [ BIT(n) for _ in range(26) ]
for i in range(n):
    tree_id = ord(s[i]) - ord("a")
    tree[tree_id].add(i, 1)

for _ in range(q):
    query = input().split()
    com = int(query[0])
    if com == 1:
        idx, new_char = int(query[1]), query[2]
        idx -= 1
        old_char = s[idx]
        new_id = ord(new_char) - ord("a")
        old_id = ord(old_char) - ord("a")

        tree[old_id].add(idx, -1)
        tree[new_id].add(idx, 1)
        s[idx] = new_char

    if com == 2:
        l, r = int(query[1]), int(query[2])
        ret = 0
        for c in range(26):
            if tree[c].sum(l-1, r) > 0:
                ret += 1
        print(ret)

Measured memory_bytes: 253108
a, b, c, x, y = [int(v) for v in input().split()]

if x < y:
    x, y = y, x
    a, b = b, a

ans = a * x + b * y
ans = min(ans, a * (x - y) + c * y * 2)
ans = min(ans, c * x * 2)
print(ans)

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

int main() {
    int h, n;
    cin >> h >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 0; i < n; i++) {
        h -= a[i];
        if (h <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3952
/*
 * ----------------------------------------------------------------------------
 *  (: Bismillahir Rahmanir Rahim :) 
 * File: /home/grim/Programming/Atcoder/Today/C_Sum_of_product_of_pairs.cpp
 * Project: /home/grim/Programming/Atcoder/Today
 * Created Date: Saturday, August 29th 2020, 6:17:26 pm
 * Author: Grim Firefly :)
 * Author Mail : GrimFirefly1@gmail.com
 * -----
 * Last Modified: Sat Aug 29 2020
 * Modified By: Grim Firefly :)
 * -----
 *   ________        .__           ___________.__                  _____ .__          
 *  /  _____/_______ |__|  _____   \_   _____/|__|_______   ____ _/ ____\|  |  ___.__.
 * /   \  ___\_  __ \|  | /     \   |    __)  |  |\_  __ \_/ __ \\   __\ |  | <   |  |
 * \    \_\  \|  | \/|  ||  Y Y  \  |     \   |  | |  | \/\  ___/ |  |   |  |__\___  |
 *  \______  /|__|   |__||__|_|  /  \___  /   |__| |__|    \___  >|__|   |____// ____|
 *         \/                  \/       \/                     \/              \/     
 * 
 *           |\_|\
 *           | a_a\
 *           | | "]
 *       ____| '-\___
 *      /.----.___.-'\
 *     //        _    \
 *    //   .-. (GF)  /|
 *   |'|  /\:  .--  / \
 *  // |-/  \_/____/\/~|
 * |/  \ |  []_|_|_] \ |
 * | \  | \ |___   _\ ]_}
 * | |  '-' /   '.'  |
 * | |     /    /|:  | 
 * | |     |   / |:  /\
 * | |     /  /  |  /  \
 * | |    |  /  /  |    \
 * \ |    |/\/  |/|/\    \
 *  \|\ |\|  |  | / /\/\__\
 *   \ \| | /   | |__
 *        / |   |____)
 *        |_/
 * ----------------------------------------------------------------------------
 */

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

//constant
#define PI acos(-1.0)
#define SZ 10000
#define mod 1000000007
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef unsigned un;
typedef pair<int, int> pii;
typedef vector<int> vi;

//Debug Setting up
#define watch(x) cout << (#x) << "=" << x << endl
#define watch2(x, y) cout << (#x) << "=" << x << " & " << (#y) << "=" << y << endl;
#define watchara(wow)     \
    for (auto x : wow)    \
    {                     \
        cout << x << " "; \
    }                     \
    cout << "\n"

//defining fast_io
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

//defining something
#define F first
#define S second

//Main Function Start From Here
void solve()
{
    ull sum = 0;
    int n;
    cin >> n;

    ll ara[n];
    ll dp[n] = {0};
    for (int i = 0; i < n; i++)
    {
        cin >> ara[i];
        if (i)
        {
            dp[i] += dp[i - 1] + ara[i];
            dp[i] %= mod;
            sum %= mod;
            sum += dp[i - 1] * ara[i] * 1ull;
            sum %= mod;
        }
        else
        {
            dp[i] = ara[i];
        }
    }
    cout << sum << endl;
}

int main()
{
    fast_io;

    solve();

    return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll w, b;
    cin >> w >> b;
    w--;
    b--;
    ll rows_for_w = w / 50;
    ll rem_w = w % 50;
    ll rows_for_b = b / 50;
    ll rem_b = b % 50;

    cout << 6 + rows_for_w*2  + rows_for_b*2 << " " << 100 << endl;
//    ここで1行
    for (auto &&i: boost::irange(0LL, 100LL)){
        cout << '#';
    }
    cout << endl;
//    ここでrows_for_w * 2行
    for (auto &&i: boost::irange(0LL, rows_for_w)){
        for (auto &&j: boost::irange(0LL, 100LL)){
            if (j%2 == 0){
                cout << '.';
            } else {
                cout << '#';
            }
        }
        cout << endl;
        for (auto &&j: boost::irange(0LL, 100LL)){
            cout << '#';
        }
        cout << endl;
    }
//    ここで1行
    for (auto &&i: boost::irange(0LL, rem_w)){
        cout << '.' << '#';
    }
    for (auto &&i: boost::irange(0LL, 100-rem_w*2)){
        cout << '#';
    }
    cout << endl;
//    ここで1行
    for (auto &&i: boost::irange(0LL, 100LL)){
        cout << '#';
    }
    cout << endl;
//    ここで1行
    for (auto &&i: boost::irange(0LL, 100LL)){
        cout << '.';
    }
    cout << endl;
//    ここでrow_for_b * 2行
    for (auto &&i: boost::irange(0LL, rows_for_b)){
        for (auto &&j: boost::irange(0LL, 100LL)){
            if (j%2==0){
                cout << '#';
            } else {
                cout << '.';
            }
        }
        cout << endl;
        for (auto &&j: boost::irange(0LL, 100LL)){
            cout << '.';
        }
        cout << endl;
    }
//    ここで1行
    for (auto &&i: boost::irange(0LL, rem_b)){
        cout << '#' << '.';
    }
    for (auto &&i: boost::irange(0LL, 100-rem_b*2)){
        cout << '.';
    }
    cout << endl;
//    ここで1行
    for (auto &&i: boost::irange(0LL, 100LL)){
        cout << '.';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<vector<ll> > v(n);
    ll ans=0;
    ll a,b;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    queue<pair<ll,set<ll> > > q;
    set<ll> s;
    s.insert(0);
    ll maki,f;
    q.push(make_pair(0,s));
    while(!q.empty()){
        f=q.front().first;
        s=q.front().second;
        q.pop();
        //cout << s.size()<<endl;
        if(s.size()==n){
            ans++;
        }
        else{
            maki=v[f].size();
            for(int i=0;i<maki;i++){
                if(s.find(v[f][i])==s.end()){
                    s.insert(v[f][i]);
                    q.push(make_pair(v[f][i],s));
                    s.erase(v[f][i]);
                }
            }
        }
    }
    cout << ans<<endl;
    return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<long int> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }

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

  long long sum=0;
  for(int i=0;i<N-K;i++){
    sum+=H.at(i);
  }

  cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#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())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);


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

  int n;
  cin >> n;
  vector<int> arr;

  rep (i, n) {
    int a;
    cin >> a;
    a = -a;
    if (arr.empty()) {
      arr.push_back(a);
      continue;
    }
    auto pos = upper_bound(arr.begin(), arr.end(), a); // a 以上の要素で最小

    if (pos == arr.end()) {
      arr.push_back(a);
    } else {
      *pos = a;
    }
  }
  cout << arr.size() << endl;
  return 0;
}


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

long days[] = {31, 29, 31, 30, 31, 30,
			   31, 31, 30, 31, 30, 31};

int main() {
	long n; cin >> n;
	map<long, long> mp;
	for (long i = 0; i < n; i++) {
		long a; cin >> a;
		mp[a]++;
	}
	long ans = mp.size();
	if (!(ans % 2)) ans--;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9372
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll a, b;
ll gcd(ll a, ll b){
    ll tmp;
    while(a%b!=0){
        tmp=b;
        b=a%b;
        a=tmp;
    }
    return b;
}
int main() {
    cin>>a>>b;

    if(a<b) swap(a, b);
    cout<<a*b/gcd(a, b)<<endl;
    return 0;
}

Measured memory_bytes: 256
//44
#include<iostream>
#include<algorithm>

using namespace std;

int gcd(int h,int l){
  if(h<l){
    swap(h,l);
  }
  while(h%l){
    h%=l;
    swap(h,l);
  }
  return l;
}

int main(){
  for(int a,b;cin>>a>>b;){
    cout<<gcd(a,b)<<' '<<a/gcd(a,b)*b<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
N = 10**6
n = int(input())

nine = [1, 9]
while True:
    t = nine[-1] * 9
    if t > N:
        break
    nine.append(t)

six = [1, 6]
while True:
    t = six[-1] * 6
    if t > N:
        break
    six.append(t)

dp = [N]*(n+1)
dp[0] = 0
for i in range(1, n+1):
    # dp[i] = min(dp[i], dp[i-1]+1)
    for j in nine:
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j]+1)
    for j in six:
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j]+1)

print(dp[n])

Measured memory_bytes: 74080
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

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

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

    int h = H[0]-1;
    bool ok = true;
    for (int i = 1; ok && i < N; ++i) {
        if (h < H[i]) {
            h = H[i] - 1;
        } else if (H[i] < h) {
            ok = false;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    ll x;
    cin >> x;
    
    ll a, b;
    for(a = 0;;++a){
        ll b5;
        b5 = - (x - (ll)pow((double)a, 5.0));

        if(b5 > -1){
            for(b = 0;(ll)pow((double)b, 5.0) < b5;++b);
        }else{
            for(b = 0;(ll)pow((double)b, 5.0) > b5;--b);
        }
        

        if((ll)pow((double)a, 5.0) - (ll)pow((double)b, 5.0) == x){
            break;
        }

        // cout << a << " " << b << " " << (ll)pow((double)a, 5.0) - (ll)pow((double)b, 5.0) << endl;
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 4116
from itertools import permutations
import sys
input = sys.stdin.readline


def main():

    input = sys.stdin.readline

    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))

    L = list(permutations(list(range(1, n + 1))))
    print(abs(L.index(p) - L.index(q)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 70316
n,m=map(int,input().split())
good = [0]*(m)
for i in range(n):
    ka=list(map(int,input().split()))
    for j in range(1,ka[0]+1):
        good[ka[j]-1] += 1
ans = 0
for i in range(m):
    if good[i] == n:
        ans += 1
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll N;
ll g[500010][2];
ll dp[500010][2];
ll lcnt[500010];

void predfs(ll v){
  if(v==N-1)return ;
  rep(i,2){
    predfs(g[v][i]);
    lcnt[v]+=lcnt[g[v][i]];
  }
}

void dfs(ll v,ll dep){
  if(v==N-1)return ;
  rep(i,2)dfs(g[v][i],dep+1);

  ll l=g[v][0],r=g[v][1];
  dp[v][0]=dp[l][0]+dp[r][0]+lcnt[v];
  minch(dp[v][1],dp[v][0]);
  minch(dp[v][1],dp[l][0]+lcnt[l]+dp[r][1]+1);
  minch(dp[v][1],dp[l][1]+1+dp[r][0]+lcnt[r]);
  minch(dp[v][1],dp[l][1]+1+dp[r][1]+1+dep);
}

int main(){
  cin>>N;
  memset(g,-1,sizeof(g));
  rep(i,N-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    g[i][0]=a;
    g[i][1]=b;
  }
  rep(i,N)rep(j,2)dp[i][j]=INF;
  lcnt[N-1]=1;
  predfs(0);
  dp[N-1][0]=dp[N-1][1]=0;
  dfs(0,0);
  cout<<dp[0][1]<<endl;
  return 0;
}



Measured memory_bytes: 45988
#include <stdio.h>

char map[104][104];
int a, b;

int main(void){
int i,j,x,y;
while(scanf("%d %d",&a,&b),a+b){
for(i=0;a-i;i++) scanf("%s",map[i]);
x=y=0;
while(map[x][y]-46&&map[x][y]-32){
i=x;j=y;
if(map[x][y]==94) x--;
if(map[x][y]/95) x++;
if(map[x][y]==60) y--;
if(map[x][y]==62) y++;
map[i][j]=32;
}
if(map[x][y]==32) puts("LOOP");
else printf("%d %d\n",y,x);
}
return 0;
}

Measured memory_bytes: 624
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::pair<int, int>> p(m);
  for (int i = 0; i < m; ++i)
    std::cin >> p.at(i).first >> p.at(i).second;

  for (int i = 0; i < 1000; ++i) {
    int xi = i;
    std::vector<int> x;

    do {
      x.push_back(xi % 10);
      xi /= 10;
    } while (xi > 0);
    if ((int)x.size() != n)
      continue;
    std::reverse(x.begin(), x.end());

    bool ok = true;
    for (auto &pi : p)
      if (x.at(pi.first - 1) != pi.second)
        ok = false;

    if (!ok)
      continue;

    std::cout << i << std::endl;
    return 0;
  }
  std::cout << -1 << std::endl;
}


Measured memory_bytes: 256