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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  long N,M;
  cin>>N>>M;
    // 前処理
    COMinit();

    long ans=1;
    map<long,long> m;
    for(int i=2;i*i<=M;i++){
      while(M%i==0){
        m[i]++;
        M/=i;
      }
    }
    if(M>1) m[M]++;
    for (const auto& [i, j] : m){
        ans*=COM(N-1+j,j);
        ans%=MOD;
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main(void){
  int n,m;
  vector<int> cnt;
  cin >> n >> m;
  cnt = vector<int>(n);
  for (int i=0; i<m; i++){
    int u,v;
    cin >> u >> v;
    cnt[u-1]++;
    cnt[v-1]++;
  }
  for (int i=0; i<n; i++){
    cout << cnt[i] << endl;
  }
  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,t;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>s>>t;
      if(Size(s)!=Size(t)){
        if(Size(s)>Size(t))Cout("GREATER");
        else Cout("LESS");
      }
      else{
        rep(i,Size(s)){
          cmp=s[i]-'0';
          cmpp=t[i]-'0';
          if(cmp>cmpp)Cout("GREATER"),fl=false;
          else if(cmp<cmpp)Cout("LESS"),fl=false;
          if(!fl)return 0;
        }
        Cout("EQUAL");
      }
     

       
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	int N, X;  cin >> N >> X;
	vi a(N); FOR(i, 0, N) cin >> a[i];
	
	ll cnt = 0;
	if (a[0] > X) {
		cnt += a[0] - X;
		a[0] = X;
	}

	FOR(i, 0, N - 1) {
		ll dif = a[i] + a[i + 1] - X;
		if (dif <= 0) continue;

		if (a[i + 1] >= dif) {
			a[i + 1] -= dif;
		}
		else {
			int t = a[i + 1];
			a[i+1] = 0;
			a[i] -= (dif - t);
		}		
		cnt += dif;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn =1e5+13;

int dp[maxn];
int main()
{
	int n;
    ll ans=0; 
	scanf("%d",&n); 
	for(int i=1;i<=n-1;i++)
	{
		ans+=(n%i==0?n/i-1:n/i);
	}
	printf("%d",ans);
 } 

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

int main() {
  int k = 0;
  int i;
  char s[1000];

    scanf("%s",s);
      if(s[2] == s[3]) {
        k = 1;
    } else {
      k = 0;
    }

    if(s[4] == s[5]) {
      k += 1;
    } else {
      k = 0;
    }

  if(k == 2) {
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
}


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

int main () {
  int N,K;
  cin >> N;
  vector<int> data(N);
  for (int i=0; i<N; i++){
    cin >> data[i];
  }
  sort(data.begin(),data.end());
  K = N/2;
  cout << data[K] - data[K-1] << endl;

}

Measured memory_bytes: 3744
# coding: utf-8
import itertools

i = int(input())
p = tuple(int(i) for i in input().split())
q = tuple(int(i) for i in input().split())

permn = list(itertools.permutations(range(1, i+1), i))

print(abs(permn.index(p) - permn.index(q)))

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

const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


long long sum(long long l,long long r){
    return (l+r)*(r-l+1)/2;
}
int N,K;
int main(){
    cin>>N>>K;
    mint ans;
    for(int i=K;i<=N+1;i++)ans+=sum(N-i+1,N)-sum(0,i-1)+1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
package main

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

func main() {
	N := sc.nextFloat()
	NSqrt := math.Sqrt(N)
	min := math.Pow10(12)
	for i := float64(1); i <= NSqrt; i++ {
		if int64(N)%int64(i) == 0 {
			j := N / i
			if min > i+j {
				min = i + j
			}
		}
	}
	fmt.Println(int64(min - 2))
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
    d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?Z[a]>Z[n]?n=b,b=f,K(n):M(O[f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(n=0);Z[a=H[P[n]]-n?n:0];*Z=++n)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

using namespace std;

int main()
{
    long long a,b,r,k=1;

    cin>>a>>b;

    long long nr=__gcd(a,b);
    for(long long i=2;i*i<=nr;i++)
    {
        if(nr%i==0)
        {
            k++;
            while(nr%i==0)
                nr/=i;
        }
    }

    if(nr!=1)
        k++;

    cout<<k;
    return 0;
}


Measured memory_bytes: 256
//arc092_d.cpp
//Mon Jan 27 11:24:03 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	vector<ll> a,b;
	a.resize(n);
	b.resize(n);
	for (int i=0;i<n;i++){
		cin >> a[i];
	}
	for (int i=0;i<n;i++){
		cin >> b[i];
	}

	ll ans = 0;
	for (int i=29;i>=0;i--){
		ll bekihigh = 1<<(i+1);
		ll bekilow = 1<<i;
		for (int j=0;j<n;j++){
			a[j] = a[j]%bekihigh;
			b[j] = b[j]%bekihigh;
		}
		sort(b.begin(),b.end());
		ll keta = 0;
		for (int j=0;j<n;j++){
			if (bekilow-a[j]>=0){
				keta += lower_bound(b.begin(),b.end(),bekihigh-a[j])
						- lower_bound(b.begin(),b.end(),bekilow-a[j]);
			}else {
				keta += lower_bound(b.begin(),b.end(),bekihigh-a[j])-b.begin();
				keta += lower_bound(b.begin(),b.end(),bekihigh)
						- lower_bound(b.begin(),b.end(),bekihigh+bekilow-a[j]);
			}
		}
		if (keta%2==1){
			ans += bekilow;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3328
#include<stdio.h>
 
#define H 250
 
int main(int argc,char *argv[])
{
    int heap[H+1];
    int i, j;
 
    scanf("%d", &i);
    for(j = 1; j <= i; j++){
        scanf("%d", &heap[j]);
    }
 
    for(j = 1; j <= i; j++){
        printf("node %d: key = %d, ", j, heap[j]);
        if(0 < (j / 2)){
            printf("parent key = %d, ", heap[j / 2]);
        }
        if((2 * j) <= i){
            printf("left key = %d, ", heap[2 * j]);
        }
        if((2 * j + 1) <= i){
            printf("right key = %d, ", heap[2 * j + 1]);
        }
        printf("\n");
    }
 
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = unsigned long long;
using Graph = vector<vector<int>>;

int main(){
    ll N; cin>>N;
    ll s = 26, len = 1;
    while(N>s){
        N -= s;
        s *= 26;
        len++;
    }
    //Nを26進数で表す
    vector<ll> v;
    N--;
    while(N){
        v.push_back(N%26);
        N /= 26;
    }
    while(v.size()!=len)v.push_back(0);
    reverse(v.begin(),v.end());
    rep(i,v.size())cout<<char('a'+v.at(i));
    cout<<endl;
}

Measured memory_bytes: 3596
def main():
    def cmb(n, r, mod):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7  # 出力の制限
    N = 10**6
    g1 = [1, 1]  # 元テーブル
    g2 = [1, 1]  # 逆元テーブル
    inverse = [0, 1]  # 逆元テーブル計算用テーブル

    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    H, W, A, B = map(int, input().split())

    ans = cmb((H+W-2), min(H, W)-1, mod)

    tmp = 0
    for i in range(B):
        t = cmb(H-A-1+i, i, mod)
        t *= cmb(W-1-i + A - 1, A-1, mod)
        tmp += t
        tmp %= mod
    print((ans - tmp) % mod)


main()


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

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int l = max(x, max(y, z));
	int sum = x + y + z;
	int res;
	if(sum % 2 == (3 * l) % 2) res = 3 * l;
	else res = 3 * (l + 1);
	cout << (res - sum) / 2;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>	

int main(){

 int i,h,max1,max2,max3;


 scanf("%d",&h);
  max1 = h;
 
 scanf("%d",&h);
 if(h>max1){
 max2 = max1;
 max1 = h;
 }else{
 	max2 = h;
 }
 
 scanf("%d",&h);
  if(h>max1){
  	max3 = max2;
  	max2 = max1;
  	max1 = h;
  }else if(max1>h>max2){
  	max3 = max2;
  	max2 = h;
  }
  else{
  	max3 = h;
  }
  
  for(i=0;i<7;i++){
 	 scanf("%d",&h);
 	if(h>max1){
 		max3 = max2;
 		max2 = max1;
 		max1 = h;
 	}else if(h>max2){
 		max3 = max2;
 		max2 = h;
 	}else if(h>max3){
 		max3 = h;
 	}
 	else{
 		;
 	}
 }
 
 printf("%d\n",max1);
 printf("%d\n",max2);
 printf("%d\n",max3);


 
 return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
            string[] S = Input.ScanStrArray();
          S[0]=new string(new char[]{S[0][0]}).ToUpper();
S[1]=new string(new char[]{S[1][0]}).ToUpper();
S[2]=new string(new char[]{S[2][0]}).ToUpper();
Console.WriteLine(S[0]+S[1]+S[2]);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string S;
  cin >> S;
  bool bl = true;
  string T = S;
  reverse(T.begin(), T.end());
  if (S != T) bl = false;
  int right = sz(S) / 2 - 1;
  for (int i = 0; i < right; i++) {
    if (S[i] != S[right-i]) bl = false;
  }
  puts(bl ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3636
PROGRAM abc152b
      IMPLICIT NONE
      integer(16) :: a,b,mi,ma,i,ans = 0
      read*,a,b
      ma = min( a,b )
      mi = max( a,b )
      
      do i = 1,mi
        ans = ans + ma*10**(i-1)
      end do
      
      print*,ans
      
      
      
      
      
      
      END PROGRAM

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 500;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

int main()
{
	char c;
	double a, b;
	vector< pair< double, double > > vpf;
	while( cin >> a >> c >> b ){
		if( cin.eof() ) break;
		vpf.push_back( MP( a, b ) );
	}
	
	pair< double, double > root = vpf[0];

	int pos = 2;
	double ans = 0.0;
	while( pos < vpf.size()){
		double a = sqrt( 
			(vpf[pos].X - root.X) * (vpf[pos].X - root.X) + 
			(vpf[pos].Y - root.Y) * (vpf[pos].Y - root.Y) );

		double b = sqrt( 
			(vpf[pos - 1].X - root.X) * (vpf[pos - 1].X - root.X) + 
			(vpf[pos - 1].Y - root.Y) * (vpf[pos - 1].Y - root.Y) );

		double c = sqrt( 
			(vpf[pos].X - vpf[pos - 1].X) * (vpf[pos].X - vpf[pos - 1].X) + 
			(vpf[pos].Y - vpf[pos - 1].Y) * (vpf[pos].Y - vpf[pos - 1].Y) );

		ans += sqrt( (a + b + c) * (-a + b + c) * (a + -b + c) * (a + b + -c) ) /  4.0;	//ヘロンの公式.
		++pos;
	}

	printf("%0.6f\n", ans);
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
char s1[50][50],s2[50][50];
int main(){
  fast();
  int n , m;
  cin>>n>>m;
  for(int i=0;i<n;++i)
     for(int j=0;j<n;++j)
       cin>>s1[i][j];
  for(int i=0;i<m;++i)
     for(int j=0;j<m;++j)
       cin>>s2[i][j];
  bool f =true;
  for(int x=0;x<n-m+1;++x){
    for(int y=0;y<n-m+1;++y){
             f=true;
        for(int i=0;i<m;++i){
        for(int j=0;j<m;++j){
           if(s1[i+x][j+y]!=s2[i][j])  {
              f=false;
           }
         if(f==false)
            break;
        }
       if(f==false)
            break;
      }
      if(f==true){
      cout<<"Yes"<<endl;
      return 0;
    }
    }
  }
 cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int N, M;
vector<vector<int>> to(100005);


int main()
{
	cin >> N >> M;
	vector<int> H(N);
	rep(i, N)cin >> H[i];
	rep(i, M)
	{
		int A, B;
		cin >> A >> B;
		--A; --B;
		to[A].push_back(B);
		to[B].push_back(A);
	}
	int count = 0;
	rep(i, N)
	{
		int d = to[i].size();
		if (d == 0)  count++;
		else
		{
			bool highest = true;
			for (int u : to[i])
			{
				if (H[i] <= H[u]) highest = false;				
			}
			if (highest == true) count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

#define MAX 200010

ll mod = 1000000007LL;

long long extgcd(long long a,long long b,long long& x,long long& y) {
  long long d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m) {
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

const int MAXnCk = MAX;
ll fact[MAXnCk+1], fact_inv[MAXnCk+1];
void init_nCk(){
  fact[0] = fact_inv[0] = 1;
  REP(i,1,MAXnCk+1) {
    fact[i] = fact[i-1] * (ll)i % mod;
    fact_inv[i] = mod_inv(fact[i],mod);
  }
}

ll nCk(ll n,ll k){
  if( n < 0 || k < 0 || k > n ) return 0LL;
  if( n-k < k ) k = n-k;
  return fact_inv[k] * fact[n] % mod * fact_inv[n-k] % mod;
}

int N;
vector<int> G[MAX];

ii val[MAX]; // ii(# of nodes, comb)

const bool debug = 0;

ii dfs(int cur,int pre) {
  ii &v = val[cur];
  if( v.fst != -1 ) return v;
  v.fst = 0, v.snd = 1;
  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i];
    if( nex == pre ) continue;
    ii w = dfs(nex,cur);
    v.snd = ( ( ( v.snd * w.snd ) % mod ) * nCk(v.fst+w.fst,w.fst) ) % mod;
    v.fst += w.fst;
  }
  ++v.fst;
  return v;
}

ii answer[MAX];
void dfs2(int cur, int pre, ii d_par) {
  vector<ii> vL, vR;
  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i];
    ii w = ( nex == pre ) ? d_par : val[nex];
    vL.pb(w);
    vR.pb(w);
  }
  REP(i,1,(int)vL.size()) {
    ii v = vL[i], w = vL[i-1];
    v.snd = ( ( ( v.snd * w.snd ) % mod ) * nCk(v.fst+w.fst,w.fst) ) % mod;
    v.fst += w.fst;
    vL[i] = v;
  }
  for(int i=(int)vR.size()-2;i>=0;--i) {
    ii v = vR[i], w = vR[i+1];
    v.snd = ( ( ( v.snd * w.snd ) % mod ) * nCk(v.fst+w.fst,w.fst) ) % mod;
    v.fst += w.fst;
    vR[i] = v;
  }
  answer[cur] = vL.back();
  ++answer[cur].fst;

  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i];
    if( nex == pre ) continue;
    ii l = (i-1>=0) ? vL[i-1] : ii(0,1);
    ii r = (i+1<(int)G[cur].size()) ? vR[i+1] : ii(0,1);
    ii tmp = ii(l.fst+r.fst+1,
		(((l.snd*r.snd)%mod) * nCk(l.fst+r.fst,r.fst))%mod);
    dfs2(nex,cur,tmp);
  }
}

void solve() {
  rep(i,N) val[i] = ii(-1,-1);
  dfs(0,-1);
  if( debug ) {
    rep(i,N) {
      cout << "*" << i << "-th: (" << val[i].fst << ", " << val[i].snd << ")" << endl;
    }
  }
  dfs2(0,-1,ii(0,1));
  rep(i,N) {
    cout << answer[i].snd << endl;
  }
}

int main() {
  init_nCk();
  cin >> N;
  int a,b;
  rep(i,N-1) {
    cin >> a >> b;
    --a, --b;
    G[a].pb(b);
    G[b].pb(a);
  }
  solve();
  return 0;
}


Measured memory_bytes: 28308
#include <cstdio>
#define LL long long 
LL x;

int main() {
	scanf ( "%lld", &x );
	for ( LL i = -200;i <= 200;i ++ )
		for ( LL j = -200;j <= 200;j ++ ) {
			LL temp1 = i * i * i * i * i;
			LL temp2 = j * j * j * j * j;
			if ( temp1 - temp2 == x )
				return ! printf ( "%lld %lld", i, j );
		}
	return 0;
}

Measured memory_bytes: 3252
#include <stdio.h>
int main(void){
    int h, n, i, a[1000000];
    
    scanf("%d%d",&h, &n);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
       
    for(i=1;i<=n;i++) h=h-a[i];
    
    if(h<=0) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
    ll X;
    cin >> X;
    ll N = X;
    REP(i, N + 1){
        X -= i;
        if(X <= 0){
            print(i);
            return 0;
        }
    }
}

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

using namespace std;


int main() {
	int n;
	string s;
	cin >> n >> s;
	int p = 0, no = 0;
	string ans = "";
	for (int i = 0; i < n; i++) {
		if (s[i] == ')') {
			no--;
		}
		else {
			no++;
		}
		if (p > no) {
			p = no;
		}
		ans.push_back(s[i]);
	}
	for (int i = 0; i < no - p; i++) {
		ans.push_back(')');
	}
	no = 0;
	string bans = "";
	for (int i = 0; i < -p; i++) {
		bans.push_back('(');
	}
	cout << bans << ans << endl;
//	cin >> n;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,W,w[100],v[100],w1;
	int dp[101][101][301] = {};
	cin >> n >> W;
	for(int i = 0;i < n;i++){
		cin >> w[i] >> v[i];
		if(!i) w1 = w[i];
		w[i] -= w1;
	}
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= n;j++){
			for(int k = 0;k <= 300;k++){
				if(j && k - w[i - 1] >= 0) dp[i][j][k] = max(dp[i - 1][j][k],dp[i - 1][j - 1][k - w[i - 1]] + v[i - 1]);
				else dp[i][j][k] = dp[i - 1][j][k];
			}
		}
	}
	int ma = 0;
	for(int i = 0;i <= n;i++){
		for(int j = 0;j <= 300;j++){
			if(j + w1 * i <= W){
				ma = max(ma,dp[n][i][j]);
			}
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std; 
int best_dist[100010];
int parents[100010];
int Find(int v){
	if(parents[v] == v)
		return v;
	else{
		parents[v] = Find(parents[v]);
		return parents[v];
	}
}
void Union(int a, int b){
	int fa = Find(a);
	int fb = Find(b);
	if(fa != fb){
		parents[fa] = fb;
	}
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector <pair<int,int> > arr_x(n);
	vector <pair<int,int> > arr_y(n);
	for (int i = 0; i < n; ++i)
	{
		int x,y; cin>>x>>y;
		parents[i] = i;
		best_dist[i] = INT_MAX;
		arr_x[i].first = x; arr_x[i].second = i;
		arr_y[i].first = y; arr_y[i].second = i;
	}
	sort(arr_x.begin(), arr_x.end());
	sort(arr_y.begin(), arr_y.end());
	priority_queue <pair<int, pair< int, int > > > pqx;
	priority_queue <pair<int, pair< int, int > > > pqy;
	for (int i = 0; i < n - 1; ++i)
	{
		pqx.push(make_pair(arr_x[i].first - arr_x[i + 1].first, make_pair(arr_x[i].second, arr_x[i+1].second)));
		pqy.push(make_pair(arr_y[i].first - arr_y[i + 1].first, make_pair(arr_y[i].second, arr_y[i+1].second)));
	}
	// int ptrx = 0, ptry = 0;
	long long answer = 0;
	int counter = 0;
	while(counter < n - 1)
	{
		pair<int, pair<int, int> > valx = pqx.top();
		pair<int, pair<int, int> > valy = pqy.top();
		if(-valx.first < -valy.first){
			// cout<<"x chosen "<<valx.second.first<<" "<<valx.second.second<<endl;
			int fa = Find(valx.second.first);
			int fb = Find(valx.second.second);
			if(fa != fb){
				// cout<<"Added\n";
				Union(valx.second.first, valx.second.second);
				answer += -valx.first;
				counter++;
			}
			pqx.pop();			
		}
		else{
			// cout<<"y chosen "<<valy.second.first<<" "<<valy.second.second<<endl;
			int fa = Find(valy.second.first);
			int fb = Find(valy.second.second);
			if(fa != fb){
				// cout<<"Added\n";
				Union(valy.second.first, valy.second.second);
				answer += -valy.first;
				counter++;
			}
			pqy.pop();	
		}
	}
	cout<<answer<<endl;
	return 0;
}

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

using namespace std;

int main() {
	int N,M; cin >> N >> M;
	vector<int> box(N+1,1);
	vector<bool> red(N+1);
	red[1]=true;
	for(int i=0;i<M;++i) {
		int x,y; cin >> x >> y;
		--box[x]; ++box[y];
		if(red[x]) red[y]=true;
		if(!box[x]) red[x]=false;
	}
	int ans=0;
	for(int i=1;i<=N;++i)
		if(red[i]) ++ans;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
ll c(ll x){return x*x*x;}
int main(){
	ll N,K;
	cin>>N>>K;
	if(K%2) cout<<c(N/K)<<endl;
	else cout<<c(N/K)+c((N+K/2)/K)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);


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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  sort(ALL(a));

  vector<int> v(1000001, 0);
  for (auto& x : a) {
    if (v[x] != 0) {
      v[x]++;
      continue;
    }
    for (int i = x; i <= 1000000; i += x) {
      v[i]++;
    }
  }

  int ans = 0;

  for (auto& x : a) {
    if (v[x] == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7944
k = list(map(int, input().split()))
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
l = []
m = 0
for i in listA:
  if m % 2 == 1:
    l.append(i)
  m += 1
flat = sum(l, [])
import collections
c = collections.Counter(flat)

print(k[0] - len(c))

Measured memory_bytes: 9400
import sys


def input():
    return sys.stdin.readline().strip()


class UnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.parent = [i for i in range(n_nodes)]
        self.rank = [1] * n_nodes
        self.size = [1] * n_nodes

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
            self.size[x] += self.size[y]
        else:
            self.parent[x] = y
            self.size[y] += self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def check(self, x, y):
        return self.find(x) == self.find(y)

    def get_parent_list(self):
        return [i for i in range(self.n_nodes) if self.find(i) == i]

    def get_n_groups(self):
        return len(self.get_parent_list())


def main():
    N, M = map(int, input().split())
    edge = [list(map(int, input().split())) for _ in range(M)]
    cnt = 0
    for i in range(M):
        Tree = UnionFind(N)
        for j in range(M):
            if i == j:
                continue
            else:
                Tree.unite(edge[j][0] - 1, edge[j][1] - 1)
        if Tree.get_n_groups() > 1:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
n, x, m = map(int,input().split())
lst = [0 for i in range(m)]
lst2 = [x]
i = 2
lst[x] = 1
c = 0
while True:
    if (i > n):
        break
    x = x**2%m
    if (lst[x] == 0):
        lst[x] = i
        lst2.append(lst2[i - 2] + x)
        i = i + 1
    else:
        lst2.append(lst2[i - 2] + x)
        c = 1
        break
if (c == 1):
    a = i - lst[x]
    b = lst2[i - 1] - lst2[i - 1 - a]

    c = (n - i)//a
    d = (n - i)%a
    ans = lst2[i - 1] + b*c + lst2[i - 1 - a + d] - lst2[i - 1 - a]
    print(ans)

else:
    print(lst2[n - 1])


Measured memory_bytes: 13768
n, p = gets.split.map(&:to_i)
if n > 39
  puts 1
elsif n == 1
  puts p
else
  ans = 1
  i = 2
  while (i ** n) <= p do
    if p % (i ** n) == 0
      ans = i
    end
    i += 1
  end
  puts ans
end


Measured memory_bytes: 3836
# B

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

d = abs(a - b)
s = v - w
if s <= 0:
    print("NO")
else:
    s = abs(s)
    if float(d/s) <= t:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 61656
w = list(input())
alpha = list("qwertyuiopasdfghjklzxcvbnm")
FLAG = True
for i in alpha:
  cnt = w.count(i)
  if cnt == 0:
    continue
  elif cnt % 2 == 0:
    continue
  else:
    print("No")
    FLAG = False
    break
while FLAG:
  print("Yes")
  break

Measured memory_bytes: 61856
/* Preprocess */
#include <bits/stdc++.h>

/* Field */
using namespace std;

/* Function */
int main (void) 
{

  int r, g, b;
  int num;
  string ans;

  cin >> r;
  cin >> g;
  cin >> b;

  num = r*100 + g*10 + b;

  if(num%4 == 0)
  {
    ans = "YES";
  }
  else
  {
    ans = "NO";
  }
  
  cout << ans << endl;


  return 0;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      int n=Integer.parseInt(br.readLine().trim());
      String s[]=br.readLine().trim().split("\\s+");
      int size=s.length;
      int arr[]=new int[size];
      for(int i=0;i<size;i++)
        arr[i]=Integer.parseInt(s[i]);
      
      int dp[] =  new int[size];
      Arrays.fill(dp, -1);
      
      System.out.println(minCost(arr, 0, dp));
      
    }
  
  public static int minCost(int arr[], int pos, int dp[]){
  	if(pos >= arr.length)
      return Integer.MAX_VALUE;
    
     if(pos == arr.length -1)
      return 0;
    
    if(dp[pos] != -1)
      	return dp[pos];
    
    if(pos+1 < arr.length)
      dp[pos] = Math.abs(arr[pos] - arr[pos+1]) + minCost(arr, pos+1,dp);
    
    if(pos+2 < arr.length)
     dp[pos] = Math.min(dp[pos], Math.abs(arr[pos] - arr[pos+2]) + minCost(arr, pos+2,dp));
    
      return dp[pos];
    
  }
}


Measured memory_bytes: 43784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int A = Integer.parseInt(scan.nextLine());
		 int B = Integer.parseInt(scan.nextLine());
		 int C = Integer.parseInt(scan.nextLine());
		 int X = Integer.parseInt(scan.nextLine());
		 
		 int cnt = 0;
		 
		 for (int i = 0; i < A + 1; i++) {
			 for (int j = 0; j < B + 1; j++) {
				 for (int k = 0; k < C + 1; k++) {
					 if (500 * i + 100 * j + 50 * k == X) {
						 cnt++;
					 }
				 }
			 }
		 }
		 
		 System.out.println(cnt);
		 scan.close();

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void){
    int N; cin >> N;
    int a0=0, a2=0, a4=0;
    for(int i=0; i<N; i++){
        int x; cin >> x;
        if(x%4==0) a4++;
        else if(x%2==0) a2++;
        else a0++;
    }

    if(a2==0){
        if(a4>=a0-1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        if(a4>=a0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)


int main() {
    char str[100000] = {-1};
    cin >> str;
    
    int cnt[2];

    for (int i = 0; str[i] != '\0' ; i++) {
        if (str[i] == '0') cnt[0]++;
        else cnt[1]++;
    }

    cout << min(cnt[0], cnt[1]) * 2 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn=(1<<26)+100;
const int maxm=2e5+100;
int g[maxn];
char s[maxm];
int dp[maxm];
int main() {
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin >> (s+1);

    fill(g,g+maxn,1001000);
    g[0]=0;
    dp[0]=1;
    int cd=0,len=strlen(s+1);
    for(int i=1;i<=len;++i) {
        dp[i]=1001000;
        int tmp=s[i]-'a';
        cd^=(1<<tmp);
        for(int j=0;j<26;++j) {
            int p=(1<<j)^cd;
            dp[i]=min(g[p]+1,dp[i]);
        }
        dp[i]=min(g[cd]+1,dp[i]);
        g[cd]=min(g[cd],dp[i]);

    }

    cout << dp[len] << endl;
    return 0;
}


Measured memory_bytes: 263424
#include <cstdio>
int N, a[200001], p[200001], L[200002], R[200002], F[200002];
long long O, C;
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", a + i);
		p[a[i]] = i;
	}
	for (int i = 1; i <= N; i++)
	{
		L[i] = R[i] = i;
		F[i] = 0;
	}
	for (int i = N; i; i--)
	{
		int u = p[i];
		int LM = F[u - 1] ? L[u - 1] : u, RM = F[u + 1] ? R[u + 1] : u;
		F[u] = 1;
		R[LM] = RM;
		L[RM] = LM;;
		O += C += (long long)(u - LM) * (RM - u) + RM - LM + 1;
	}
	printf("%lld\n", O);
	return 0;
}


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

using namespace std;

int a[100000005];
int main(void) {
	ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] == '<') {
      a[i + 1] = max(a[i + 1], a[i] + 1);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '>') {
      a[i] = max(a[i], a[i + 1] + 1);
    }
  }
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 2844
import sys
n,k = map(int,input().split())
x_ls = list(map(int, input().split()))
x_ls.sort()
if x_ls[0] >= 0:
    print(x_ls[k-1])
    sys.exit()
elif x_ls[-1] <= 0:
    x_ls.sort(reverse=True)
    print(abs(x_ls[k-1]))
    sys.exit()
l = 0
r = k - 1
ans = float('inf')
while r < n:
    cost_1 = 2*abs(x_ls[l]) + abs(x_ls[r])
    cost_2 = abs(x_ls[l]) + 2*abs(x_ls[r])
    cost = min(cost_1,cost_2)
    ans = min(cost, ans)
    r += 1
    l += 1
print(ans)
    

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

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

  int cur = 0, cnt = 0;
  vector<bool> seen(n, false);
  while (true) {
    if (cur+1 == 2) {
      cout << cnt << endl;
      return 0;
    }
    if (seen[cur]) {
      cout << -1 << endl;
      return 0;
    }
    cnt++;
    seen[cur] = true;
    cur = buttons[cur];
  }
  return 0;
}

Measured memory_bytes: 3772
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N & 1:
    if A[0] == 0:
        for i in range(1, N, 2):
            if A[i] != (i+1):
                print(0)
                exit()
    else:
        print(0)
        exit()
else:
    for i in range(0, N, 2):
        if A[i] != (i+1):
            print(0)
            exit()
print(pow(2, N//2, 10**9+7))


Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	ll x;
	cin >> x;
	ll now = 100;
	ll count = 0;
	while (now < x) {
		ll tmp = now / 100;
		now += tmp;
		count++;
	}
	cout << count << endl;
	return 0;
}

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

int solve(int start, int c[], int s[], int f[], int n) {
    int res = 0;
    for (int i = start; i < n - 1; i++) {
        if (res <= s[i])
            res = s[i];
        else
            res = s[i] + ((res - s[i] - 1) / f[i] + 1) * f[i];
        res += c[i];
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int c[n - 1], s[n - 1], f[n - 1];
    for (int i = 0; i < n - 1; i++)
        cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < n; i++) {
        cout << solve(i, c, s, f, n) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

template <class T, class U>
T lexical_cast(const U& from) {
    stringstream ss;
    ss << from;
    T to;
    ss >> to;
    return to;
}

int time2int(const string& str) {
    int h = lexical_cast<int>(str.substr(0,2));
    int m = lexical_cast<int>(str.substr(3,2));
    int s = lexical_cast<int>(str.substr(6,2));
    return h * 60 * 60 + m * 60 + s;
}

int main() {
    for(int N; cin >> N, N; ) {
        vector<int> v(60*60*24, 0);
        for(int i = 0; i < N; i++) {
            string s, e; cin >> s >> e;
            int ss = time2int(s);
            int ee = time2int(e);
            for(int j = ss; j < ee; j++) {
                v[j]++;
            }
        }
        cout << *max_element(v.begin(), v.end()) << endl;
    }
}

Measured memory_bytes: 1564
s = ['SUN','MON','TUE','WED','THU','FRI','SAT']
day = input()
start = s.index(day)
if day == 'SUN':
    print(7)
else:
    count = 0
    for x in range(7):
        if start == 7:
            start = 0
        if s[start] == 'SUN':
            print(count)
            break
        else:
            start += 1
        count += 1

Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 36

typedef struct{
  char c;
  int n;
}Card;


int main(){
  int N,i,j,k=0;
  Card card1[MAX], card2[MAX], card3[MAX],cp;
  char c;
  int mini;
  
  scanf("%d\n",&N);
  for(i=0; i<N; i++){
    scanf("%c%d",&card1[i].c,&card1[i].n);
    scanf("%c",&c);
  }
  
  for(i=0; i<N; i++)card2[i]=card1[i];
  
  k=0;
  for(i=1;i<=9;i++){
    for(j=0;j<N;j++){
      if(card1[j].n==i){
	card3[k]=card1[j];
	k++;
      }
    }
  }
  
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(card1[j].n<card1[j-1].n){
	cp=card1[j];
	card1[j]=card1[j-1];
	card1[j-1]=cp;
      }
    }
  }
  
  for(i=0; i<N-1; i++) printf("%c%d ",card1[i].c,card1[i].n);
  printf("%c%d\n",card1[i].c,card1[i].n);
  
  
  k=0;
  for(i=0;i<N;i++){
    if(card1[i].c!=card3[i].c){
      printf("Not stable\n");
      k++;
      break;
    }
  }
  if(k==0)printf("Stable\n");
  
  
  for(i=0;i<N;i++){
    mini=i;
    for(j=i;j<N;j++){
      if(card2[j].n<card2[mini].n)mini=j;
    }
    cp=card2[i];
    card2[i]=card2[mini];
    card2[mini]=cp;
  }
  
  
  for(i=0;i<N-1;i++) printf("%c%d ",card2[i].c,card2[i].n);
  printf("%c%d\n",card2[i].c,card2[i].n);
  
  k=0;
  for(i=0; i<N; i++){
    if(card2[i].c!=card3[i].c){
      printf("Not stable\n");
      k++;
      break;
    }
  }
  if(k==0)printf("Stable\n");

  return 0;
}

Measured memory_bytes: 608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main{
	
	static long mod = (int)1e9 + 7;
	

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = fs.nextInt();
		long[] arr = new long[n];
		for(int i=0;i<n;i++) arr[i]= fs.nextLong();
		
		long sum = 0;
		long sSum = 0;
		for(long l: arr) {
			sum = (sum+l)%mod;
			sSum = (sSum + (l*l)%mod)%mod;
		}
		
		long ans = ((((sum*sum)%mod - sSum + mod)%mod)*(exp(2L,mod-2)%mod))%mod;
		
		out.println(ans);
		
		out.close();
		
		

		
	}
	
	static long exp(long a,long n) {
		long res = 1L;
		while(n>0) {
			if((n&1)==1) {
				res = (res*a)%mod;
			}
			a = (a*a)%mod;
			n = n>>1;
		}
		return res;
	}
	
	
	
	
	
	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		
		public String nextLine() throws IOException {
			return br.readLine();
		}
		
		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	


}

Measured memory_bytes: 56488