akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll dp[109][10];

void add(ll &x,ll y){
    x=(x+y)%MOD;
}

bool is(int bit,int i){
    return (bit&(1<<i));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W,K;
    cin>>H>>W>>K;
    
    dp[0][0]=1;
    rep(i,H)rep(bit,pow(2,W-1)){
        bool f=false;
        rep(k,W-2)if(is(bit,k)&&is(bit,k+1)) f=true;
        if(f) continue;
        
        rep(j,W){
            if(j<W-1&&is(bit,j)){
                add(dp[i+1][j+1],dp[i][j]);
            }else if(j>0&&is(bit,j-1)){
                add(dp[i+1][j-1],dp[i][j]);
            }else{
                add(dp[i+1][j],dp[i][j]);
            }
        }
    }
    cout1(dp[H][K-1])
}

Measured memory_bytes: 512
#!/usr/bin/env python
# coding: utf-8


def main():
    s = input()
    t = input()
    s2 = "".join(sorted(s))
    t2 = "".join(sorted(t, reverse=True))
    if s2 < t2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.PriorityQueue;



public class Main {

	public static void main(String[] args) throws IOException {
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>(3, Collections.reverseOrder());
	    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    String s;
	    while ((s = in.readLine()) != null && s.length() != 0) {
	    	pq.add(Integer.parseInt(s));
//	    	System.out.println(s);
	    // An empty line or Ctrl-Z terminates the program	    
	    }
	    for (int i = 0; i < 3; i++) {
			System.out.println(pq.poll());
		}
	    
	}
	
	
	
	

}

Measured memory_bytes: 17012
#include<cstdio>
#include<algorithm>
int par[100001];
int rank[100001];
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rank[i]=0;
	}
}
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	
	if(rank[x]<rank[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rank[x]==rank[y])rank[x]++;
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	init(n);
	int p[n]={};
	int x[m]={};
	int y[m]={};
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
		p[i]--;
	}
	for(int i=0;i<m;i++){
		scanf("%d%d",&x[i],&y[i]);
		x[i]--;
		y[i]--;
		unite(x[i],y[i]);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(same(i,p[i]))ans++;
	}
	printf("%d\n",ans);
	return 0;
}
		

Measured memory_bytes: 2176
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  int n = N;
  int fx = 0;
  while (n > 0) {
    fx += (n % 10);
    n /= 10;
  }

  if (N % fx == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c,d;
    while(~scanf("%d",&a))
    {
        scanf("%d",&b);
        scanf("%d",&c);
        scanf("%d",&d);
        if(a>b)
            printf("%d\n",b*c+(a-b)*d);
        else
            printf("%d\n",a*c);
        }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int r, d, x;
  cin >> r >> d >> x;
  rep3(i, 1, 11) {
    x = r * x - d;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#define mod 1000000007
using namespace std;
typedef long long ll;

ll mod_pow(ll x,ll y){
  ll res=1;
  for(int i=0;i<35;i++){
    if(y&(1LL<<i)) res=res*x%mod;
    x=x*x%mod;
  }
  return res;
}

int main(){
  ll m,n;
  cin>>m>>n;
  cout << mod_pow(m,n)<<endl;
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		// 入力
        var a = int.Parse(Console.ReadLine());
		var b = int.Parse(Console.ReadLine());

		        //値の判定
        switch (a + b)
        {   
            case 3:
                Console.WriteLine(3);   
                break;
            case 4:
                Console.WriteLine(2); 
                break;
            case 5:
                Console.WriteLine(1); 
                break;
        }
	}
}

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int a, b;
    cin >> a >> b;
    if(a <= 0 && b >= 0){
        cout << "Zero";
        return 0;
    }
    if(a > 0){
        cout << "Positive";
    }
    else if((b-a)%2) cout << "Positive";
    else cout << "Negative";
    return 0;
}


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

vector<int> G[1048576];

int main(){
	int N; cin >> N;
	int A[N];
	rep(i, N) cin >> A[i];
	int rui[N];
	rui[0] = A[0];
	rep(i, N-1){
		rui[i+1] = rui[i] ^ A[i+1];
	}
	int sum[N];
	rep(i, N){
		G[rui[i]].push_back(i);
		if(i == 0){
			if(rui[i] == 0) sum[i] = 1;
			else sum[i] = 0;
		}else{
			if(rui[i] == 0) sum[i] = sum[i-1] + 1;
			else sum[i] = sum[i-1];
		}
	}
	ll ans = 0, s = 1;
	if(rui[N-1] == 0){
		rep(i, sum[N-1] - 1) s = (s * 2) % mod;
		ans = s;
		for(int i=1; i<1048576; i++){
			if(!G[i].size()) continue;
			int p = G[i].size();
			ll dp[p], su = 0;
			dp[p-1] = 1, su = dp[p-1];
			for(int j=p-2; j>=0; j--){
				int nn = sum[G[i][j+1]] - sum[G[i][j]];
				dp[j] = (su * nn % mod + dp[j+1]) % mod;
				su = (su + dp[j]) % mod;
			}
			ans = (ans + su) % mod;
		}
	}else{
		int x = rui[N-1];
		ll dp[G[x].size()], su = 0;
		dp[G[x].size() - 1] = 1, su = 1;
		for(int i=G[x].size() - 2; i>=0; i--){
			if(i == G[x].size() - 2){
				int nn = sum[G[x][i+1]] - sum[G[x][i]];
				dp[i] = nn;
              	su = (su + nn) % mod;
				continue;
			}
			int nn = sum[G[x][i+1]] - sum[G[x][i]];
			dp[i] = (su * nn % mod + dp[i+1]) % mod;
			su = (su + dp[i]) % mod;
		}
		ans = (ans + su) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 40308
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int n, m, k;
    cin >> n >> m >> k;
    REP(i, n + 1) REP(j, m + 1) {
        if (m * i + n * j - i * j * 2 == k) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;cin>>n;
	int a[n];
	map<int,int> mp;
	rep(i,n) {
		cin>>a[i];
		rep(j,3) mp[a[i]+j]++;
	}

	int ans=0;
	for(auto i:mp){
		ans=max(i.second,ans);
	}

	cout<<ans<<"\n";
}

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

int main(void)
{
  int ar[3];
  for(int i=0;i<3;i++)
  {
    cin>>ar[i];
  }
  int c=0;
   for(int i=0;i<3;i++)
  {
    c+=ar[i];
  }
  if(c>=22)
    cout<<"bust";
  else
    cout<<"win";
  return 0;
  
}

Measured memory_bytes: 256
l = [int(input()) for i in range(5)]
k = int(input())
c = 0
for i in range(5):
    for j in range(5):
        if abs(l[i] - l[j]) > k:
            c += 1
    
if c == 0:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void NGE(ll arr[], ll n,ll *arr1)
{
    stack<ll> s;

//	int arr1[n];


    // iterating from n-1 to 0
    for (ll i = 0; i < n; i++)
    {
        ll yav=0;


        /*We will pop till we get the
        greater element on top or stack gets empty*/
        while (!s.empty() && s.top() >= arr[i]) {
            s.pop();


        }

        /*if stack gots empty means there
        is no element on right which is greater
        than the current element.
        if not empty then the next greater
        element is on top of stack*/
        if (s.empty()) {
            arr1[i] = -1;

        }
        else {
            arr1[i] = s.top();
        }
        s.push(arr[i]);
    }
}
ll min(vector<ll> &v){
    ll tmp=1232245,idx;
    for(int i=0;i<v.size();i++){
        if(v[i]<tmp){
            tmp=v[i];
            idx=i;
        }
    }
    v[idx]=98767543223456777;
    return idx;
}
int main(){

   // ios_base::sync_with_stdio(false);
  ll a[5];
  for(int i=0;i<5;i++)
      cin>>a[i];
 vector<ll> b;
 for(int i=0;i<5;i++){
     if(a[i]%10==0)
         b.push_back(0);
     else
     b.push_back(10-(a[i]%10));
 }

 ll sum=0;
 for(int i=0;i<5;i++){
    ll k=min(b);
    sum+=a[k];
    if(i!=4){
        if(sum%10!=0){
    sum=sum+(10-(sum)%10);}
    }

 }
 //sum=sum-(10-(sum)%10);
 cout<<sum<<endl;



}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    ll n,m;cin>>n>>m;
    vector<ll> k[40];
    int maxketa=0;
    rep(i,n){
        ll a,b;cin>>a;
        b=a;
        int keta=0;
        while(a>0){
            a/=2;
            keta++;
        }
        k[keta].push_back(b);
        maxketa=max(keta,maxketa);
    }
    int cnt=0;
    while(cnt+k[maxketa].size()<m && maxketa>0){
        cnt+=k[maxketa].size();
        maxketa--;
        for(auto tmp : k[maxketa+1])k[maxketa].push_back(tmp/2);
    }
    sort(k[maxketa].begin(),k[maxketa].end(),greater<ll>());
    ll cost=0;
  if(maxketa==0){
    cout << 0 << endl;
    return 0;
  }
    rep(i,m-cnt)k[maxketa][i]/=2;
    rep(i,maxketa+1){
        for(auto tmp : k[i])cost+=tmp;
    }
    cout << cost <<endl;
}

Measured memory_bytes: 2364
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int l;
    cin >> l;
    long double a = l / 3.0;
    cout << a * a * a << endl;
}

Measured memory_bytes: 256
import numpy as np

n, m = map(int, input().split())
res = np.ones(m, dtype=np.int8)
for _ in range(n):
    a_like = np.zeros_like(res)
    for a in map(lambda x: int(x)-1, input()[2:].split()):
        a_like[a] = 1
    res *= a_like
print(np.count_nonzero(res))


Measured memory_bytes: 27156
#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  string op[2] = {"ARC", "ABC"};
  cin >> s;
  if(s == op[0])cout << op[1] << endl;
  else cout << op[0] << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc = 1;
  // cin >> tc;
  for(int i = 1; i <= tc; ++i) {
    // cout << "Case #" << i <<": ";
    solve();
  }
  return 0;
}

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

int main(){
  int64_t n;
  int64_t m;
  priority_queue<double> que;
  int64_t sum = 0;
  
  cin >> n >> m;
  vector<int64_t> a(n);
  for(int i=0;i<n;i++){
    int64_t p;
    cin >> p;
    que.push(p);
  }
  for(int i=0;i<m;i++){
    int64_t p;
    p = que.top();
    que.pop();
    p = p / 2;
    que.push(p);
  }
  for(int i=0;i<n;i++){
    sum += (int64_t)que.top();
    que.pop();
  }
  cout << sum << endl;
}
          
        
  
      
    
    
    
  
  
  

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

using namespace std;

static const long MOD = 1000000007;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		int Ai;
		cin >> Ai;
		A[Ai]++;
		if (A[Ai] >= 3) {
			printf("0\n");
			return 0;
		}
	}

	int one = 0, two = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] == 1) one++;
		else if (A[i] == 2) two++;
	}

	if (N % 2 == 0 && one != 0) {
		printf("0\n");
		return 0;
	}
	if (N % 2 == 1 && (one != 1 || A[0] != 1)) {
		printf("0\n");
		return 0;
	}

	long ans = 1;
	while (two > 0) { ans = (ans * 2) % MOD; two--; }

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    rep(i, m) {
        cin >> l[i];
        cin >> r[i];
    }

    int ml = 0, mr = inf;
    rep(i, m) {
        ml = max(ml, l[i]);
        mr = min(mr, r[i]);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (ml <= i && mr >= i) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

char*dir = "HD";
int main() {
	char a, b; cin >> a >> b;
	a = find(dir, dir + 2, a) - dir;
	if (b == 'D')a = !a;
	cout << dir[a] << endl;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long INF = 1L<<59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto LRA = M.iota.map!(_ => readln.split.map!(to!int).array).array;
    LRA.sort();

    auto st = new LazySegmentTree!(long, long, max, (a,b)=>a+b, (a,b)=>a+b, (a,b)=>a, -INF, 0L)(N+2);
    st.table[] = 0L;
    auto pq = new BinaryHeap!(Array!(Tuple!(int, int, long)), "a[1] > b[1]")();

    for (int i = 1, p = 0; i <= N+1; ++i) {
        while (p < M && i >= LRA[p][0]) {
            pq.insert(tuple(LRA[p][0], LRA[p][1], LRA[p][2].to!long));
            st.update(0, LRA[p][0]-1, LRA[p][2].to!long);
            ++p;
        }
        while (!pq.empty && pq.front[1] < i) {
            st.update(0, pq.front[0]-1, -pq.front[2].to!long);
            pq.removeFront;
        }

        auto v = st.query(0, i-1);
        st.update(i, i, v);
    }

    st.query(N+1, N+1).writeln;
}



class LazySegmentTree(T, L, alias opTT, alias opTL, alias opLL, alias opPrd, T eT, L eL) {
    T[] table;
    L[] lazy_;
    int n;
    int size;

    this(int n) {
        this.n = n;
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        lazy_ = new T[](size);
        table[] = eT;
        lazy_[] = eL;
    }

    void push(int i, int a, int b) {
        if (lazy_[i] == eL) return;
        table[i] = opTL(table[i], opPrd(lazy_[i], b - a + 1));
        if (i * 2 + 1 < size) {
            lazy_[i*2] = opLL(lazy_[i*2], lazy_[i]);
            lazy_[i*2+1] = opLL(lazy_[i*2+1], lazy_[i]);
        }
        lazy_[i] = eL;
    }

    T query(int l, int r) {
        if (l > r) return eT;
        return query(l, r, 1, 0, n-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) return eT;
        push(i, a, b);
        if (l <= a && b <= r) {
            return table[i];
        } else {
            return opTT(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }

    void update(int l, int r, L val) {
        if (l > r) return;
        update(l, r, 1, 0, n-1, val);
    }

    void update(int l, int r, int i, int a, int b, L val) {
        if (b < l || r < a) {
            push(i, a, b);
        } else if (l <= a && b <= r) {
            lazy_[i] = opLL(lazy_[i], val);
            push(i, a, b);
        } else {
            push(i, a, b);
            update(l, r, i*2, a, (a+b)/2, val);
            update(l, r, i*2+1, (a+b)/2+1, b, val);
            table[i] = opTT(table[i*2], table[i*2+1]);
        }
    }
}


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

class dice {
public:
    int getTopFace(void);
    int getBottomFace(void);
    void rotate(char dir);
    void setFaceNumber(int *number);
    bool compareDice(dice d2);
private:
    int face[6];
    int getFaceIndex(int number);
    bool compareDiceFace(dice d2);
};

int dice::getTopFace(void) {
    return face[0];
}

int dice::getBottomFace(void) {
    return face[5];
}

int dice::getFaceIndex(int number) {
    int i;
    for(i=0; i<6; ++i) {
        if (face[i]==number) {
            return i;
        }
    }
    return -1;
}

void dice::rotate(char dir) {
    int temp;
    switch(dir) {
    case 'N' :
        temp=face[0];
        face[0]=face[1];
        face[1]=face[5];
        face[5]=face[4];
        face[4]=temp;
        break;
    case 'S' :
        temp=face[0];
        face[0]=face[4];
        face[4]=face[5];
        face[5]=face[1];
        face[1]=temp;
        break;
    case 'W' :
        temp=face[0];
        face[0]=face[2];
        face[2]=face[5];
        face[5]=face[3];
        face[3]=temp;
        break;
    case 'E' :
        temp=face[0];
        face[0]=face[3];
        face[3]=face[5];
        face[5]=face[2];
        face[2]=temp;
        break;
    }
}

void dice::setFaceNumber(int *number) {
    for(int i=0; i<6; ++i) {
        face[i]=*(number+i);
    }
}

bool dice::compareDiceFace(dice d2) {
    for(int i=0;i<6;++i) {
        if(d2.face[i]!=face[i]) {
            return false;
        }
    }
    return true;
}

bool dice::compareDice(dice d2) {
    for(int j=0;j<3;++j) {
        if(compareDiceFace(d2)) return true;
        for(int i=0;i<3;++i) {
            d2.rotate('E');
            if(compareDiceFace(d2)) return true;
        }
        d2.rotate('E');
        d2.rotate('N');
        d2.rotate('N');
        if(compareDiceFace(d2)) return true;
        for(int i=0;i<3;++i) {
            d2.rotate('E');
            if(compareDiceFace(d2)) return true;
        }
        d2.rotate('N');
    }
    return false;
}

int main() {
    int n,num[6];
    vector<dice> d;
    bool ans=true;

    cin >> n;
    d.resize(n);

    for(int i=0; i<n; ++i) {
    	for(int j=0; j<6; ++j) {
    		cin >> num[j];
    	}
    	d[i].setFaceNumber(num);
    }

    for(int i=0; i<n-1; ++i) {
    	for(int j=i+1; j<n; ++j) {
    		ans = (ans && !(d[i].compareDice(d[j])));
    	}
    }
    cout << (ans?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
int main()
{
	lint n=0;
	lint sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0) continue;
		sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int a,b;
	cin>>a>>b;
	
	double ans=0;
	while(ans<(int)1e5){
		double tmp=ans*0.08;
		double tmpp=ans*0.1;
		if(a==floor(tmp) and b==floor(tmpp)){
			cout<<ans<<endl;
			return 0;
		}
		
		ans++;
	}
	
	cout<<-1<<endl;
}

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

using namespace std;

int main() {
	int N;
	
	cin >> N;
	
	int d[N];
	
	for(int i = 0; i < N; i++) {
		cin >> d[i];
	}
	
	int sum = 0;
	for(int i = 0; i < N; i++) {
		for(int j = i+1; j < N; j++) {
			sum = sum + (d[i] * d[j]);
		}
	}
	
	cout << sum << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int S,h,m,s;
	scanf("%d",&S);
	h = S / 60 / 60;
	m = (S - h * 60 * 60) / 60;
	s = S - h * 60 * 60 - m * 60 ;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1816
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String[] input = sc.next().split("");
		Map<String, Boolean> map = new HashMap<>();
		for (String element : input) {
			if (map.get(element) != null) {
				System.out.println("no");
				System.exit(0);
			}
			map.put(element, true);
		}
		System.out.println("yes");
	}
}


Measured memory_bytes: 35588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
	/* topを加算してから
	   その位置へ挿入 */
	S[++top] = x;
}

int pop() {
	top--;
	/* topが指していた要素を返す*/
	return S[top + 1];
}

int main(int argc, char *argv[])
{
	int a, b;
	top = 0;
	char s[100];
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a*b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());

	return 0;
}



Measured memory_bytes: 2772
"use strict";
// import bigInt from 'big-integer'

const Main = input => {
  input = input.trim().split("\n");
  const nums = input[1].split(" ");
  var count = 0;
  var canDivide = true;
  while (canDivide) {
    for (let i = 0; i < nums.length; i++) {
      if (nums[i] % 2 === 1) {
        canDivide = false;
        break;
      }
      nums[i] /= 2;
    }
    canDivide && count++;
  }

  console.log(count);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn read_str_as_char_vec() -> Vec<char> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn read_str_as_T<T>() -> T
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().unwrap()
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let a = in_vec[0];
    let b = in_vec[1];

    println!("{}", a * b);
}


Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M, X;
  cin>>N>>M>>X;
  vector<int> bomb(M, 0);
  for(int i=0; i<M; i++){
    cin>>bomb.at(i);
  }
  int cost=0;
  for(int i=0; i<M; i++){
    if(bomb.at(i)<X){
      cost++;
    }
    else{
      break;
    }
  }
  if(cost<=M-cost){
    cout<<cost<<endl;
  }
  else{
    cout<<M-cost<<endl;
  }
}

Measured memory_bytes: 3580
n = int(input())
A = [int(x) for x in input().split()]
B = [0] * n

for i in reversed(range(n)):
    if i + 1 > n // 2:
        B[i] = A[i]
        # iの倍数が書かれた箱に入っているボールの個数はOK
    else:
        # iの倍数が書かれた箱に入っているボールの個数
        c = n // (i+1)
        s = 0
        for j in range(c):
            s += B[(i+1)*(j+1)-1]
        if s % 2 == A[i]:
            continue
        else:
            B[i] = 1

ans = sum(B)
print(ans)
count = 0
for i in range(len(B)):
    if B[i] == 1:
        count += 1
        if count == ans:
            print(i + 1)
        else:
            print(i + 1, end=' ')

# 欲しい出力を如何に高速に得るかも重要

Measured memory_bytes: 7276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    bool han=0;
    string s,p,ss;
    std::cin >> s;
    std::cin >> p;
    ss=s+s;
    rep(i,s.size()){
        bool dum=1;
        rep(j,p.size()){
            if(ss[i+j]!=p[j])dum=0;
        }
        if(dum)han++;
    }
    if(han)std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int ans_num[6] = { 9, 0, 900, 0, 90000, 0 };

	int n;
	cin >> n;

	int digit = 0;
	int log = 1;
	while(n / log > 0)
	{
		digit++;
		log *= 10;
	}
	log /= 10;

	int ans = 0;
	for(int i = 0; i < digit - 1; ++i)
	{
		ans += ans_num[i];
	}
	if (digit & 1)
	{
		ans += n - log + 1;
	}

//	cout << log << " " << digit << endl;
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>

int main(){

    int A, B;

    int fare;

    scanf("%d", &A);
    scanf("%d", &B);

    if(A>12){
        fare = B;
    }else if(6 <= A && A <= 12){
        fare = B / 2;
    }else{
        fare = 0;
    }

    printf("%d", fare);

    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << (a*b)/2  << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
int n,pm,pe,pj;
    while (true){
        std::cin >> n;
        if (n == 0){
            break;
}       for (int i = 0;i < n;i++){
            std::cin >> pm >> pe >> pj;
            if (pm == 100 || pe == 100 || pj == 100 || pm + pe >= 180 || pm + pe + pj >= 240){
                std::cout << "A" << std::endl;
}           else if (pm + pe + pj >= 210 || (pm + pe + pj >= 150 && (pm - 80) * (pe - 80) <= 0 )){
                std::cout << "B" << std::endl;
}           else{
                std::cout << "C" << std::endl;
}
}
}
    return 0;
}

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

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (int i = 1; i <= 9; ++i) {
			for (int j = 1; j <= 9; ++j) {
				if (N == i * j) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

void dfs(int v, vvp &g, vint &c)
{
    for (P p : g[v])
    {
        if (c[p.first] != -1)
            continue;
        int newc = !c[v];
        if (p.second % 2)
        {
            c[p.first] = newc;
        }
        else
        {
            c[p.first] = c[v];
        }
        dfs(p.first, g, c);
    }
}

int main()
{
    int n;
    cin >> n;
    vvp g(n);
    vint c(n, -1);
    rep(i, n - 1)
    {
        int f, t, w;
        cin >> f >> t >> w;
        g[f - 1].emplace_back(P(t - 1, w));
        g[t - 1].emplace_back(P(f - 1, w));
    }
    c[0] = 1;
    dfs(0, g, c);

    rep(i, n)
    {
        cout << c[i] << (i == n - 1 ? "" : "\n");
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 10728
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    ll n, count[5] = {}, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        if (t[0] == 'M')count[0]++;
        else if (t[0] == 'A')count[1]++;
        else if (t[0] == 'R')count[2]++;
        else if (t[0] == 'C')count[3]++;
        else if (t[0] == 'H')count[4]++;
    }
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += count[i] * count[j] * count[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

int main()
{
    int tot=0,n=read();
    LL d=read();
    while(n--)
    {
        LL x=read(),y=read();
        if(x*x+y*y<=d*d) tot++;
    }
    cout<<tot;

    return 0;
}


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

typedef long long ll;

int main()
{
    ll i,j,l;
    ll n,k;
    cin >> n >> k;
    deque<ll> v;
    for(i = 0;i < n;++i){
        ll a;
        cin >> a;
        v.push_back(a);
    }
    ll r = min(n,k);
    ll max = 0;
    for(i = 1;i <= r;++i){
        for(j = 0;j <= i;++j){
            deque<ll> b = v;
            vector<ll> tmp;
            for(l = 0;l < j;++l){
                ll a = b.front();
                b.pop_front();
                tmp.push_back(a);
            }
            for(l = 0;l < i-j;++l){
                ll a = b.back();
                b.pop_back();
                tmp.push_back(a);
            }
            ll t = min(k-i, (ll)tmp.size());
            sort(tmp.begin(), tmp.end());
            for(l = 0;l < t;++l){
                if(tmp.at(l) < 0){
                    tmp.at(l) = 0;
                }else{
                    break;
                }
            }
            ll sum = 0;
            for(l = 0;l < tmp.size();++l){
                sum += tmp.at(l);
            }
            if(sum > max){
                max = sum;
            }
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())
mx_A=F//(100*A)
mx_B=F//(100*B)
mx_C=F//C
mx_D=F//D
Conc=-1
Vol=0
Sal=0
for i in range(mx_A+1):
    for j in range(mx_B+1):
        if 0<100*(A*i+B*j)<=F:
            for k in range(mx_C+1):
                for l in range(mx_D+1):
                    m_Sal=C*k+D*l
                    m_Wat=100*(A*i+B*j)
                    if (m_Sal+m_Wat)<=F and m_Sal<=(E*m_Wat//100):
                        if (m_Sal/(m_Sal+m_Wat))>Conc:
                            Conc=(m_Sal/(m_Sal+m_Wat))
                            Sal=m_Sal
                            Vol=m_Sal+m_Wat
print(Vol,Sal)

Measured memory_bytes: 42860
import sys
sys.setrecursionlimit(10**9)
N = int(input())
edge = [[] for _ in range(N)]

for _ in range(N-1):
    u,v,w = map(int, input().split())
    w %= 2
    u, v = u-1, v-1
    edge[u].append((v,w))
    edge[v].append((u,w))

ret = [0] * N
def dfs(pv, v, dist):
    ret[v] = dist
    for nv, w in edge[v]:
        if nv == pv:
            continue
        dfs(v, nv, (dist+w)%2)

dfs(-1,0,0)
print(*ret, sep="\n")


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

int main(){
    string ans = "No";
    
    int x, y;
    cin >> x >> y;
    
    int crane = x, turtle = 0;
    for (int i = 0; i <= x; i++) {
        crane = x - i; turtle = i;
        int buf = crane * 2 + turtle * 4;
        if (buf == y) {
            ans = "Yes";
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3624
/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

const int N = 1e6 + 5;
int divs[N + 5];

void solve() {
    int n;
    cin >> n;
    ll ans = 0;

    for(int i = 1; i <= N; i++) {
        for(int j = i; j <= N; j += i) {
            divs[j]++;
        }
    }
    for(int i = 1; i < n; i++) {
        int num = n - i;
        //int sn = sqrt(num);
        //cout << divs[num] << '\n';
        ans += (divs[num]);
        //if(sn * sn == num) ans--;
    }
    cout << ans;
    return;
}

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


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

using namespace std;

long long luca(int p){
    if(p==0){ return 2;}
    else if(p==1){ return 1;}
    //return luca(p-1)+luca(p-2);
    vector<long long> calc;
    calc.push_back(2); calc.push_back(1);
    for(int i=2;i<p;i++){
        calc.push_back( calc[i-1] + calc[i-2] );
    }
    return calc[p-1] + calc[p-2];
}

int main(void){
    int n;
    cin >> n;
    cout << luca(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> v(n,1);
  vector<bool> w(n,false);
  w[0]=true;

  rep(i,m){
    int x,y;
    cin>>x>>y;
    x--;
    y--;
    v[x]--;
    v[y]++;
    if(w[x])
      w[y]=true;
    if(v[x]==0&&w[x])
      w[x]=false;
  }

  cout<<count(all(w),true)<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    cout<<((e-a<=k)? "Yay!": ":(")<<endl;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b){ if (a > b) { a = b; } }

ll a[100000];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1, of = 1e18;
    for (int i = 0; i < n; ++i) {
        if (of / ans < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4412
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    cin>>ar[i];
    sort(ar, ar+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(ar[i]==ar[j]||ar[j]==ar[k])
                continue;
                if((ar[i]+ar[j])<=ar[k])
                continue;
                ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3692
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>
#include<functional>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define EPS 1e-9
#define PI 3.14159265359
const ll mod = 1000000007;
const ll OO = (ll)1e9;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(ll base, ll power){
	if (power == 0)
		return 1;
	if (power == 1)
		return (base % mod);
	if (power % 2 == 0)
		return (fast_power(((base*base) % mod), power / 2LL) % mod);
	else return ((base*fast_power(((base*base) % mod) % mod, power / 2LL)) % mod);
}
//#pragma warning (disable : 4996)
void Qalbaz()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(2);
}

int main(){

	Qalbaz();

	int a, b;
	cin >> a >> b;
	if (a + b == 15)
		cout << '+';
	else if (a * b == 15)
		cout << '*';
	else
		cout << 'x';

	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  vector<char> C(S.size());
  for (int i = 0; i < S.size(); i++) {
    C.at(i) = S.at(i);
  }
  
  cout << C.at(0) << C.at(1) << C.at(2) << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define upmin(a,b) (a)=min((a),(b))
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

const int MAXN = 200055;
const int MX = 262144;

struct SEG {
	SEG() { init(); }
	ll d[MX*2];

	void init() { fill(d, d+MX*2, INFLL); }
	void upd(int x, ll r) {
		x += MX; d[x] = r;
		for(x >>= 1; x; x >>= 1)
			d[x] = min(d[x<<1], d[x<<1|1]);
	}
	ll get(int s, int e) {
		ll r = INFLL; for(s += MX, e += MX; s <= e; s >>= 1, e >>= 1) {
			if(s&1) upmin(r, d[s++]);
			if(~e&1) upmin(r, d[e--]);
		}
		return r;
	}
} segL, segR;

int A[MAXN];

ll Delta, Ans = INFLL;
int N, Q;

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

	cin >> N >> Q >> A[0] >> A[1]; Q++;
	for(int i = 2; i <= Q; i++) cin >> A[i];

	segL.upd(A[0], -A[0]);
	segR.upd(A[0], A[0]);

	for(int i = 2; i <= Q; i++) {
		ll ret = min(segL.get(0, A[i]) + A[i], segR.get(A[i], N+1) - A[i]) + Delta;
		ll dt = abs(A[i] - A[i-1]);
		Delta += dt; ret -= Delta;
		segL.upd(A[i-1], ret - A[i-1]);
		segR.upd(A[i-1], ret + A[i-1]);
	}

	for(int i = 0; i <= N+1; i++)
		upmin(Ans, min(segL.get(i, i) + i, segR.get(i, i) - i));
	cout << Ans + Delta << endl;
	return 0;
}

Measured memory_bytes: 9216