akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
int t,n;
char s[100010];
ll a[100010];
ll d[64];
bool add(ll x)
{
    for(int i=60; i>=0; i--)
    {
        if(x&(1ll<<i))
        {
            if(d[i])
            {
                x^=d[i];
            }
            else
            {
                d[i]=x;
                return true;
            }
        }
    }
    return false;
}
int main()
{
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=1; i<=n; i++)
        {
            cin>>a[i];
        }
        scanf("%s",s+1);
        bool ans=true;
        for(int i=1; i<=n; i++)
        {
            if(s[i]=='1')
            {
                memset(d,0,sizeof(d));
                for(int j=i+1; j<=n; j++)
                    if(s[j]=='0')
                        add(a[j]);
                if(add(a[i]))
                    ans=false;
            }

        }
        if(ans)
        {
            cout<<0<<endl;
        }
        else
        {
            cout<<1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3760
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector <ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    string s;
    cin >> s;
    bool good = false;
    vector <ll> ok(62, -1);
    for (int i = n - 1; i >= 0; i--) {
      ll x = a[i];
      for (int j = 0; j < 62; j++) {
        if ((x >> j) & 1) {
          if (ok[j] != -1) {
            x ^= ok[j];
          }
        }
      }
      if (!x) continue;
      if (s[i] == '0') {
        for (int j = 0; j < 62; j++) {
          if ((x >> j) & 1) {
            ok[j] = x;
            break;
          }
        }
      } else {
        good = true;
        break;
      }
    }
    cout << good << '\n';
  }
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n,d,x;

scanf("%d%d%d",&n,&d,&x);
int sum=x;
d--;
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=(d/a[i]);
sum++;
}
printf("%d",sum);
}

Measured memory_bytes: 256
n,m=map(int,input().split())
o=[list(map(int,input().split()))for i in range(m)]
for i in range(10**n):
    if len(str(i))==n and all(str(i)[j-1]==str(k) for j,k in o):
        print(i)
        break
else:print(-1)


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

using namespace std;

int main() {

    int n, m;
    long long res = 1;
    cin >> n >> m;
    int base = 1e9 + 7;

    if ( abs (n - m) > 1) {
            cout << 0 << '\n';
    }
        else
    {
        if (n == m) {
            res = 2;
        }

        for (int i = 1; i <= n; ++i) {
            res *= i;
            res = res % base;

        }
        for (int j = 1; j <= m; ++j) {
            res *= j;
            res = res % base;
        }

        cout << res << '\n';
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int solve(long long int num){
	long long int ret=0;
	for(long long int i=10;i<10000000;i*=10){
		ret=max(ret,(num/i)*(num%i));
	}
	return ret;
}

long long int q,n[105];
int main() {
	string s,t;
	cout << fixed << setprecision(18);
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>n[i];
	}
	for(int i=0;i<q;i++){
		long long int res=0;
		while(n[i]>=10){
			res++;
			n[i]=solve(n[i]);
		}
		cout<<res<<endl;
	}

} 


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int a, b, k;cin>>a>>b>>k;
  if((b-a+1)/2>=k){
    for(int i=a;i<a+k;i++)cout << i << endl;
    for(int i=b-k+1;i<=b;i++)cout << i << endl;
  }else{
    for(int i=a;i<=b;i++)cout << i << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n;
    cin >> n;
    vector<ll> vx(n), vy(n), vh(n);
    for (int i = 0; i < n; i++) {
        cin >> vx[i] >> vy[i] >> vh[i];
    }
    ll resx=-1, resy=-1, resh=-1;
    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
            ll h;
            for (int i = 0; i < n; i++) {
                if (vh[i] > 0) {
                    h = vh[i] + abs(vx[i] - x) + abs(vy[i] - y);
                    break;
                }
            }
            bool ok = true;
            for (int i = 0; i < n; i++) {
                if (vh[i] > 0 && vh[i] != h - abs(vx[i] - x) - abs(vy[i] - y)) ok = false;
                if (vh[i] == 0 && 0 < h - abs(vx[i] - x) - abs(vy[i] - y)) ok = false;
            }
            if (ok) {
                resx = x, resy = y, resh = h;
                cout << resx << " " << resy << " " << resh << endl;
                return 0;
            }
        }
    }
}


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

int main()
{
    int N, K, d, sum;
    sum = 0;
    cin >> N >> K;
    vector<int> sunuke(N), okasi(N);

    for (int i = 0; i < K; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> okasi.at(j);
            for (int l = 0; l < N; l++)
            {
                if (l == okasi.at(j)-1)
                {
                    sunuke.at(l)++;
                }
            }
        }
    }
    for (int a = 0; a < N; a++)
    {
        if (sunuke.at(a) == 0)
        {
            sum++;
        }
    }
    cout << sum << endl;
}


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

int main(){
  ll x;
  std::cin >> x;
  ll ans=x/500*1000;
  ans+=(x-x/500*500)/5*5;
  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	r, D, x := oneInt(), oneInt(), oneInt()

	for i := 0; i < 10; i++ {
		x = r*x - D
		fmt.Println(x)
	}

}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func scanNums(n int) (nums []int) {
	str := readLine()
	s := strings.Split(str, " ")
	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(s[i])
		nums = append(nums, num)
	}
	return nums
}

func scanStrings() []string {
	str := readLine()
	s := strings.Split(str, " ")

	return s
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

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

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main()
{
    ll n;
    ll q;
    cin >> n;
    vll S(n);
    rep(i,0,n) cin >> S[i];
    cin >> q;
    vll T(q);
    rep(i,0,q) cin >> T[i];
    ll s = 0;
    rep(i, 0, q) {
        if (binary_search(S.begin(), S.end(), T[i])) {
            ++s;
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 3716
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 1; i <= N - 1; i++) {
            sum += i;
        }

        System.out.println(sum);
        return;
    }

}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl;
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 114514810893364364;

int main() {
  Int n;
  cin >> n;
  vector<Int> cnt(26, INF);
  for (Int i = 0; i < n; i++) {
    string s;
    cin >> s;
    vector<Int> x(26, 0LL);
    for (Int j = 0; j < (Int)s.size(); j++) x[s[j] - 'a']++;
    for (Int j = 0; j < 26; j++) cnt[j] = min(cnt[j], x[j]);
  }
  for (Int i = 0; i < 26; i++) {
    if (cnt[i] == INF) continue;
    for (Int j = 0; j < cnt[i]; j++) {
      printf("%c", 'a' + i);
    }
  }
  cout << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int i;
    i = 1;
    int x;
    x = i;
    while(i <= n){
        x = i;
        if((x%3)==0){
            cout << " " << i;
        }
        else{
            if ( x % 10 == 3 ){
                    cout << " " << i;
                
            
            }
            else{
                x /= 10;
                if ( x ){
                    if ( x % 10 == 3 ){
                        cout << " " << i;
                    }
                    else{
                         x /= 10;
                    if ( x ){
                        if ( x % 10 == 3 ){
                            cout << " " << i;
                        }
                        else{
                         x /= 10;
                         if ( x ){
                            if ( x % 10 == 3 ){
                                cout << " " << i;
                            }
                         }
                        }
                    }
                    }
                    
                }
            }
            
            
            
        }
        i = i + 1;
    }
    cout << endl;
}
    


Measured memory_bytes: 3092
#include<stdio.h>
main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if ( a == b )
	printf("a == b\n", a, b);
	else if ( a < b )
	printf("a < b\n", a, b);
	else
	printf("a > b\n", a, b);

	
}



Measured memory_bytes: 2716
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int dp[n];

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1])
                  , dp[i-2] + abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
x, n = map(int, input().split())
p_list = [i for i in map(int, input().split())]
p_list.sort()
plus_count = 1
minus_count = -1
while True:
    m_p = x + minus_count in p_list
    p_p = x + plus_count in p_list
    if x not in p_list:
        print(x)
        break
    elif m_p is False:
        print(x + minus_count)
        break
    elif p_p is False:
        print(x + plus_count)
        break
    else:
        minus_count -= 1
        plus_count += 1


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

int yu(int m, int n){
  while(1){
    if(n == 0) return m;
    int tmp = m % n;
    m = n;
    n = tmp;
  }
}

int main(){
  long long n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;

  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
    string t2 = s;
    s = t;
    t = t2;
  }

  int l = yu(n, m);

  long long saisyou = (n * m) / l;

  for(int i = 0;i*(saisyou/m) < n;i++){
    if(s[i*(saisyou/m)] != t[i*(saisyou/n)]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << saisyou << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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 gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {

	char x, y;
	cin >> x >> y;

	if (x < y) { cout << "<"; }
	else if (x > y) { cout << ">"; }
	else { cout << "="; }

	system("PAUSE");

	

}


Measured memory_bytes: 504
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll a, b, c, d, ans;
ll lcm(ll a, ll b){
    return a * b / __gcd(a, b);
}
ll count(ll l, ll r, ll x){
    if(l % x) l += (x - (l % x));
    if(r % x) r -= (r % x);
    return (r / x) - (l / x) + 1;
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> a >> b >> c >> d;
    ans += count(a, b, c);
    ans += count(a, b, d);
    ans -= count(a, b, lcm(c, d));
    cout << b - a + 1 - ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            int C = scanner.nextInt();
            int[] array = new int[N];
            for (int i = 0; i < N; i++) {
                array[i] = scanner.nextInt();
            }
            System.out.println(recurse(0, 0, 0, A, B, C, array, 0));
        }
    }

    static int recurse(int lenA, int lenB, int lenC, int a, int b, int c, int[] array, int pos) {
        if (pos == array.length) {
            if (Math.min(Math.min(lenA, lenB), lenC) > 0) {
                return Math.abs(lenA - a) + Math.abs(lenB - b) + Math.abs(lenC - c) - 30;
            } else {
                return Integer.MAX_VALUE - 100000;
            }
        }
        int ret1 = recurse(lenA, lenB, lenC, a, b, c, array, pos + 1);
        int ret2 = recurse(lenA + array[pos], lenB, lenC, a, b, c, array, pos + 1) + 10;
        int ret3 = recurse(lenA, lenB + array[pos], lenC, a, b, c, array, pos + 1) + 10;
        int ret4 = recurse(lenA , lenB, lenC+ array[pos], a, b, c, array, pos + 1) + 10;
        return Math.min(ret1, Math.min(ret2, Math.min(ret3, ret4)));
    }
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll a,b,c; cin>>a>>b>>c;
    if(a+b+1 >= c) cout << b+c << endl;
    else cout << b+a+b+1 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int a, b;
	cin >> a >> b;
	int sum = 0;
	for(int i = 1; i <= b-a; i++) {
		sum += i;
	}
	cout << sum - b << endl;
}

Measured memory_bytes: 256
package main

import ("fmt")

func main() {
    var a, b, c, x int
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Scan(&c)
    fmt.Scan(&x)

    ways := 0
    for i := 0; i < a + 1; i++ {
        if 500 * i > x {
            break;
        }
        for j := 0; j < b + 1; j++ {
            tmp := 500 * i + 100 * j
            if tmp > x {
                break;
            }
            if (x - tmp) % 50 == 0 && (x - tmp) / 50 <= c {
                ways++
            }
        }
    }

    fmt.Println(ways)
}

Measured memory_bytes: 512
#include <stdio.h>

int main(int argc,char* argv[]){
  
  double rank[7][2] =
    {
      {35.50,        1*60 + 11.00},
      {37.50,        1*60 + 17.00},
      {40.00,        1*60 + 23.00},
      {43.00,        1*60 + 29.00},
      {50.00,        1*60 + 45.00},
      {55.00,        1*60 + 56.00},
      {1*60 + 10.00, 2*60 + 28.00}
    };

  char* rank_s[8] = {"AAA","AA","A","B","C","D","E","NA"};
  
  double h_time,t_h_time;

  while(scanf("%lf %lf",&h_time,&t_h_time) != EOF){
    int i;
    for(i = 0; i < 7; i++){
      if(rank[i][0] > h_time && rank[i][1] > t_h_time){
	break;
      }
    } 
    
    printf("%s\n",rank_s[i]);

  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,m,a[200000],b[200000],A[200000],B[200000],cnt=1,dp[200000][4],BIT[200001],L,bik[200001],ans,MOD;
vector<P> v;
void BITadd(ll a,ll b){
    while(a){
        BIT[a]+=b;
        a-=a&(-a);
    }
    return ;
}
ll BITsum(ll a){
    ll tot=0;
    while(a<=200000){
        tot+=BIT[a];
        a+=a&(-a);
    }
    return tot;
}
int main(void){
    cin>>n;
    MOD=998244353;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        A[i]=a[i],B[i]=b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    map<ll,ll> mp;
    for(int i=0;i<n;i++)mp[a[i]]=cnt++;
    map<ll,ll> mp2;
    cnt=1;
    for(int i=0;i<n;i++)mp2[b[i]]=cnt++;
    for(int i=0;i<n;i++){
        A[i]=mp[A[i]];
        B[i]=mp2[B[i]];
        v.push_back({A[i],B[i]});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        L=BITsum(v[i].second);
        dp[i][3]=L;
        dp[i][2]=i-L;
        BITadd(v[i].second,1);
    }
    for(int i=0;i<=200000;i++)BIT[i]=0;
    reverse(v.begin(),v.end());
    for(int i=0;i<n;i++){
        L=BITsum(v[i].second);
        dp[n-i-1][1]=L;
        dp[n-i-1][0]=i-L;
        BITadd(v[i].second,1);
    }
    bik[0]=1;
    for(int i=1;i<200001;i++){
        bik[i]=bik[i-1]*2%MOD;
    }
    ans=n*bik[n-1]%MOD;
    for(int i=0;i<n;i++){
        ans+=(bik[dp[i][0]]-1)*(bik[dp[i][1]]-1)%MOD*(bik[dp[i][2]]-1)%MOD*(bik[dp[i][3]]-1)%MOD;
        ans%=MOD;
        ans+=(bik[dp[i][0]]-1)*(bik[dp[i][3]]-1)%MOD*((bik[dp[i][1]]+bik[dp[i][2]]-1)%MOD);
        ans%=MOD;
        ans+=(bik[dp[i][1]]-1)*(bik[dp[i][2]]-1)%MOD*((bik[dp[i][0]]+bik[dp[i][3]]-1)%MOD);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 45040
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int A, B, C, D; cin >> A >> B >> C >> D;

    int ans = min(A, B) + min(C, D);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	while(true){
	int joi=0,ioi=0;
	string str;
	cin >> str;
	if(str.size()==0)
	break;
	for(int i=0;i<str.size()-2;i++){
		if(str[i+1]=='O'&&str[i+2]=='I'){
		if(str[i]=='J')
			joi++;
		if(str[i]=='I')
			ioi++;
		}
	}
	cout << joi << endl << ioi << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int n,t;
int main(){
    int a[3];
    for(int i=0; i<3; i++){
        cin >> a[i];
    }
    sort(a,a+3);
    cout << a[2]*10+a[1]+a[0] << endl;
}


Measured memory_bytes: 256
s=list(input())

maru = 0
batu = 0
for i in range(len(s)):
  if s[i] == "o":
    maru = maru + 1
  else:
    batu = batu + 1
if 15 - maru - batu >= 8 - maru:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int A = Int ();
        int B = Int ();

        if (A >= 10) {
            Console.WriteLine (-1);
            return;
        }

        if (B >= 10) {
            Console.WriteLine (-1);
            return;
        }

        Console.WriteLine (A * B);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

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

int main() {
	int n, x; 
	while (cin >> n >> x, n) {
		int cnt = 0;
		for (int i = 1; i <= n; i++)
			for (int j = i + 1; j <= n; j++)
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x)cnt++;
				}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3084
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	a, b, c := sc.nextInt(), sc.nextInt(), sc.nextInt()
	if a+b == c || a+c == b || b+c == a {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}

	wtr.Flush()
}


Measured memory_bytes: 640
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math;

void main()
{
    auto n = readln.chomp.to!int;
    auto DP = new long[](n+1);
    DP[0] = 1;
    DP[1] = 1;
    foreach (i; 2..n+1) {
        DP[i] = DP[i-1] + DP[i-2];
    }
    writeln(DP[n]);
}


Measured memory_bytes: 2468
#include <bits/stdc++.h>
#define N 200005

using namespace std;

int n, K;
int a[N];

int main() {
	scanf("%d %d", &K, &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	int ans = K;
	a[0] = a[n] - K;
	for(int i = 1; i <= n; ++i)
		ans = min(ans, K - (a[i] - a[i - 1]));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

#define MAX 200001
#define MIN pow(-10.0, 9.0)

int main(){
    int n, R[MAX], minv, maxv;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> R[i];
    }
    
    minv = R[0];
    maxv = MIN;
    for (int i = 1; i < n; i++){
        maxv = max(maxv, ( R[i] - minv ));
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3868
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, x; cin >> n >> x;
    vector<int> loc(n);
    REP(i, n) cin >> loc[i];
    int d = 0, count = 1, i = 0;
    while(d <= x){
        d += loc[i];
        if(d <= x) count++;
        i++;
        if(i > n - 1) break;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
r = 0
l = 0
for s in S:
	if s == "(":
		l += 1
	else:
		if l == 0:
			r += 1
		else:
			l -= 1
r2 = 0
l2 = 0
for s in S[::-1]:
	if s == ")":
		r2 += 1
	else:
		if r2 == 0:
			l2 += 1
		else:
			r2 -= 1
S = ["("] * r + S + [")"] * l
print("".join(S))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
int even(ll &n) {
	int count = 0;
	while (n > 0) {
		if (n % 2 == 0) {
			count++;
			n /= 2;
		}
		else {
			break;
		}
		//cout << n << endl;
	}
	return count;
}

int main() {
	int n;
	scanf("%d",& n);
	int ans = 0;
	rep(i, n) {
		ll a;
		cin >> a;
		ans += even(a);
	}
	cout << ans << endl;

}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+10, 0);
    for (int i = 1; i <= n; i++) cin >> a[i];
    vector<int> putted(n+10, 0);
    for (int i = n; i >= 1; i--) {
        int sum_temp = 0;
        for (int j = i + i; j <= n; j += i) sum_temp += putted[j];
        putted[i] = (a[i] + sum_temp) % 2;
    }
    int m = count(putted.begin(), putted.end(), 1);
    if (m == 0) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> ans;
    cout << m << endl;
    for (int i = 1; i <= n; i++) if (putted[i]) ans.push_back(i);
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if (i < ans.size() - 1) cout << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5344
n = int(input())
a = list(map(int,input().split()))
c = 0
flag = True
 
while flag:
    for i in range(n):
        if a[i] % 2 != 0:
            flag = False
            break
        else:
            a[i] /= 2
    c += 1
 
print(c-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s,t; cin>>s>>t;
    sort(ALL(s));
    sort(ALL(t)); reverse(ALL(t));

    cout<<(s<t? "Yes":"No")<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
	int ans, n, k;

  ans = 0;
  cin>>n;
  	for(int i = 0; i<n; i++){
      cin>>k;
      if((i&1)==0){
      	if((k&1)==1) ans++;
      }
    }
  	cout<<ans;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll inf = 1001001001;

int main() {
  ll n;
  cin >> n;
  vector<vl> g(n, vl(n));
  vector<vb> e(n, vb(n, true));
  bool ok = true;
  rep(i, n) rep(j, n) cin >> g[i][j];
  rep(k, n) rep(i, n) rep(j, n) {
    if(k == i || k == j) continue;
    ll now = g[i][k] + g[k][j];
    if(g[i][j] > now)
      ok = false;
    else if(g[i][j] == now) {
      e[i][j] = false;
      e[j][i] = false;
    }
  }
  ll ans = 0;
  if(ok) {
    rep(i, n - 1) rep2(j, i + 1, n) if(e[i][j]) ans += g[i][j];
    cout << ans << endl;

  } else
    cout << -1 << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i, n) for(int i = 0; i < (n); ++i)
const ll mod = 1e9 + 7;

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

bool pairCompare(const P &firstElof, const P &secondElof) {
    return firstElof.second < secondElof.second;
}

int main() {
    ll a, b, c, k;
    ll ans = 0;
    cin >> a >> b >> c >> k;

    if(k < a) {
        ans = k;
    } else if(k < a + b) {
        ans = a;
    } else {
        ans = a - (k - a - b);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
import java.io.*;
class Main{
    public static void main(String[] args)throws IOException{
	BufferedReader br =
	    new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(br.readLine());
	for(int i=0;i<n;i++){
	    String buf = br.readLine();
	    System.out.println(buf.replaceAll("Hoshino","Hoshina"));
	}
    }
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod=1e+9+7;
long long x,y;
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;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    cin>>x>>y;
    long long n,m;
    if((2*x-y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    n=(2*x-y)/3;
    m=x-2*n;
    if(n<0||m<0){
        cout<<0<<endl;
        return 0;
    }
    combination c(m+n);
    mint ans=c(m+n,n);
    cout<<ans.x<<endl;
}


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

int main(){
  int M;
  cin >> M;
  cout <<24 + 24 - M << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N,i,j,v,w;
    scanf("%d",&N);
    int A[N];
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(i=0;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(w=0;w<N;w++){
            printf("%d",A[w]);
            if(w<N-1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<string>
#define qw() freopen("in.txt","r",stdin)
#define er() freopen("out.txt","w",stdout)
using namespace std;
int v[100005];
int main(void)
{
    int n;
    while(~scanf("%d",&n))
    {
        int a=0;
        int b=0;
        int c=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&v[i]);
            if(v[i]%4==0) a++;
            else
            {
                if(v[i]%2==0)b++;
                else c++;
            }
        }
        int x;
        if(b!=0)x=n-b+1;
        else x=n;
        if(a>=x/2)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;
int f0070(vi A,int n,int s){
	int b1=0,b2=0,c=0,j=1,i,tmp,a=A.size();
	vi::iterator it1=A.begin(),it2=it1+a;
	if(n==1)return(find(it1,it2,s)==it2)?0:1;
	sort(it1,it2);
	it1+=n-1;
	it2-=n;
	for(i=0;i<n;i++){
		b1+=j*(*it1--);
		b2+=j*(*it2++);
		j++;
	}
	if(b1<=s&&s<=b2)
		for(i=0;i<a;i++){
			tmp=s-A[i]*n;
			if(tmp<0)break;
			vi A3(A);
			A3.erase(A3.begin()+i);
			c+=f0070(A3,n-1,tmp);
	}
	return c;
}
int main(){
	int n,s,i;
	vi A(10);
	for(i=0;i<10;A[i]=i++);
	while(1){
		cin>>n>>s;
		if(cin.eof())break;
		cout<<f0070(A,n,s)<<endl;
	}
}

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

int main(void){
  int N;
  cin >> N;
  if(N == 1){
    cout << "Hello World" << "\n";
  }
  else if(N == 2){
    int A, B;
    cin >> A >> B;
    cout << A + B << "\n";
  }
  return 0;
}


Measured memory_bytes: 3580
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
void dfs(vvi &root, vi &ans, int pos, vi &check){
  check[pos] = 1;
  for(int x : root[pos]){
    if(!check[x]){
      ans[x] += ans[pos];
      dfs(root, ans, x, check);
    }
  }
}
int main(){
  int n,q;
  cin >> n >> q;
  vvi root(n);
  vi ans(n);
  rep(i, n - 1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    root[a].push_back(b);
    root[b].push_back(a);
  }
  rep(i, q){
    ll p,x;
    cin >> p >> x;
    ans[p - 1] += x;
  }
  vi check(n, 0);
  dfs(root, ans, 0, check);
  rep(i, n - 1) cout << ans[i] << " ";
  cout << ans[n - 1] << endl;
}

Measured memory_bytes: 28268
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int n;
	scanf("%d", &n);
	printf("%d\n", (n - 1) / 2);
	return 0;
}

/* waffle */


Measured memory_bytes: 128
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<iostream>
#include<vector>
#define MAXN 1000
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	//freopen("../in", "r", stdin);
	//freopen("../out", "w", stdout);
	ll n;
	cin>>n;
	if(n%2==0)
		cout<<1.0/2<<endl;
	else
		cout<<(n+1)/2.0/n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>v[200005];
int main()
{
    long int n,a;
    cin>>n;
    int h[n+5];
    for(int i=0;i<n;i++) {
        cin>>h[i];
    }
    vector<int>dp(n,1e9+5);
    dp[0] = 0;
    for(int i=0;i<n;i++)
    for(int j:{i+1,i+2}){
            if(j<n){
                dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); ++i) {
		if (n % i == 0) {
			return false;
		}
	}

	return true;
}

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

	int y = x;
	while (!prime(y)) {
		++y;
	}

	cout << y;
	
	return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
double ax,ay,bx,by,cx,cy,a,b,c,s,r;
main()
{
	cin>>ax>>ay>>bx>>by>>cx>>cy;
	a=hypot(ax-bx,ay-by);
	b=hypot(bx-cx,by-cy);
	c=hypot(cx-ax,cy-ay);
	s=sqrt((a+b+c)*(a+b-c)*(a-b+c)*(-a+b+c)/16);
	r=2*s/(a+b+c);
	a=max({a,b,c});
	cout<<fixed<<setprecision(15)<<a/(2+a/r)<<endl;
}


Measured memory_bytes: 256
n = gets.chomp
p_array = gets.chomp.split.map(&:to_i)
count = 0
for i in 0.. p_array.length - 3
  min_2_number = [p_array[i], p_array[i+1], p_array[i+2]].sort[1]
  if min_2_number == p_array[i+1]
    count += 1
  end
end
print("#{count}\n")


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, b;
    cin >> a >> b;
    cout << setprecision(20) << a / b << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python

import sys

def next(values):
    if values[0] > 0:
        values[0]

def main(argv):
    line = sys.stdin.readline()
    while line:
        N, Y = map(lambda i: int(i), line.rstrip("\n").split(" "))

        values = [-1, -1, -1]
        n = Y / 1000
        for i in xrange(int(n / 5) + 1):
            for j in xrange(int(i / 2) + 1):
                if (j + i - 2 * j + n - 5 * i) == N:
                    values = [j, i - 2 * j, n - 5 * i]
                    break

        print " ".join([str(v) for v in values])

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2692
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 2e5 + 5;
int t;

int main()
{
	string a;
	while (cin >> a)
	{
		int tt = a.size();
		if (tt == 6 && a[2] == a[3] && a[4] == a[5])puts("Yes");
		else puts("No");
	}
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>

#define mod 1000000007

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", a + b + c - std::max(std::max(a, b), c));

	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x,cnt = 0;
	cin >> n;
	for (int i = 1;i <= n;++i) {
		cin >> x;
		if (x&1 && i&1) {
			++cnt;
		}
	}
	cout << cnt << '\n';
	return 0;
}



Measured memory_bytes: 3600