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

   typedef long long ll;
   typedef pair<ll, ll> Pii;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 300;
ll N;
ll a[MAX_N];
ll x = 0, y = 0, z = 0;
double dp[3 * MAX_N + 1][ (3 * MAX_N / 2) + 2][MAX_N + 1] = {};

double sushi(ll x, ll y, ll z){
  //1-kan * x, 2-kan * y, 3-kan * z
  if (x == 0 && y ==0 && z == 0) return 0;
  else if (x < 0 || y < 0 || z < 0 || (x + 2 * y + 3 * z > x + 2 * y + 3 * z)) return 0;
  else if (dp[x][y][z] >= 0) return dp[x][y][z];
  else{
    double ans = (x * sushi(x-1,y,z) + y * sushi(x+1,y-1,z) + z * sushi(x,y+1,z-1) + N) / (double)(x+y+z);
    dp[x][y][z] = ans;
    return ans;
  }
}
int main(){
  cin >> N;
  REP(i, N){
    cin >> a[i];
    if (a[i] == 1) x++;
    if (a[i] == 2) y++;
    if (a[i] == 3) z++;
  }

  REP(i, 3 * N + 1){
    REP(j, (3 * N / 2) + 2){
      REP(k, N + 1){
        dp[i][j][k]= -1.0;
      }
    }
  }
  /*
  REP(i, 3 * N + 1){
    REP(j, 2 * N + 1){
      REP(k, N + 1){
        if (i + 2 * j + 3 * k <= x + 2 * y + 3 * z){
          printf("sushi(%lld, %lld, %lld) = %f\n", i, j, k, sushi(i,j,k));
        }
      }
    }
  }
  */
  printf("%.10f\n", sushi(x,y,z));
}


Measured memory_bytes: 957952
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int c = (A == B) + (B == C) + (C == A);
	if (c == 1)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 384
n = int(raw_input())
S = map(int,raw_input().strip().split(' '))

def counting_sort(S,k):
    C = [0]*(k+1)
    B = [0]*len(S)
    for v in S:
        C[v] += 1
    for i in range(1,k+1):
        C[i] += C[i-1]
    for i in range(len(S)):
        B[C[S[i]]-1] = S[i]
        C[S[i]] -= 1
    return B

B = counting_sort(S,10000)
for b in B:
    print b,

Measured memory_bytes: 177024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var k, n int
	fmt.Scanf("%d %d", &n, &k)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	sum := 0
	for i := 0; i < k; i++ {
		sum += p[i]
	}
	fmt.Println(sum)
}

Measured memory_bytes: 1888
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
diff = 1000
for i, hi in enumerate(h):
    hi_temp = abs(a - (t - hi*0.006))
    if hi_temp < diff:
        diff = hi_temp
        ans = i + 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    string s;cin>>s;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            cnt++;
    }
    int ans=0;
    for(int i=0;i<cnt;i++)
    {
        if(s[i]=='W')
            ans++;
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3764
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

fn rec(node: usize, dp: &mut [usize], graph: &[Vec<usize>]) -> usize {
    if dp[node] != std::usize::MAX {
        return dp[node];
    }

    let mut result = 0;
    graph[node].iter().for_each(|v| {
        result = result.max(rec(*v, dp, graph) + 1);
    });
    dp[node] = result;
    result
}

#[fastout]
pub fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(Usize1, Usize1); m],
    }

    let mut graph = vec![Vec::new(); n];
    edges.into_iter().for_each(|(x, y)| {
        graph[x].push(y);
    });
    let mut dp = vec![std::usize::MAX; n];

    println!(
        "{}",
        (0..n)
            .into_iter()
            .map(|i| rec(i, &mut dp, &graph))
            .max()
            .unwrap()
    );
}


Measured memory_bytes: 12544
#include<stdio.h>
int selectionSort(int *,int );

int main(){
  int A[100],N,i,x;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);

  x=selectionSort(A,N);
  for(i=0;i<N;i++)
    {
      if(i>0)printf(" ");
      printf("%d",A[i]);
    }
  printf("\n");
  printf("%d\n",x);
  return 0;
}

    int selectionSort(int A[],int N)
    {
      int i,j,minj,x=0,tmp;
      for(i=0;i<N-1;i++)
        {
          minj=i;
          for(j=i;j<N;j++)
            {
              if(A[j]<A[minj])minj=j;
            }
          tmp=A[i];
          A[i]=A[minj];
          A[minj]=tmp;
          if(i != minj)x++;
        }
      return x;
    }



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N; cin >> N;	
	map<Pl, ll> mp;
	
	ll p2[200005];
	p2[0] = 1;
	for (ll i = 1; i < 200005; i++) {
		p2[i] = (p2[i-1] * 2) % mod;
	}

	for (ll i = 0; i < N; i++) {
		ll A, B; cin >> A >> B;
		if (A == 0 || B == 0) {
			if (A == 0 && B == 0) mp[Pl(0, 0)]++;
			else if (A == 0) mp[Pl(0, 1)]++;
			else mp[Pl(1, 0)]++;
			continue;
		}
		ll div = gcd(abs(A), abs(B));
		A /= div, B /= div;
		if (B < 0) {
			A = -A;
			B = -B;
		}

		mp[Pl(A, B)]++;
		//cout << A << " " << B << endl;
	}
	
	set<Pl> used;
	ll ans = 1;
	for (auto &data : mp) {
		ll a, b;
		tie(a, b) = data.first;
		if (used.find(Pl(a, b)) != used.end()) continue;
		if (a == 0 && b == 0) {
			continue;
		}
		used.emplace(a, b);
		ll na = b, nb = -a;
		if (na == 0 || nb == 0) {
			nb = a;
		}
		if (nb < 0) na = -na, nb = -nb;
		used.emplace(na, nb);

		ll cnt1 = data.second, cnt2 = mp[Pl(na, nb)];
		//cout << a << " " << b << " " << cnt1 << " " << na << " " << nb << " " << cnt2 << endl;

		ll num = (p2[cnt1]+p2[cnt2]+mod-1) % mod;
		(ans *= num) %= mod;
	}
	
	cout << (ans+mp[Pl(0, 0)]+mod-1)%mod << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 55128
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    ans = float('inf')
    for a in A:
        if a % 2 == 0:
            cnt = 0
            while True:
                if a % 2 == 0:
                    a = a // 2
                    cnt += 1
                else:
                    break
            ans = min(ans, cnt)
        else:
            print(0)
            exit()
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false
using namespace std;

ll bmm(ll a, ll b) {
	if (b == 0) return a;
	else return bmm(b, a%b);
}
ll kmm(ll a, ll b) {
	return(a*b) / bmm(a, b);
}


const ll mod = 1e9 + 7;
const ll MAXN = 3e5+5;

ss s;

int main() {
	isc;
	cin >> s;
	if(s=="Sunny")
		cout << "Cloudy";
	else{
		if(s=="Cloudy")
			cout << "Rainy";
		else
			cout << "Sunny";
	}
	return 0;
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

int n;

ll dp[MAX_N][4][4][4];

int a = 0, c = 1, g = 2, t = 3;

ll ans = 0;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  dp[0][t][t][t] = 1;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) for (int l = 0; l < 4; ++l) {
      for (int m = 0; m < 4; ++m) {
        if (j == a && k == g && l == c) continue;
        if (k == a && l == g && m == c) continue;
        if (j == a && k == g && m == c) continue;
        if (j == a && l == g && m == c) continue;
        if (k == g && l == a && m == c) continue;
        if (k == a && l == c && m == g) continue;
        if (j == g && k == a && l == c) continue;
        if (j == a && k == c && l == g) continue;

        dp[i + 1][k][l][m] += dp[i][j][k][l];
        dp[i + 1][k][l][m] %= MOD;
      }
    }
  }

  for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) for (int l = 0; l < 4; ++l) {
    ans += dp[n][j][k][l];
    ans %= MOD;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
from functools import reduce

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7


def cmb(r):
    numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
    return numerator * pow(denominator, mod - 2, mod) % mod


ans = pow(2, n, mod) - 1 - cmb(a) - cmb(b)
print(ans % mod)


Measured memory_bytes: 11556
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7;

int a[N];

void solve() {
    int n , k;
    cin >> n >> k;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
    }
    sort(a+1 , a+n+1);
    int l = 1 , r = a[n] , ans;
    while(l <= r) {
        int md = l + (r-l) / 2 , cnt = 0;
        for(int i = 1; i <= n; i ++) {
            if(a[i] <= md) continue;
            else {
                cnt += a[i]/md-1 + (a[i]%md != 0);
            }
        }
        if(cnt <= k) {
            ans = md;
            r = md-1;
        }
        else {
            l = md+1;
        }
    }
    cout << ans;
}
/*
*/
main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4420
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      x.begin(),x.end()
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,n);
  unsigned long long a[112345]={};
  long long b[112345]={};
  long long m=1123456789;
  int minInd=-1;
  int count=0;
  int i;
  rep(i,n){
    in(long long,x);
    if(x < 0){
      x= abs(x);
      count++;
    }
    b[i] = x;
    if(x < m){
      m = x;
      minInd = i;
    }
    a[i+1] = a[i]+x;
    dout(m);
  }
  if (count % 2 == 1){
    dputs("ひいたよ");
    dout(a[n]);
    a[n] -= b[minInd]*2;
  }
  putv(a[n]);
  return 0;
}


Measured memory_bytes: 2176
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 
    string s;
    cin>>s;
    cout<<s[0]<<(s.size()-2)<<s[s.size()-1]<<endl;





}


Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
	static bool[] h;
	static List<int>[] a;
	const int mod=1000000007;
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		a=new List<int>[n+1];
		for(int i=1;i<=n;i++){a[i]=new List<int>();}
		for(int i=0;i<n-1;i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			a[q[0]].Add(q[1]);
			a[q[1]].Add(q[0]);
		}
		h=new bool[n+1];
		Console.WriteLine("{0}",fu(1)[0]);
	}
	static long[] fu(int b){
		h[b]=true;
		long f=1,g=1;
		for(int i=0;i<a[b].Count;i++){
			if(!h[a[b][i]]){
				long[] q=fu(a[b][i]);
				g=(g*q[0])%mod;
				f=(f*q[1])%mod;
			}
		}
		return new long[]{(f+g)%mod,g};
	}
}

Measured memory_bytes: 31684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  ll res = 0;
  rep(i, n) {
    ll a; cin >> a;
    if (i%2 == 0) {
      if (a%2) {
        res++;
      }
    }
  }
  cout << res << endl;
}

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

using namespace std;

const int MAX = 1e5 + 10;

int main()
{
	long long x; cin>>x;

	long long c = x/11;

	if(c*11 >= x) cout<<2*c;
	else if(c*11 + 6 >= x) cout<<2*c+1;
	else cout<<2*c+2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,i,j;
  int p[10000];
  int sum=0;
  cin>>n>>k;
  for(i=0;i<n;i++)
  {
    cin>>p[i];
  }
  sort(p,p+n);
  for(i=0;i<k;i++)
  {
    sum=sum+p[i];
    
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int a[n];
	int num[1000]={};
	for (int i=0;i<n;i++)
		cin >> a[i];
	for (int i=0;i<m;i++)
	{
		int b;
		cin >> b;
		for(int j=0;j<n;j++)
			if(a[j]<=b) 
			{
				num[j]++;
				break;
			}
	}
	int res=0;
	for (int i=0;i<n;i++)
	{
		if (num[res]<num[i])
			res=i;
	}
	cout << (res+1) << endl;
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int pan(char a, char b, char c) {
	if (a != b && b != c && c != a) return 1;
	return 0;
}
int main() {
    int n;
    cin>>n; 
    char a[n];
    cin>>a;
    long long cnt = 0;
    int x = 0, y=0, z= 0;
    for (int i = 0; i < n ; i++) {
    	if (a[i] == 'R') x++;
    	if (a[i] == 'G') y++;
    	if (a[i] == 'B') z++;
	}
	cnt = (long long)x * y * z;
	for (int i = 0; i < n; i++) {
		for (int d = 1; i + d+d< n; d++)
		if (pan(a[i], a[i+d],a[i+d+d])) cnt--;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main() {
  while (true) {
    int t, h, s;
    cin >> t >> h >> s;

    if (t == -1)
      break;

    int sum = 7200 - ((t * 60 + h) * 60 + s);
    printf("%02d:%02d:%02d\n", sum / 3600, (sum % 3600) / 60, (sum % 60));
    sum *= 3;
    printf("%02d:%02d:%02d\n", sum / 3600, (sum % 3600) / 60, (sum % 60));
  }
}


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

#define ll long long
#define endl "\n"

void solve() {
  ll a[3];
  for (ll &i : a)
    cin >> i;
  sort(a, a + 3);
  ll ans = 0;
  if (a[1] == a[0])
    ans = a[2];
  else if (a[1] == a[2])
    ans = a[0];
  cout << ans << endl;
}

int main() {
  ll t;
  t = 1;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
bool is_prime(int n)
{
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    vector<int> dp(100100);
    for (int i = 3; i < 100001; i++)
    {
        if (i % 2 == 0)
        {
            continue;
        }
        if (!is_prime(i))
        {
            continue;
        }
        if (!is_prime((i + 1) / 2))
        {
            continue;
        }
        dp[i] = 1;
    }
    for (int i = 0; i < 100000; i++)
    {
        dp[i + 1] += dp[i];
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string s;
  cin >> s;
  YesorNo(s[2] == s[3] && s[4] == s[5]);
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	cout << (a+b)%24 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#define F(a) for(register int (i)(0);(i)<(a);(i)++)
int n,a[100010];
std::map<int,int> m;
signed main()
{
	scanf("%d",&n);int t,now(0),ans(0);
	F(n)
	{
		scanf("%d",&t);
		if(!m[t])
		{
			a[now++]=t;
		}
		m[t]++;
	}
	F(now)
	{
		(ans+=m[a[i]])-=a[i]*(m[a[i]]>=a[i]);
	}
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 5120
Module Program

    Sub Main(args As String())

        Dim arrStr As String() = Split(Console.ReadLine())
        Dim S As Integer = CInt(arrStr(0))
        Dim W As Integer = CInt(arrStr(1))

        If S <= W Then
            Console.WriteLine("unsafe")
        Else
            Console.WriteLine("safe")
        End If

    End Sub

End Module

Measured memory_bytes: 28388
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;

void file() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    if (freopen("input.txt", "r", stdin));
    if (freopen("output.txt", "w", stdout));
#endif
}


int main()
{
    file();

    int n;
    cin >> n;
    cout << 2 * acos(-1) * n << endl;

    


}


Measured memory_bytes: 3828
from functools import lru_cache
import sys
sys.setrecursionlimit(10000000)
@lru_cache(maxsize= 10 ** 7)
def solve(n):
  if n == 1:
    return 1
  else:
    return solve(n//2) * 2 + 1
h = int(input())
print(solve(h))


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int l;
    cin >> l;
    double edge = l / 3.0;

    cout << fixed;
    cout << setprecision(12);
    cout << edge * edge * edge << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int N=2e5+20,inf=0x3f3f3f3f;
int n,a[N];
int main()
{
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==i)
			cnt++;
	}
	a[0]=-1;
	for(int i=1;i<=n;i++)
	{
		if(a[i-1]==i-1&&a[i]==i)
			cnt--,swap(a[i],a[i-1]);
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    pair = defaultdict(int)

    for i in range(N):
        pair[A[i]] += 1

    cnt = 0
    for num, count in pair.items():
        if count >= num:
            cnt += count - num
        else:
            cnt += count

    print(cnt)
if __name__ == "__main__":
    main()

Measured memory_bytes: 18676
/* D-"Median of Medians" */
/*  */
//include <bits/stdc++.h>
#include <iostream>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++) 
using namespace std;

int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;

    return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx-sx, dy = ty-sy;
  for(int i=0; i<dx; ++i) cout << "R";
  for(int i=0; i<dy; ++i) cout << "U";
  for(int i=0; i<dx; ++i) cout << "L";
  for(int i=0; i<dy; ++i) cout << "D";
  cout << "L";
  for(int i=0; i<dy+1; ++i) cout << "U";
  for(int i=0; i<dx+1; ++i) cout << "R";
  cout << "D";
  cout << "R";
  for(int i=0; i<dy+1; ++i) cout << "D";
  for(int i=0; i<dx+1; ++i) cout << "L";
  cout << "U" << endl;
}

Measured memory_bytes: 3508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl
#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

LL n, x;

LL gcd(LL x, LL y) {
    return x % y ? gcd(y, x % y) : y;
}

int main() {
    LL d;
    while (cin >> n >> x) {
        d = gcd(n, x);
        n /= d, x /= d;
        cout << d * 3 * (n - 1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
c = input()

from collections import deque

red = deque()
white = deque()
for i, ci in enumerate(c):
    if ci == "R":
        red.append(i)
    else:
        white.append(i)
if len(red) == 0:
    print(0)
    exit()
if len(white) == 0:
    print(0)
    exit()

red.appendleft(-1)
white.append(2000000)

cnt = 0
while True:
    r = red.pop()
    w = white.popleft()
    if w > r:
        print(cnt)
        break
    cnt += 1

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int a[110000], b[110000];
int c[110000];
vint G[110000];
int ans[110000];
int cnt = 0;
void dfs(int idx, int par) {
    ans[idx] = c[cnt];
    cnt++;
    rep(i, G[idx].size()) {
        int cur = G[idx][i];
        if (cur == par) { continue; }
        dfs(cur, idx);
    }
}
signed main() {
    cin >> N;
    rep(i, N - 1) {
        cin >> a[i] >> b[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    rep(i, N) { cin >> c[i]; }
    sort(c, c + N), reverse(c, c + N);
    int sum = 0;
    for (int i = 1; i < N; i++) { sum += c[i]; }
    cout << sum << endl;
    dfs(1, 0);
    reps(i, N) { cout << ans[i] << " "; }
    cout << endl;
}


Measured memory_bytes: 4608
#!/usr/bin/env python3
n = int(input())
x_y = [list(input().split()) for _ in range(n)]
ans = 0
for i in range(n):
    if x_y[i][1] == "JPY":
        ans+=float(x_y[i][0])
    else:
        ans+=float(x_y[i][0])*380000
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <ctype.h>

int a2i(char a) {
	if(islower(a))return a-'a';
	if(isupper(a))return a-'A'+26;
	return 0;
}

char i2a(int i) {
	if(i<26)return i+'a';
	else return i-26+'A';
}

int main(void) {
	int n,i;
	int key[100];
	char s[200];
	while(scanf("%d",&n)==1 && n>0) {
		for(i=0;i<n;i++)scanf("%d",&key[i]);
		scanf("%s",s);
		for(i=0;s[i];i++) {
			putchar(i2a((a2i(s[i])-key[i%n]+52)%52));
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 576
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
my $tax = sub {
    my $num = shift;
    return int($num * 1.08);
};

for (my $i=$n; ; $i--) {
    my $ans = $tax->($i);
    if ($n==$ans) {
        print "$i\n";
        exit;
    } elsif ($n>$ans) {
        print ":(\n";
        exit;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int A, B, C;
  cin >> A >> B;
  C = max(A, B);
  int n;
  for (n = 1; n < C * 100; n++) {
    if (int(n * 0.08) == A && int(n * 0.1) == B) {
      cout << n << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N (200010)
typedef long long LL;
int a[N];
LL s[N];
int n;
LL abs(LL x){
    return x < 0 ? - x: x;
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d", a + i);
        s[i] = s[i - 1] + a[i];
    }
    LL ans = abs(s[n] - s[1] - s[1]);
    for (int i = 1; i < n; i++){
        if (abs(s[n] - s[i] - s[i]) < ans){
            ans = abs(s[n] - s[i] - s[i]);
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  i64 N;
  cin >> N;
  vector<i64> p(N);
  for(int i = 0;i < N;i++) { cin >> p[i]; p[i]--; }
  i64 ans = 0;
  for(int i = 0;i + 1 < N;i++) {
    if(p[i] == i) {
      swap(p[i], p[i + 1]);
      ans++;
    }
  }
  cout << ans + !!(p[N - 1] == N - 1) << endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    b=[0]*M
    for i in range(N):
        l=list(map(lambda x:int(x)-1,input().split()))
        for x in l[1:]:
            b[x]+=1
    ans=0
    for x in b:
        if x==N:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
	int a, b, t;
    cin >> a >> b >> t;
    int ans = t / a * b;
  	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
struct point{
	int v;
	point *l,*r,*pa;
	point(){l=r=pa=NULL;}
	point(int vv):v(vv){l=r=pa=NULL;}
};
point *root;
void insert(int v){
	point *p,*pa=NULL;
	p=root;
	while(p){
		pa=p;
		if(v>=p->v)p=p->r;
		else p=p->l;
	}
	if(!pa){root=new point(v);return;}
	if(v>=pa->v)pa->r=new point(v),pa->r->pa=pa;
	else pa->l=new point(v),pa->l->pa=pa;
}
point* find(int v){
	point *p=root;
	while(p){
		if(v>p->v)p=p->r;
		else if(v<p->v)p=p->l;
		else break;
	}return p;
}
point* nextp(point *p){
	if(!p->l)return p;
	else return nextp(p->l); 
}
void del(point *p){
	if(!p)return;
	point *pa=p->pa;
	if(!p->l&&!p->r){if(pa)p->v>=pa->v?(pa->r=NULL):(pa->l=NULL);}
	else if(p->l&&!p->r){if(pa)p->v>=pa->v?(pa->r=p->l):(pa->l=p->l),p->l->pa=pa;}
	else if(!p->l&&p->r){if(pa)p->v>=pa->v?(pa->r=p->r):(pa->l=p->r),p->r->pa=pa;}
	else{
		// 中序遍历该点的后一个节点（某个叶子）放过来 
		point *ne=nextp(p->r);
		p->v=ne->v;
		p=ne;
		p->v>=p->pa->v?(p->pa->r=NULL):(p->pa->l=NULL);
	}
	delete(p);
}
void dfs1(point *p){
	if(!p)return;
	dfs1(p->l);
	printf(" %d",p->v);
	dfs1(p->r);
}
void dfs2(point *p){
	if(!p)return;
	printf(" %d",p->v);
	dfs2(p->l);
	dfs2(p->r);
}
void print(){
	dfs1(root);printf("\n");
	dfs2(root);printf("\n");
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int T;cin>>T;
	string s;int vv;
	bool first=0;
	while(T--){
		cin>>s;
		if(s=="insert")cin>>vv,insert(vv);
		else if(s=="find")cin>>vv,(printf("%s\n",find(vv)?"yes":"no"));
		else if(s=="delete")cin>>vv,del(find(vv));
		else print();
	}
	return 0;
}


Measured memory_bytes: 21992
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int d[n];
    for(int i=0; i<n; i++)cin>>d[i];
    int r=0;
    for(int i=0; i<n-1; i++)
    {
    	for(int j=i+1; j<n; j++)
    	{
    		r+=(d[i]*d[j]);
		}
	}
	cout<<r<<endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans = 0
for i in range(len(A)):
  ans += B[A[i]-1]
  if i <= (N-1)-1 and A[i]+1 == A[i+1]:
    ans += C[A[i]-1]

print(ans)


Measured memory_bytes: 3064
from math import isinf

V, E = map(int, input().split())
d = [[float('inf') for i in range(V)] for j in range(V)]

for i in range(V):
    d[i][i] = 0
    
for i in range(E):
    s, t, w = map(int,input().split())
    d[s][t] = w
    
for k in range(V):
    for j in range(V):
        for i in range(V):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
            
for i in range(V):
    if d[i][i] < 0:
        print('NEGATIVE CYCLE')
        exit()

for di in d:
    print(' '.join( ('INF' if isinf(dij) else str(dij) for dij in di)))


Measured memory_bytes: 6480
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C = map(int, input().split())
    if A <= C <= B:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4196
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct N {
  int parent, left, right;
} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if( u == NIL ) return;
  D[u] = d;
  setDepth( T[u].left, d+1);
  setDepth( T[u].right, d+1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;
  if( T[u].left != NIL )
    h1 = setHeight(T[u].left) + 1;
  if( T[u].right != NIL )
    h2 = setHeight(T[u].right) + 1;
  return H[u] = ( h1 > h2 ? h1 : h2 );
}

int getSibling(int u){
  if( T[u].parent == NIL ) return NIL;
  if( T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if( T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if( T[u].left != NIL ) deg++;
  if( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if( T[u].parent == NIL ){
    printf("root\n");
  }
  else if( T[u].left == NIL && T[u].right == NIL ){
    printf("leaf\n");
  }
  else printf("internal node\n");
}

int main(){
  int i, v, l, r, root = 0;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ) T[i].parent = NIL;

  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if( l != NIL ) T[l].parent = v;
    if( r != NIL ) T[r].parent = v;
  }

  for( i = 0 ; i < n ; i++ ){
    if( T[i].parent == NIL ) root = i;
  }

  setDepth(root, 0);
  setHeight(root);

  for( i = 0 ; i < n ; i++ ) print(i);

  return 0;
}



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

#define DEBUG 0

void update(int x, int y);
int find(int index, int x, int y, int l, int r);
void initRMQ();
void printTree();

const int infinit = INT_MAX;
int n, q;
const int SIZE = 1000000;
int segmenttree[SIZE * 2 + 10];

int main() {

	cin >> n >> q;

	initRMQ();

	/*
	for (int i = 0; i < n * 2 - 1; ++i)
		segmenttree[i] = infinit;
	*/

#if DEBUG == 1
	printTree();
#endif


	for (int i = 0; i < q; ++i) {

		int com, x, y;

		cin >> com >> x >> y;

		switch (com) {
		case 0:
			update(x, y);
			break;

		case 1:
			cout << find(0, x, y + 1, 0, n) << endl;
			break;


		}


#if DEBUG == 1
		cout << com << " " << x << " " << y << endl;
		printTree();
#endif // DEBUG == 1


	}

	return 0;

}

void initRMQ() {

	int n_ = 2 * n - 1;
	n = 1;
	while (n < n_)
		n *= 2;
	for (int i = 0; i < 2 * n - 1; ++i)
		segmenttree[i] = infinit;


}

void update(int x, int y) {

	int i = x + n - 1;
	segmenttree[i] = y;

	while (i > 0) {
		i = (i - 1) / 2;
		segmenttree[i] = min(segmenttree[i * 2 + 1], segmenttree[i * 2 + 2]);

	}

}

int find(int index, int x, int y, int l, int r) {

	if (r <= x || y <= l) {
		return infinit;
	}
	else if (x <= l && r <= y) {
		return segmenttree[index];
	}
	else {
		int left = find(index * 2 + 1, x, y, l, (r + l) / 2);
		int right = find(index * 2 + 2, x, y, (r + l) / 2, r);
#if DEBUG == 1
		cout << "(r + l) / 2 = " << (r + l) / 2 << endl;
		cout << "r = " << r << endl;
		cout << "l = " << l << endl;
		cout << "index * 2 + 2 = " << index * 2 + 2 << endl;
		cout << "l = " << left << ", r = " << right << endl;
#endif
		return min(left, right);
	}

}

void printTree() {

	for (int i = 0; i < n * 2 - 1; ++i)
		cout << segmenttree[i] << " ";
	cout << endl << endl;

}


Measured memory_bytes: 5120