akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using lint = long long;


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, q;
    cin >> n >> q;
    const int S = 1<<18;
	const int h = __builtin_clz(1)-__builtin_clz(S);
	vector<int> seg(2*S), lazy(2*S);
	auto apply = [&](int v, int delta, int len) {
		seg[v] += delta * len;
		if (v < S) lazy[v] += delta;
	};
	auto push = [&](int v) {
		for (int s = h, len = 1<<(h-1); s > 0; --s, len /= 2) {
			int i = v >> s;
			if (lazy[i]) {
				apply(2*i, lazy[i], len);
				apply(2*i+1, lazy[i], len);
				lazy[i] = 0;
			}
		}
	};
	auto update_all = [&](int v) {
		for(int len = 2; v /= 2; len *= 2) {
			seg[v] = seg[2*v] + seg[2*v+1];
			seg[v] += lazy[v] * len;
		}
	};
	auto update = [&](int l, int r, int delta) {
		push(l + S), push(r + S - 1);
		for (int a = l+S, b = r+S, len = 1; a < b; a /= 2, b /= 2, len *= 2) {
			if (a & 1) apply(a++, delta, len);
			if (b & 1) apply(--b, delta, len);
		}
		update_all(l + S), update_all(r + S - 1);
	};

	auto query = [&](int p) {
		push(p + S);
		int res = 0;
		while(p /= 2) res += seg[p];
		return res;
	};
    // for (int i = S; i; --i) seg[i] = (seg[2*i] + seg[2*i+1]);
    while(q--) {
    	int op, l, r;
    	cin >> op;
    	if (op) {
    		cin >> l;
    		--l;
    		push(l + S);
    		cout << seg[l+S] << '\n';
    	}
    	else {
    		int v;
    		cin >> l >> r >> v;
    		--l, --r;
    		update(l, r+1, v);
    	}
    	// for (int i = 0; i < n; ++i) {
	    // 	cout << query(i, i+1) << ' ';
	    // }
	    // cout << endl;
    }
    
}


Measured memory_bytes: 7060
use std::io;

fn main() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n: u32 = n.trim().parse().unwrap();

    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();

    let vec: Vec<_> = s.trim().chars().collect();
    let mut max = 0;

    for i in 1..n {
        let mut cnt = 0;
        let mut exist = Vec::with_capacity(32);
        for j in 0..i {
            if exist.contains(&vec[j as usize]) {
                continue;
            }
            for k in i..n {
                if vec[j as usize] == vec[k as usize] {
                    cnt += 1;
                    exist.push(vec[j as usize]);
                    break;
                }
            }
        }

        if cnt > max {
            max = cnt;
        }
    }
    println!("{}", max);
}

Measured memory_bytes: 4352
#include <iostream>

int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (a + b < c + d)
        printf("Right\n");
    else if (a + b > c + d)
        printf("Left\n");
    else
        printf("Balanced\n");
    return 0;
}


Measured memory_bytes: 256
//解説動画見ながら書きました　これ通った方マジ化け物

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(void){
    // Your code here!
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    vector<mint> two(n+1);
    two[0]=1;
    rep(i,n) two[i+1]=two[i]*2;
    mint ans=0;
    rep(i,n){
        int l=i,r=n-1-i;
        mint now=two[r];
        if(r!=0)now+=two[r-1]*r;
        now*=two[l];
        now*=a[i];
        ans+=now;
        
    }
    
    ans*=two[n];
    cout<<ans.x<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef vector< ll > vl;
typedef vector< vl > vvl;
const ll MAX = 1e5+5;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define EE '\n'
#define ll long long int
#define forn(i,j,n) for ( auto i=j ; i<n ; i++ )
#define fornd(i,j,n) for ( auto i=j ; i>n ; i-- )
#define PI 3.14159265
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
#define SOT(A) sort(A.begin(),A.end())
#define SOTR(A) sort(A.rbegin(),A.rend())

const int N = 200043;
const int MOD = 998244353;
//////////////// ncr ///////////////////////
int mul(int x, int y) {return (x * 1ll * y) % MOD;}
int binpow(int x, int y){
    int z = 1;
    while(y){
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
int inv(int x) {return binpow(x, MOD - 2);}
int divide(int x, int y) {return mul(x, inv(y));}
int fact[N];
void precalc(){
    fact[0] = 1;
    for(int i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
}
int C(int n, int k)  {return divide(fact[n], mul(fact[k], fact[n - k]));}

/////////////// ncr  ///////////////////////


//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve(){
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) {
    	if (is_prime[i]) {
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////
////////////////////////////////////////////////////////////////////////////////

int main(){
    int t=1;
    //cin>>t;
    forn(term,0,t){
        ll n,m,x;
        cin>>n>>m;
        priority_queue<ll> A;
        forn(i,0,n) {cin>>x;A.push(x);}
        ll s=0;
        //cout<<"A"<<A.top()<<EE;
        while(m>0){
            // cout<<"A"<<A.top()<<EE;
            x=A.top();
            // cout<<x<<EE;
            A.pop();
            // cout<<"A"<<A.top()<<EE;
            A.push(x/2);
            m--;
        }
        forn(i,0,n){
            // cout<<A.top()<<EE;
            s+=(A.top());
            A.pop();
        }
        cout<<s;
    }
}

Measured memory_bytes: 1404
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int n=nextInt();
		int k=nextInt();
		int a[]=new int[n+1];
		for(int i=1;i<=n;i++)
			a[i]=nextInt();
		while(k-->0)
		{
			int b[]=new int[n+1];
			for(int i=1;i<=n;i++)
			{
				b[Math.max(1,i-a[i])]++;
				int r=Math.min(n,i+a[i]);
				if(r!=n)
					b[r+1]--;
			}
			for(int i=1;i<=n;i++)
				b[i]+=b[i-1];
			a=b;
			boolean flag=true;
			for(int i=1;i<=n;i++)
				if(a[i]!=n)
					flag=false;
			if(flag)
				break;
		}
		for(int i=1;i<=n;i++)
			out.print(a[i]+" ");
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 58536
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>

int main()
{
int a,i,j,k,b,c,n,count=0;
scanf("%d",&a) ; 
n=a+a*a+a*a*a ; 
printf("%d",n) ; 

return 0 ; 
} 

Measured memory_bytes: 1720
#include <stdio.h>
#include <string.h>

int main(void){
  char s[12];
  scanf("%s", s);
  
  int flag=0;
  
  if(s[0]=='A') flag++;
  int l = strlen(s);
  int c=0;
  for(int i=2;i<=(l-2);i++){
    if(s[i]=='C') c++;
  }
  if(c==1) flag++;
  int d=0;
  for(int i=1;i<=l;i++){
    if(s[i]>='a' && s[i]<='z') d++;
  }
  if(d==l-2) flag++;
  if(flag==3) printf("AC\n");
  else printf("WA\n");
  return 0;

}



Measured memory_bytes: 1648
#include <iostream>

using namespace std;

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

    int cnt = 0;
    for(int a = 0; a <= A; a++){
        for(int b = 0; b <= B; b++){
            for(int c = 0; c <= C; c++){
                if(a*500+b*100+c*50 == X){
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

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

int main(){
    long long int A, B, N;
    cin >> A >> B >> N;
    if (A == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (B <= N) {
        long long int l = A*(B-1)/B;
        cout << l << endl;
        return 0;
    } else {
        long long int l = A*N/B;
        cout << l << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  char temp;
  cin >> temp;
  if(temp == 'A'){
    cout << 'T' << endl;
  } else if(temp == 'T'){
    cout << 'A' << endl;
  } else if(temp == 'G'){
    cout << 'C' << endl;
  } else {
    cout << 'G' << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    double a,b,x;
    cin >> a >> b >> x;

    double v = a * a * b;
    double ans;

    if(x <= v / 2){
        double tri_area = x / a;
        double h = tri_area * 2 / b;
        ans = atan(b/h) * 180 / PI;

        cerr << h << endl;
    }else{
        double air_area = (v - x) / a;
        double h = air_area * 2 / a;
        ans = atan(h/a) * 180 / PI;

        cerr << h << endl;
    }

    cout << setprecision(12) << ans << endl;

}


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

using namespace std;


void hawawa()
{
	int n;
	cin >> n;
	cout << "AB";
	if (n < 1000) {
		cout << "C\n";
	}
	else {
		cout << "D\n";
	}
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    std::string s;
    std::cin >> s;

    std::reverse(s.begin(),s.end());
    while(s.size()>0){
        if(s.substr(0,7)=="remaerd"){
            s.erase(0,7);
            continue;
        }
        if(s.substr(0,5)=="maerd"){
            s.erase(0,5);
            continue;
        }
        if(s.substr(0,5)=="esare"){
            s.erase(0,5);
            continue;
        }
        if(s.substr(0,6)=="resare"){
            s.erase(0,6);
            continue;
        }
        break;
    }

    if(s.size()==0) std::cout << "YES" << "\n";
    else std::cout << "NO" << "\n";
    return 0;
}

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

int INF = 1000000000;

int main() {
    int n;
    scanf("%d", &n);
    // vector<int> a = {4,1,6,2,8,5,7,3};
    // n = a.size();
    vector<int> a(n);
    rep(i, n) {
        scanf("%d", &a[i]);
    }
    int len = 1;
    vector<int> l(n+1, INF);
    rep(i, n) {
        if (i == 0) {
            l[len] = a[i];
            continue;
        }
        if (a[i] > l[len]) {
            len++;
            l[len] = a[i];
        } else {
            int ng = 0, ok = len;
            while (ng + 1 < ok) {
                int mid = (ok + ng) / 2;
                if (a[i] <= l[mid]) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            l[ok] = a[i];
        }
        // for (int j = 1; j <= len; j++) {
        //     printf("%d ", l[j]);
        // }
        // printf("\n");
    }    
    printf("%d\n", len);
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    rep(i, n)
    {
        if (a[i] % 2 != 0)
            continue;
        if (!(a[i] % 3 == 0 || a[i] % 5 == 0))
        {
            OP("DENIED");
            return 0;
        }
    }
    OP("APPROVED");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
main(){std::string s;int f,n,c,i,j;for(;std::cin>>s,s!="#";printf("%d\n",n))for(n=99999,f=j=-1;j++<1;f=c<n&&(n=c))for(c=i=0;++i<s.size();)f*(s[i-1]-1)%3<f*(s[i]-1)%3?c++:f*=-1;}

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

int main()
{
    int n;
    int order1, order2, value;
    deque<int> a;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> order1;

        switch( order1 )
        {
            case 0:
                cin >> order2 >> value;
                if( order2 == 0 )
                    a.push_front( value );
                else
                    a.push_back(value);
                break;
            case 1:
                cin >> value;
                cout << a[value] << endl;
                break;
            case 2:
                cin >> order2;
                if( order2 == 0 )
                    a.pop_front();
                else
                    a.pop_back();
                break;
        }   
    }
    return 0;
}


Measured memory_bytes: 4516
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

const int MAXN = 1100010;
long long fact[MAXN], inv[MAXN];

void initComb() {
    fact[0] = 1;
    for (int i=1; i<MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    inv[MAXN - 1] = mod_pow(fact[MAXN - 1], MOD-2);
    for (int i=MAXN - 2; i>=0; i--) {
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }
}

long long comb(int n, int r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}

int main(void) {
    long long X, Y; cin >> X >> Y;
    if ((X+Y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    long long n = (X+Y)/3LL;
    long long s = 2LL*n;
    long long r = s - Y;
    if (r < 0 || n < r) {
        cout << 0 << endl;
        return 0;
    } else {
        initComb();
        cout << comb(n, r) << endl;
    }
    return 0;
}




Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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

    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }

    string ans;
    int i = 0;
    while (n != 0) {
        if (n % 2 == 0) {
            ans += '0';
            n = n / 2;
        } else {
            ans += '1';
            if (i % 2 == 0) {
                n = (n - 1) / 2;
            } else {
                n = (n + 1) / 2;
            }
        }
        i++;
    }

    reverse(ans.begin(), ans.end());

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

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    n = IS()
    if len(set(n[:3])) == 1 or len(set(n[1:])) == 1: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n; cin>>n;
    vector<ll> l(n);
    rep(i,n) cin>>l[i];
    int cnt=0;
    rep(i,n-2){
        repi(j,i+1,n-1){
            repi(k,j+1,n){
                if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i])
                if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]) cnt++;
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

class STlazy{
private:
    int n;
    vector<ll> node, lazy;

public:
    STlazy(vector<ll> v){
        int siz = v.size();
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, 0);
        lazy.resize(2*n-1, 0);
        
        for(int i = 0; i < siz; i++)    node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = node[2*i+1] + node[2*i+2];
    }

    void eval(int k, int l, int r){
        if(lazy[k] == 0)    return;
        node[k] += lazy[k];
        if(r-l > 1){
            lazy[2*k+1] += lazy[k]/2;
            lazy[2*k+2] += lazy[k]/2;
        }
        lazy[k] = 0;
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, l, r);
        if(r <= a || b <= l)    return;
        if(a <= l && r <= b){
            lazy[k] += (r-l)*x;
            eval(k, l, r);
            return;
        }
        add(a, b, x, 2*k+1, l, (l+r)/2);
        add(a, b, x, 2*k+2, (l+r)/2, r);
        node[k] = node[2*k+1] + node[2*k+2]; // 自分の全ての子孫の値伝播が終わったら自分を更新する
    }

    ll query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        if(r <= a || b <= l)    return 0;
        eval(k, l, r); // 最初の呼び出しが必ずeval(0,0,n)となるので漏れなく上から値の伝播がなされている
        if(a <= l && r <= b)    return node[k];
        ll lx = query(a, b, 2*k+1, l, (l+r)/2);
        ll rx = query(a, b, 2*k+2, (l+r)/2, r);
        return lx+rx;
    }
};

int main(){
    int n, d, a;
    cin >> n >> d >> a;
    vector<pii> vp;
    for(int i = 0; i < n; i++){
        int x, h;
        cin >> x >> h;
        vp.push_back({x, h});
    }
    sort(vp.begin(), vp.end());
    
    vector<ll> za;
    for(int i = 0; i < n; i++)  za.push_back(vp[i].first);

    vector<ll> emp(n, 0);
    STlazy seg(emp);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll hist = seg.query(i, i+1);
        ll hp = vp[i].second;
        if(hist*a >= hp)  continue;
        ll attack = (hp-hist*a+a-1)/a;
        ans += attack;
        ll from = vp[i].first;
        ll to = from+2*d;
        int x = --upper_bound(za.begin(),za.end(),to)-za.begin();
        seg.add(i, x+1, attack);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14832
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const double eps = 1e-10;
const int MAX_N = 50;
const double g = 9.8;

int N, V, X, Y;
int L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

double position(double vy, double t) {
	return vy*t-g*t*t/2.0;
}

int cmp(double lb, double ub, double a) {
	return a < lb + eps?-1:a>ub-eps?1:0;
}

// 射出路径经过(qx,qy)时，能否击中猪
bool check(double qx, double qy) {
	double a = g*g/4.0, b=g*qy-V*V, c=qx*qx+qy*qy;
	double D = b*b-4*a*c;
	if (D < 0 && D > -eps) D = 0;
	if (D < 0) return false;
	for (int d = -1; d <= 1; d += 2) { // 验证解的循环
		double t2 = (-b + d*sqrt(D))/(2*a);
		if (t2 <= 0) continue;
		double t = sqrt(t2);
		double vx = qx/t, vy=(qy+g*t*t/2.0)/t;
		// 是否通过猪的正上方？
		double yt = position(vy, X/vx);
		if (yt < Y-eps) continue;

		bool ok = true;
		for (int i = 0; i < N; ++i) {
			if (L[i] >= X) continue;
			if (R[i] == X &&  Y <= T[i] && B[i] <= yt) ok = false;
			int yL = cmp(B[i], T[i], position(vy, L[i]/vx)); // 左侧相对位置
			int yR = cmp(B[i], T[i], position(vy, R[i]/vx)); // 右侧相对位置
			int xH = cmp(L[i], R[i], vx*(vy/g)); // 最高点相对位置
			int yH = cmp(B[i], T[i], position(vy, vy/g));
			if (xH == 0 && yH >= 0 && yL < 0) ok = false;
			if (yL * yR <= 0) ok = false;
		}
		if (ok) return true;
	}
	return false;
}

int main() {
	scanf("%d%d%d%d", &N, &V, &X, &Y);
	for (int i = 0; i < N; ++i) {
		scanf("%d%d%d%d", L+i, B+i, R+i, T+i);
	}
	for (int i = 0; i < N; ++i) {
		R[i] = min(R[i], X);
	}
	bool ok = check(X, Y);
	for (int i = 0; i < N; ++i) {
		ok |= check(L[i], T[i]);
		ok |= check(R[i], T[i]);
	}
	puts(ok?"Yes":"No");
	return 0;
}


Measured memory_bytes: 2596
def main():
    n, w = map(int, input().split())
    wv = [[0, 0] for _ in range(n + 1)]
    for i in range(1, n + 1):
        wv[i] = list(map(int, input().split()))
    # 1からi番目までの品物から総重量がj以下になるように選んだ時の価値の総和の最大値
    dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]

    for i in range(1, n + 1):
        for j in range(w + 1):
            if j - wv[i][0] >= 0:
                dp[i][j] = max(dp[i][j], dp[i - 1][j - wv[i][0]] + wv[i][1])
            dp[i][j] = max(dp[i][j], dp[i - 1][j])
    print(dp[n][w])


if __name__ == "__main__":
    main()


Measured memory_bytes: 217400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, k;
  k = 0;
  in2(a, b);
  string s;
  in(s);
  rep(i, s.size()){
    if(i != a && s[i] == '-')
      k++;
    if(i == a && s[i] != '-')
      k++;
  }
  if(k)
    out("No");
  else
    out("Yes");
  memi;
}

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

using namespace std;

class DisjointSet {
  public:
    vector<int> rank, p;

    DisjointSet() {}
    DisjointSet(int size) {
      rank.resize(size, 0);
      p.resize(size, 0);
      for ( int i = 0; i < size; i++ ) makeSet(i);
    }

    void makeSet(int x) {
      p[x] = x;
      rank[x] = 0;
    }

    bool same(int x, int y) {
      return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
      link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
      if ( rank[x] > rank[y] ) {
        p[y] = x;
      } else {
        p[x] = y;
        if ( rank[x] == rank[y] ) {
          rank[y]++;
        }
      }
    }

    int findSet(int x) {
      if ( x != p[x] ) {
        p[x] = findSet(p[x]);
      }
      return p[x];
    }
};

int main() {
  int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  for ( int i = 0; i < q; i++ ) {
    cin >> t >> a >> b;
    if ( t == 0 ) ds.unite(a, b);
    else if ( t == 1 ) {
      if ( ds.same(a, b) ) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;


int main() {
	ll a, b, x; cin >> a >> b >> x;
	if (x < a) {
		cout << x % mod << endl;
	}
	else {
		ll num = (x - a) / (a - b) + 1;
		num %= mod;
		cout << (x%mod + b % mod*num%mod) % mod << endl;
	}
	//stop
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    string s, t;
    cin >> s >> t;

    int ans = 0;
    for (int i=0; i<(int)s.size(); i++) {
        ans += s[i] != t[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3796
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;
    cin >> s;

    if (s.front() == s.back()) {
        if (s.size() % 2 == 1) {
            cout << "Second\n";
        } else {
            cout << "First\n";
        }
    } else {
        if (s.size() % 2 == 1) {
            cout << "First\n";
        } else {
            cout << "Second\n";
        }
    }

    return 0;
}

Measured memory_bytes: 512
def solve(string):
    n, *a = map(int, string.split())
    m1, m2 = sorted(a)[-2:]
    index = a.index(m2)
    return "\n".join([str(m1) if i == index else str(m2) for i in range(n)])


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


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

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    long N;
    scan(N);

    long[] ans;
    for (long k = 2; k*k <= N; k++) {
        if (check(N, k)) {
            ans ~= k;
        }
    }

    for (long d = 1; d*d <= N; d++) {
        if ((N - 1) % d == 0) {
            auto k = (N - 1) / d;

            if (d < k) {
                ans ~= k;
            }
        }
    }

    ans = ans.sort().uniq.array;

    debug {
        writeln(ans);
    }

    auto m = ans.length.to!long + 1;
    writeln(m);
}

bool check(long N, long k) {
    if (N % k == 0) {
        return check(N / k, k);
    }
    return N % k == 1;
}


void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

int main() {
  while(1) {
    int n, y, b, r, t, name;
    double max=0;
    cin >> n;
    if(n==0) break;
    cin >> y;
    for(int i=0; i<n; i++) {
      double x=1.0;
      cin >> b >> r >> t;
      if(t==1) {
	x=(double)1+(double)y*r/100;
	if(x>max) {
	  name = b;
	  max = x;
	}
      } else {
	for(int j=0; j<y; j++) x*=(double)1+(double)r/100; 
	if(x>max) {
	  name = b;
	  max = x;
	}
      }
    }
    cout << name << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
n,m,*a=map(int,open(0).read().split())
if n==1:
    print(1)
    exit()
b=[-1]*(n+1)
a+=[0,0]
for i in a:
    b[i]=0
if a[0]==1 and a[1]==2:
    b[1],b[2]=0,0
elif a[0]==1:
    b[2]=1
elif a[0]==2:
    b[1]=1
else:    
    b[1],b[2]=1,2
for i in range(3,n+1):
    if b[i]==-1:
        b[i]=(b[i-1]+b[i-2])%1000000007
print(b[-1])

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

using namespace std;

template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back(abs(a - x));
    }
    int tmp = v[0];
    for (int i = 1; i < n; ++i) {
        tmp = gcd(tmp, v[i]);
    }
    cout << tmp << endl;
}


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

int main(){
  string str;
  char al = 'a';
  char a ='z';
  int i=0,c[26]={};
  while(getline(cin,str)){
    for(i=0;i<str.size();i++){
      if(str[i]>=al && str[i]<=a){
	c[str[i]-al]++;
      }

      else if(str[i]>='A'&&str[i]<='Z') c[str[i]-'A']++;
    }
  }
  
  
  for(int i=0;i<26;i++){
    cout << (char)(al+i)  << " : "  << c[i] << endl;
  
  }
  return 0;
   
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    uint64_t ans=K+1;
    if(B-A-2>0){
        int64_t t=(K-A+1)/2;
        if(t>0) ans=A+(B-A)*t+(K-A+1)%2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
unsigned long long int sub(int n)
{
	unsigned long long int i;
	if(n==1) return 1;
	else
	{
	i=n*sub(n-1);
	return i;
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	printf("%llu\n",sub(n));
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   998244353;
ll a,b,c,d;
ll dp[3050][3050];
ll fn(ll x, ll y) {
	if(x<a||y<b)
	return 0;
	if(x==a&&y==b)
	return 1;
	if(dp[x][y]!=-1)
	return dp[x][y];
	return dp[x][y]=(x*fn(x,y-1)+y*fn(x-1,y)-(x-1)*(y-1)*fn(x-1,y-1)%mod+mod)%mod;
}
int main()
{  fast
cin>>a>>b>>c>>d;
memset(dp , -1, sizeof dp);
cout<<fn(c,d);
}

Measured memory_bytes: 76596
#include <bits/stdc++.h>
#include <iostream>
#include<string>
#include<cmath>
#include<vector>
#include<set>
typedef long long ll;
#define ss ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;

int main()
{
ss
string s;
    cin>>s;
    ll t=0,max=0;
    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i]=='R')
            t++;
        if(t>max)
            max=t;
        else
        {
            t=0;
        }
    }
    if(s[2]=='R' && s[1]==s[0] )
        max++;
    if(s[0]=='S' && s[1]=='R' && s[2]=='R')
        max++;
    cout<<max;
    
	return 0;
}


Measured memory_bytes: 3648
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	ll n;
	cin >> n;
	if(n == 1){
		cout << 0<<endl;
		return 0;
	}
	ll nn = n;
	ll i = 2;
	vector<pair<ll,int>> ps = {{1,1}};
	while(i<=sqrt(n)){
		if(n%i == 0){
			if(ps[ps.size()-1].first == i){
				ps[ps.size()-1].second++;
			}else{
				pair<ll,int> p={i,1};
				ps.push_back(p);
			}
			n = n/i;
		}else{
			i++;
		}
		if(ps.size() == 1 && sqrt(nn) < i){
			break;
		}
	}

	ps.erase(ps.begin());
	if(ps[ps.size()-1].first == n){
		ps[ps.size()-1].second++;
	}else{
		ps.push_back({n, 1});
	}
	int ans = 0;
	rep(i, ps.size()){
		int cnt = 0;
		int a = ps[i].second;
		//cout << ps[i].first << " " << ps[i].second<<endl;
		while(a > 0){

			if(a>0){
				cnt++;
				a -= 1;
			}
			a -= cnt;
		}
		ans += cnt;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3696
/**
 *    author:  [itmo] enot.1.10
 *    created: 03.04.2017 20:02:34       
**/
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = 1.01e9;
const dbl eps = 1e-9;

/* --- main part --- */

const int N = 1e5 + 10;

vi v[N];

int c[N];
int last[N][11];


int main()
{
    #ifdef home
        assert(freopen("1.in", "r", stdin));
        assert(freopen("1.out", "w", stdout));
    #endif
    int n, m;
    scanf("%d%d", &n, &m);
    forn(_, m)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        --x, --y;
        v[x].pb(y);
        v[y].pb(x);
    }
    memset(last, -1, sizeof last);     
    int q;
    scanf("%d", &q);
    forn(i, q)
    {
        int x, d;
        scanf("%d%d%d", &x, &d, &c[i]);
        --x;
        last[x][d] = i;
    }
    for (int i = 10; i > 0; --i)
    {
        forn(x, n) if (last[x][i] != -1)
        {
            for (int y : v[x]) last[y][i - 1] = max(last[y][i - 1], last[x][i]);
        }
    }
    forn(x, n)
    {
        int pos = -1;
        forn(i, 11) pos = max(pos, last[x][i]);
        int res = 0;
        if (pos >= 0) res = c[pos];
        printf("%d\n", res);
    }
    #ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


Measured memory_bytes: 11128
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	// K
	scanner.Scan()
	K, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	// X
	scanner.Scan()
	X, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	if (500 * K) >= X {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}


/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))

//ll ncr(ll n,ll r,ll p){if(r==0){return 1;}return ((((fact[n]* inv[r]) % p) * inv[n-r]) % p);}
vector<ll>v[100004];
unordered_map<ll,ll>mapa;
ll dp[100003];
ll dfs(ll i)
{
	if(mapa[i]!=0)
	{
		return dp[i];
	}
	mapa[i]=1;
	dp[i]=1;
	for(ll j:v[i])
	{
		
		dp[i]=max(dp[i],1+dfs(j));
		
	}
	return dp[i];


}
int main()
{
	ll n,m;
	in2(n,m)
	for(ll i=0;i<m;i++)
	{
		ll x,y;
		in2(x,y)
		v[x].pb(y);
	}
	//cout<<" jii";
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		//cout<<"jj";
		if(mapa[i]==0)
		{
			
			ans=max(ans,dfs(i));
			//cout<<i<<" "<<dfs(ans)<<endl;
		}
	}
	//prllarr(dp,6);
	out(ans-1)

}

	



	

Measured memory_bytes: 12708
#include <stdio.h>

int a[200010],b[200010];
int main(){
	int n,m;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	scanf("%d",&m);
	for(int i=0;i<m;i++)scanf("%d",b+i);
	a[n]=b[m]=2e9;
	for(int i=0,j=0;i!=n||j!=m;){
		if(a[i]<b[j])printf("%d\n",a[i++]);
		else if(a[i]>b[j])printf("%d\n",b[j++]);
		else printf("%d\n",a[i]),i++,j++;
	}
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

const int MOD = 1e9 + 7;
inline int mod (int a, int m = MOD) { return (a % m + m) % m; }

int sum(int j, int i){
    return (i+1)*i/2 - (j-1)*j/2;
}

signed main(){
    int n, k;
    cin >> n >> k;
    
    int ans = 0;
    reps(i,k,n+1){
        ans = mod(ans + sum(n-i+1,n) - sum(0,i-1) + 1);
    }
    
    cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int INF = INT_MAX;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

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; }
struct SegmentTree{
private:
    int n;
    vector<int> node;
public:
    SegmentTree(vector<int> v){
        int sz = v.size();
        n = 1;
        while(n < sz) n*=2;
        node.resize(2*n-1,INF);
        rep(i,sz) node[i+n-1] = v[i];
        rrep(i,n-2)node[i] = min(node[2*i+1],node[2*i+2]);
    }
    void update(int x,int val){
        x += (n-1);
        node[x] = val;
        while(x>0){
            x = (x-1)/2;
            node[x] = min(node[2*x+1],node[2*x+2]);
        }
    }
    int getmin(int a,int b,int l=0,int r=-1,int k=0){
        if(r<0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];
        int mid = (l+r)/2;
        int vl = getmin(a,b,l,mid,2*k+1);
        int vr = getmin(a,b,mid,r,2*k+2);
        return min(vl,vr);
    }
};
int main() {
    int n,q;
    cin >> n >> q;
    SegmentTree seg( vector<int>(n,INF));
    rep(i,q){
        int c,x,y;
        cin >> c >> x >> y;
        if(c==0) seg.update(x,y);
        else cout << seg.getmin(x,y+1) << endl;
    }
    return 0;
}


Measured memory_bytes: 4160
n = int(input())
Sum = 1
Max = 1000000000000000000

l = list(map(int, input().split()))
f = 0
for i in range(n):
  if l[i]==0:
    f = 1
for i in range(n):
  Sum=Sum*l[i]
  if Sum>Max:
     break
if f == 1:
  print("0")
elif Sum<=Max:
  print("%d" % Sum)
else :
  print("%d" % -1)


Measured memory_bytes: 21468
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int a[10];
	REP0(i,10) scanf("%d",&a[i]);
	sort(a,a+10);
	printf("%d\n%d\n%d\n",a[9],a[8],a[7]);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef struct {
    int to;
    ll cap;
    int rev;
} edge;

vector<vector<edge> > G;
vector<bool> used;
ll INF = 10000000000000;


//辺の追加
void add_edge(int from, int to, ll cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size()-1});
}


//頂点vからの増加パスのフローを返す
//頂点sの時はf=INFとする
//fは現在の頂点に来るまでの増加パス中の最小の容量
ll dfs(int v, int t, ll f) {
    if (v == t)
        return f;
    
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        
        if (!used[e.to] && e.cap > 0) {
            //dはvからtへの増加パスのフロー
            ll d = dfs(e.to, t, min(f, e.cap));
            
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}


//sからtへの最大流を返す
//nは頂点数
//O(F|E|) Fは最大流量
ll max_flow(int n, int s, int t) {
    int i = 1;
    ll flow = 0;
    used.resize(n);
    while (1) {
        for (int i = 0; i < n; i++)
            used[i] = false;
        
        ll f = dfs(s, t, INF);

        if (f == 0)
            return flow;
        else 
            flow += f;
    }
}

int main() {
    int n, m;   cin >> n >> m;
    G.resize(n);
    for (int i = 0; i < m; i++) {
        int u, v;   ll c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }

    cout << max_flow(n, 0, n-1) << endl;

    return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define ppb pop_back
#define ppf pop_front
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//int row[]={-1,0,1,0};
//int col[]={0,1,0,-1};

const ll N=1e4+10;
const ll M=1e9+7;

ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m

int main()
{
    fast_in_out;

    int n;
    cin>>n;

    ll ans=0;

    For(i,0,n)
    {
        ll a;
        cin>>a;
        ans+=a-1;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256