akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    K = I()
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            gcab = math.gcd(a, b)
            for c in range(1, K+1):
                ans += math.gcd(gcab, c)
    print(ans)


main()



Measured memory_bytes: 10944
#include <iostream>
#include <string>

using namespace std;

int main() {
	char s[13], b[13];
	string a;
	cin >> s;
	for (int i = 0; s[i] != '\0'; ++i) {
		if (i == 4)	
			a = a + " ";
		a = a + s[i];
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(ll(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

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

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int N, M;
    cin >> N >> M;

    int cnt[M];
    fill(cnt, cnt + M, 0);
    for (int i = 0; i < N; ++i) {
        int K;
        cin >> K;
        for (int j = 0; j < K; ++j) {
            int a;
            cin >> a;
            ++cnt[--a];
        }
    }

    int ans = 0;
    for (int i = 0; i < M; ++i) {
        if (cnt[i] == N) ++ans;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <sstream>
#include <cassert>
#include <functional>
#include <cfloat>
#include <climits>
#include <cstring>
#include <stack>
#include <time.h>
#include <complex>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int t=s.size();
    for(int i=0;i<t;i=i+2)
    cout<<s[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<int,int>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power( (num*num)%mod,g/2,mod);
}


int main(){
	double r;
	cin >> r;
	cout << 2 * M_PI*r;
}

Measured memory_bytes: 3784
#coding:utf-8
#1_9_C
import heapq

h = []
while True:
    cmd = input().split()
    if cmd[0] == "end":
        break
    elif cmd[0] == "insert":
        heapq.heappush(h, -int(cmd[1]))
    else:
        print(-heapq.heappop(h))

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

int N, A, B;
long long K;
int mod = 998244353;

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

//long long factorial(long long n) {
//    if (n == 1) {
//        return 1;
//    } else {
//        return  n * factorial(n - 1) % mod;
//    }
//}

long long power(long long a, int n){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        long long b = power(a, n / 2);
        return 1ll * b * b % mod;
    } else {
        return 1ll * a * power(a, n - 1) % mod;
    }
}

long long inverse(long long a) {
    if (a == 1) {
        return 1;
    }
    return power(a, mod - 2);
}

int main() {
    cin >> N >> A >> B >> K;
    
    if (K < min(A, B)) {
        cout << 1 << endl;
        return 0;
    }
    
    int d = gcd(A, B);
    if (K % d != 0) {
        cout << 0 << endl;
        return 0;
    }
    
    vector<long long> factorial(N + 1), factinv(N + 1);
    factorial[0] = 1; factinv[0] = 1;
    for (int i = 1; i < N + 1; i++) {
        factorial[i] = factorial[i - 1] * i % mod;
        factinv[i] = inverse(factorial[i]);
    }
    
    K /= d; A /= d; B /= d;
    long long ans = 0;
    for (int n = 0; n <= N; n++) {  //nA+mB = Kの解をみつける
       if ((K - n * A) % B != 0) {
            continue;
        } else {
            long long m = (K - n * A) / B;  //NCn * NCmだけ解がある
            if (m > N || m < 0) {
                continue;
            }
            ans += factorial[N] * factorial[N] % mod * factinv[n] % mod * factinv[N - n] % mod * factinv[m] % mod * factinv[N - m] % mod;
            ans %= mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
class Dice
  def initialize num_dict
    @num=num_dict

    @top=1
    @bottom=6
    @right=3
    @left=4
    @forward=5
    @backward=2

  end

  def ==(other)
    checkSameDice(other)
  end

  def checkSameDice(other)
    1.upto 6 do |i|
      setTop i 
      4.times do
        counterClockWiseRot
        return true if checkSameNumDice(other) 
      end
    end
    false
  end

  def checkSameNumDice(other)
    otherNum=other.instance_variable_get(:@num)
    if ( (@num[@top]==otherNum[other.instance_variable_get('@top')])&&(@num[@bottom]==otherNum[other.instance_variable_get('@bottom')])&&(@num[@right]==otherNum[other.instance_variable_get('@right')])&&(@num[@left]==otherNum[other.instance_variable_get('@left')])&&(@num[@forward]==otherNum[other.instance_variable_get('@forward')])&&(@num[@backward]==otherNum[other.instance_variable_get('@backward')]) )
      return true
    else
      return false
    end
  end

  def counterClockWiseRot
    temp=@right
    @right=@backward
    @backward=@left
    @left=@forward
    @forward=temp
  end

  def to_s
    <<"EOS"
    top:      #{@num[@top]}
    bottom:   #{@num[@bottom]}
    right:    #{@num[@right]}
    left:     #{@num[@left]}
    forward:  #{@num[@forward]}
    backward: #{@num[@backward]}

EOS
  end

  def getTop
    @num[@top]
  end

  def moveE
    temp=@top
    @top=@left
    @left=@bottom
    @bottom=@right
    @right=temp
  end

  def setTop(top)
    4.times {
      return true if @top==top
      moveN
    }
    counterClockWiseRot
    4.times {
      return true if @top==top
      moveN
    }
    false
    end

  def setRight(rightNum)
    top=@num.key(rightNum)
    3.times do |i|
      break if @top==top
      moveE
      moveN if @top!=top
    end
    if @top==top
      moveE
      return true
    end
    false
  end
    
  def moveW
    temp=@top
    @top=@right
    @right=@bottom
    @bottom=@left
    @left=temp
  end

  def moveN
    temp=@top
    @top=@backward
    @backward=@bottom
    @bottom=@forward
    @forward=temp
  end
  
  def moveS
    temp=@top
    @top=@forward
    @forward=@bottom
    @bottom=@backward
    @backward=temp
  end

  def rotate(char)
    case char
      when "E"
        moveE
      when "W"
        moveW
      when "N"
        moveN
      when "S"
        moveS
    end
  end

  def setBackwardandRight(backNum,rightNum)
    back=@num.key(backNum)
    right=@num.key(rightNum)
    3.times{
      break if @backward==back
      moveN
    }
    if @backward!=back
      moveE
      while @backward!=back
        moveN
      end
    end
 
    while @right!=right
      moveE
    end
  end
end

def newDiceFromInput
  a,b,c,d,e,f=STDIN.gets.split(" ")
  Dice.new({1 => a.to_i , 2 => b.to_i , 3 => c.to_i , 4 => d.to_i , 5 => e.to_i , 6 => f.to_i})
end

num=STDIN.gets.to_i
dices=[]
num.times do
  dices<<newDiceFromInput
end
noFlag=false
dices.each_with_index do |dice,i|
  dices.each_with_index  do |other,j|
    next if i==j
    noFlag=true if dice==other
  end
end
if noFlag
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 8828
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    sa := nextString()
    sb := nextString()
    sc := nextString()
    
    cur := "a"
    
    for {
		c := cur[0]
		if c == 'a' {
			cur = sa
			if len(cur) == 0 {
				fmt.Println("A")
				return
			}
			sa = sa[1:]
		} else if c == 'b' {
			cur = sb
			if len(cur) == 0 {
				fmt.Println("B")
				return
			}
			sb= sb[1:]
		} else if c == 'c' {
			cur = sc
			if len(cur) == 0 {
				fmt.Println("C")
				return
			}
			sc = sc[1:]
		} 
    }
}
 
/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009

typedef long long int lli;

void swap(lli *a, lli *b)
{
  lli tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

// a ÷b (mod MOD) →(a % MOD) * modinv(b, MOD) % MDO
lli modinv(lli a, lli m) {
    lli b = m, u = 1, v = 0;
    while (b) {
        lli t = a / b;
        a -= t * b; swap(&a, &b);
        u -= t * v; swap(&u, &v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


long long int combi(long long int n, long long int r) {
	long long int ans = 1;
	for ( long long int i = 0; i < r; i++ ) {
		ans = (ans * (n - i) % MOD) * modinv(r - i, MOD) % MOD;
	}
	return ans;
}

int main(void) {
	long long int n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);

	long long int sum = 2;
	long long int m = 1;
	while ( m < n ) {
		if ( m * 2 <= n ) {
			sum = sum * sum % MOD;
			m *= 2;
		} else {
			sum = sum * 2 % MOD;
			m++;
		}
	}

	sum = ((sum - combi(n, a) + MOD) % MOD - combi(n, b) - 1 + MOD) % MOD;
	printf("%lld\n", sum);
  return 0;
}


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

a, b, n = map(int, input().split())


def f(x):
    return a*x//b-a*(x//b)

high = n
low = 0
while high - low >= 1:
    mid_left = high/3+low*2/3
    mid_right = high*2/3+low/3
    if f(mid_left) <= f(mid_right):
        low = mid_left
    else:
        high = mid_right
print(max(f(int(low)),f(int(high))))


Measured memory_bytes: 9196
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 1000000007
#define meme(x) memset((x), 0, sizeof((x)))
#define memo(x) memset((x),-1, sizeof((x)))
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll

ll egcd(ll a, ll b, ll &x, ll &y){
    if (a == 0LL){  
        x = 0LL;  
        y = 1LL;  
        return b;  
    }
    ll xx, yy;
    ll val = egcd(b % a, a, xx, yy);  
    x = yy - (b / a) * xx;  
    y = xx;  
    return val;
}

ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}

//  ==========     //\\       //||     ||====//||
//      ||        //  \\        ||     ||   // ||
//      ||       //====\\       ||     ||  //  ||
//      ||      //      \\      ||     || //   ||
//  ========== //        \\  ========  ||//====|| 
//  code

vector<ll> dp;
ll rec(int s){
    if(dp[s] > -1)
        return dp[s];
    if(s == 0LL)
        return 1LL;
    ll ans = 0LL;
    for(int i = s; i >= 3; i--){
        ans += rec(s - i);
        ans %= MOD;
    }
    return dp[s] = ans;
}
void solve(){
    int n,i,j,k,l,p;
    cin >> n;
    dp.resize(n + 1, -1LL);
    cout << rec(n) << endc;
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


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

    int a[2][100];
    REP(i, 2) {
        REP(j, n) {
            cin >> a[i][j];
        }
    }

    int b[2][100];
    b[0][0] = a[0][0];
    b[1][n-1] = a[1][n-1];
    FOR(i, 1, n) {
        b[0][i] = b[0][i-1] + a[0][i];
    }
    for ( int i = n-2; i >=0; i-- ) {
        b[1][i] = b[1][i+1] + a[1][i];
    }

    int maxV = 0;
    REP(i, n) {
        int v = b[0][i] + b[1][i];
        maxV = max(maxV, v);
    }

    cout << maxV << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
    
using namespace std;
bool sortin(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first < b.first); 
} 
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll de(ll N) 
{ 
  
    // To store the binary number 
    ll B_Number = 0; 
    ll cnt = 0; 
    while (N != 0) { 
        int rem = N % 2; 
        ll c = pow(10, cnt); 
        B_Number += rem * c; 
        N /= 2; 
  
        // Count used to store exponent value 
        cnt++; 
    } 
  
    return B_Number; 
} 
  
  
int main(){
    IOS;
ll n,k;
cin>>n;map<ll,ll> m;ll sum=0;
for(ll i=0;i<n;i++){
    ll x;cin>>x;m[x]++;sum=sum+x;
}
ll q;cin>>q;
while(q--){
    ll b,c;
    cin>>b>>c;
   // cout<<m[b]<<m[c]<<"\n";
   ll x=b*m[b];
   ll y=c*m[b];
   //cout<<x<<y<<"\n";
   sum=sum+y-x;
    m[c]=m[c]+m[b];
    m[b]=0;
    cout<<sum<<"\n";
}
    return 0;}

Measured memory_bytes: 9544
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		int a = sc.nextInt();
        int b = sc.nextInt();
		int c = -1;
        for(int i=1;i<=1000;i++){if((i*8)/100==a && (i*10)/100==b){c=i;break;}}
		System.out.println(c);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n;scanf("%d",&n);
	int a,b,c;a=b=c=0;
	for(int i=1;i<=n;i++)
	{
		int x=0;scanf("%d",&x);
		if(x%4==0) a++;
		else if(x%2==0) b++;
		else c++;
	}
	if(b>0) c++;
	if(a>=c-1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FLISOnTree {
public:

    vector<int> graph[200005];
    vector<ll> a;
    vector<ll> ret;

    void dfs(int v, int pa, vector<ll>& vec) {
      // manipulate
      bool pushed = false;
      ll before = -1;
      ll idx;
      debug(vec.size(), v, pa);
      if (vec.empty() || vec.back() < a[v]) {
        vec.push_back(a[v]);
        pushed = true;
      } else {
        auto it = upper_bound(all(vec), a[v]-1);
        idx = distance(vec.begin(), it);
        before = vec[idx];
        vec[idx] = a[v];
      }

      // calc
      ret[v] = vec.size();

      for(auto e: graph[v]) {
        if (e == pa) continue;
        dfs(e, v, vec);
      }
      // reverse
      if (pushed) {
        vec.pop_back();
      } else {
        vec[idx] = before;
      }
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      a.resize(n);
      ret.resize(n);
      rep(i, n) {
        cin >> a[i];
      }
      rep(i, n-1) {
        int u, v; cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
      }
      vector<ll> v;
      dfs(0, -1, v);

      rep(i, n) {
        cout << ret[i] << '\n';
      }
    }
};

signed main() {
  FLISOnTree solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 34496
main :: IO ()                                                                                                              
main = minimum . map (abs . subtract 753 . read) . f <$> getLine >>= print                                                 
                                                                                                                           
f :: [a] -> [[a]]                                                                                                          
f [] = []                                                                                                                  
f [_] = []                                                                                                                 
f [_,_] = []                                                                                                               
f (a:b:c:as) = (a:b:c:[]):f (b:c:as)

Measured memory_bytes: 508
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn read_int_tuple() -> (i32, i32) {
    let v = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, D) = read_int_tuple();
    let ans = ((N as f64) / ((2*D+1) as f64)).ceil() as i32;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

typedef long long LL;

LL xor_till(LL n)
{
    LL left = (n/4)*4, right = n;

    LL answer = 0;

    for(LL i = left; i <= right; i++)
        answer ^= i;

    return answer;
}

int main()
{
    LL left, right;
    cin >> left >> right;

    LL xor_answer = xor_till(right)^xor_till(left - 1);

    cout << xor_answer;
    return 0;
}


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

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  int n,s = 0,c = 0;
  cin>>n;
  s = n;
  while(s)c += s % 10, s/=10;
  cout<<(n%c==0?"Yes":"No")<<endl;


}

Measured memory_bytes: 256
# Aizu Problem 00167: Bubble Sort
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def bubble_sort(N, A):
    cnt = 0
    last = N - 1
    while last > 0:
        for k in range(last):
            if A[k] > A[k+1]:
                A[k], A[k+1] = A[k+1], A[k]
                cnt += 1
        last -= 1
    return cnt


while True:
    N = int(input())
    if N == 0:
        break
    A = [int(input()) for _ in range(N)]
    print(bubble_sort(N, A))
 

Measured memory_bytes: 7824
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	curr := 0
	res := 0
	arr := strings.Split(s, "")
	for _, v := range arr {
		if v == "A" || v == "C" || v == "G" || v == "T" {
			curr++
			if res < curr {
				res = curr
			}
		} else {
			if res < curr {
				res = curr
			}
			curr = 0
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  string s,t;
  cin>>s>>t;
  string S=s;
  S+=s;
  bool judge=false;
  if(s==t) judge=true;
  for(int i=1;i<s.size();i++){
    string a="";
    for(int j=0;j<s.size();j++){
      a+=S[i+j];
    }
    if(a==t) judge=true;
  }
  if(judge) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  bool absmax_pl = true;
  int abs_max = 0;
  int max_ind = 0;
  for(int i = 0; i < N; i++){
    if(abs_max <= abs(a[i])){
      abs_max = abs(a[i]);
      if(a[i] >= 0){
        absmax_pl = true;
      }else{
        absmax_pl = false;
      }
      max_ind = i;
    }
  }

  if(absmax_pl){
    // 正だったら
    cout << 2 * (N-1) << endl;
    for(int i = 0; i < N; i++){
      if(i != max_ind){
        cout << (max_ind+1) << " " << (i+1) << endl;
      }
    }

    // 下から
    for(int i = 0; i < N-1; i++){
      cout << i+1 << " " << i+2 << endl; 
    }

  }else{
    // 負だったら
    cout << 2 * (N-1) << endl;
    for(int i = 0; i < N; i++){
      if(i != max_ind){
        cout << (max_ind+1) << " " << (i+1) << endl;
      }
    }

    for(int i = N; i > 1; i--){
      cout << i << " " << (i-1) << endl;
    }
  }



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
ll A[200010];
ll cnt1[200010];
ll cnt2[200010];


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    cnt1[1] = 1;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
    }

    stack<pll> st;
    st.push({linf, 1});

    for(int i = 2; i <= N; ++i){
        cnt1[i] = cnt1[i - 1] + 1;
        ll cp = A[i - 1];
        ll cnt = 0;
        
        if(cp < A[i]){
            while(cp < A[i]) cp *= 4, cnt += 2;
           
            ll pre = i;
            while(cnt != 0){
                pll p = st.top();
                st.pop();

                if(cnt <= p.first){
                    p.first -= cnt;
                    cnt1[i] += cnt * (pre - p.second);
                    cnt = 0;
                    if(p.second == 1) st.push({linf, 1});
                    else if(p.first != 0) st.push(p);
                }else{
                    cnt1[i] += cnt * (pre - p.second);
                    cnt -= p.first;
                    pre = p.second;
                }
            }
        }else{
            cp = A[i];
            while(cp * 4 <= A[i - 1]) cp *= 4, cnt += 2;
            if(cnt != 0) st.push({cnt, i});
        }
    }

    while(!st.empty()) st.pop();
    st.push({linf, N});
    for(int i = N - 1; i >= 1; --i){
        cnt2[i] = cnt2[i + 1];
        ll cp = A[i + 1];
        ll cnt = 0;
        
        if(cp < A[i]){
            while(cp < A[i]) cp *= 4, cnt += 2;
            ll pre = i;
            while(cnt != 0){
                pll p = st.top();
                st.pop();

                if(cnt <= p.first){
                    p.first -= cnt;
                    cnt2[i] += cnt * (p.second - pre);
                    cnt = 0;
                    if(p.second == 1) st.push({linf, N});
                    else if(p.first != 0) st.push(p);
                }else{
                    cnt2[i] += cnt * (p.second - pre);
                    cnt -= p.first;
                    pre = p.second;
                }
            }
        }else{
            cp = A[i];
            while(cp * 4 <= A[i + 1]) cp *= 4, cnt += 2;
            if(cnt != 0) st.push({cnt, i});
        }
    }
    ll ans = linf;
    for(int i = 0; i <= N; ++i){
        chmin(ans, cnt1[i] + cnt2[i + 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)
	for x := 0; x <= N; x++ {
		for y := 0; y <= N-x; y++ {
			z := N - x - y
			if 10000*x+5000*y+1000*z == Y {
				fmt.Println(x, y, z)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

vector<int> G[100'010];

int main(){
  //using namespace std;
  int n, m;
  cin>>n>>m;
  int a[m], b[m];
  vector<int> ans(n, -1);
  ans[0] = 0;
  queue<int> q;
  q.push(0);
  REP(i, m){
    cin>>a[i]>>b[i];
    a[i]--; b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  while(!q.empty()){
    int v = q.front();
    q.pop();
    for(int nv: G[v]){
      if(ans[nv] >= 0) continue;
      ans[nv] = v;
      q.push(nv);
    }
  }
  REP(i, n){
    if(ans[i] >= 0) continue;
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  REP(i, n){
    if(i == 0) continue;
    cout << ans[i] + 1 << endl;
  }
  return 0;
}


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

int n;
int a[10000];

signed main() {
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  int ans = 0;
  for(int i=0; i<n; i++) {
    int aa = a[i];
    while(aa%2==0) {
      aa /= 2;
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define It iterator
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;


int main() {
    //freopen("test.in","r",stdin);
    int x,y;
    cin>>x>>y;

    printf("%.6f",1./(1./x+1./y));

    return 0;
}


Measured memory_bytes: 256
def parent(i):
    if i / 2 <= 0:
        return 0
    else:
        return int(i/2)
    
def left_child(i):
    if 2*i >= len(L):
        return 0
    else :
        return int(2*i)

def right_child(i):
    if 2*i+1 >= len(L):
        return 0
    else :
        return int(2*i + 1)
    
def make_print(l_idx,p,l_c,r_c):
    print_str='node '+str(l_idx+1)+': key = '+str(L[l_idx+1])
    if p != 0:
        print_str+=', parent key = '+str(L[p])
    if l_c != 0:
        print_str+=', left key = '+str(L[l_c])
    if r_c != 0:
        print_str+=', right key = '+str(L[r_c])
        
    print_str+=', '
    print(print_str)
    
N=int(input())
L=list(map(int,input().split()))
L=[0]+L
    
for l_idx,l in enumerate(L[1:]):
#     print('=====')
#     print(l_idx,l)
    p = parent(l_idx+1)
    l_c = left_child(l_idx+1)
    r_c = right_child(l_idx+1)
#     print(p,l_c,r_c)
    make_print(l_idx,p,l_c,r_c)


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

vector<int> calc(int64_t v){
    vector<int> res;
    for(int k=0; k<30; k++){
        res.push_back(v%3);
        v /= 3;
    }
    return res;
}

int64_t pw3(int k){
    int64_t res = 1;
    while(k--) res *= 3;
    return res;
}

int main(){
    int Q;
    cin >> Q;
    while(Q--){
        int64_t x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1--; y1--; x2--; y2--;
        vector<int> vx1 = calc(x1), vy1 = calc(y1), vx2 = calc(x2), vy2 = calc(y2);

        int64_t dist = abs(x1-x2) + abs(y1-y2);
        int64_t ext = 0;
        for(int k=29; k>=0; k--){
            if(vx1[k] != vx2[k]) break;
            int64_t B = pw3(k);
            if(vx1[k] == 1 && (y1+B)/3/B != (y2+B)/3/B){
                int64_t L1 = x1 / B * B - 1;
                int64_t L2 = L1 + 1 + B;
                ext = max(ext, 2*min(L2-max(x1, x2), min(x1, x2)-L1));
            }
        }
        for(int k=29; k>=0; k--){
            if(vy1[k] != vy2[k]) break;
            int64_t B = pw3(k);
            if(vy1[k] == 1 && (x1+B)/3/B != (x2+B)/3/B){
                int64_t L1 = y1 / B * B - 1;
                int64_t L2 = L1 + 1 + B;
                ext = max(ext, 2*min(L2-max(y1, y2), min(y1, y2)-L1));
            }
        }
        cout << dist+ext << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define inf (int)(1e14)

int main(){
	int N, M, i, j, k;
	scanf("%d%d", &N, &M);
	vector<vector<int>> edge(N, vector<int>(0));
	for(i = 0; i < M; i++){
		int s, t;
		scanf("%d%d", &s, &t);
		s--;
		t--;
		edge[s].push_back(t);
	}
	vector<double> E(N, 0);
	for(i = N - 2; i >= 0; i--){
		for(j = 0; j < edge[i].size(); j++){
			E[i] += E[edge[i][j]] + 1;
		}
		E[i] /= edge[i].size();
	}
	double ans = E[0];
	for(k = N - 2; k >= 0; k--){
		vector<double> e(N, 0);
		for(i = N - 2; i >= 0; i--){
			if(i == k){
				if(edge[i].size() == 1){
					e[i] = inf;
				}
				else{
					double emax = 0;
					for(j = 0; j < edge[i].size(); j++){
						e[i] += e[edge[i][j]] + 1;
						emax = max(emax, e[edge[i][j]]);
					}
					e[i] -= emax + 1;
					e[i] /= edge[i].size() - 1;
				}
			}
			else{
				for(j = 0; j < edge[i].size(); j++){
				e[i] += e[edge[i][j]] + 1;
				}
				e[i] /= edge[i].size();
			}
		}
		ans = min(ans, e[0]);
	}
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep (i, N) cin >> A[i];
  ll sum = 0;
  rep (i, N) sum += A[i];

  ll ans = -1;
  ll ans_tmp = 0;

  rep (i, N) {
    ll tmp = A[i] * N;
    if (abs(sum - ans_tmp) > abs(sum - tmp)) {
      ans = i;
      ans_tmp = tmp;
    }
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using namespace std;
int main()
{
	int N,M;
	unsigned long long int i,j,k,ans=0;
	vector<pair<unsigned long long int, int>> p;
	cin >>N >> M;
	for(i=0;i<N;i++)
	{

		cin>>j>>k;
		p.push_back(make_pair(j, k));
	}
	sort(p.begin(), p.end());
	for(i=0;i<N;i++)
	{
		if(p[i].second < M)
		{
			ans += p[i].first * p[i].second;
			M-=p[i].second;
		}
		else
		{
			ans += p[i].first * M;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#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 repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    string s;
    in(s);
    if (s == "SAT")
    {
        out("1");
    }
    if (s == "FRI")
    {
        out("2");
    }
    if (s == "THU")
    {
        out("3");
    }
    if (s == "WED")
        out("4");
    if (s == "TUE")
        out("5");
    if (s == "MON")
        out("6");
    if (s == "SUN")
        out("7");
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        A: [i64; N],
    }

    let mut cnt: HashMap<i64, u64> = HashMap::new();
    let mut ans = 0;

    for (i, &a) in A.iter().enumerate() {
        ans += *cnt.entry((i as i64) - a).or_default();
        *cnt.entry((i as i64) + a).or_insert(0) += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 18184
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

d = ni()

if d == 25:
    print('Christmas')
    
elif d == 24:
    print('Christmas Eve')
    
elif d == 23:
    print('Christmas Eve Eve')
    
elif d == 22:
    print('Christmas Eve Eve Eve')

Measured memory_bytes: 3064
let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let edges = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun a b -> a-1, b-1)) in
  let g = Array.init n (fun _ -> Array.make n false) in
  edges |> Array.iter (fun (u, v) ->
    g.(u).(v) <- true; g.(v).(u) <- true);
  let check () =
    let visited = Array.make n false in
    let rec dfs v =
      visited.(v) <- true;
      Array.mapi (fun w e -> if e && not visited.(w) then dfs w else 0) g.(v)
      |> Array.fold_left (+) 1
    in dfs 0 < n
  in
  edges |> Array.map (fun (u, v) ->
    g.(u).(v) <- false; g.(v).(u) <- false;
    let x = if check () then 1 else 0 in
    g.(u).(v) <- true; g.(v).(u) <- true;
    x)
  |> Array.fold_left (+) 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int k;
    int t;
    cin >> k >> t;
    Vec<int> v(t);
    for (int i = 0; i < t; i++) {
        cin >> v[i];
    }
    int eat = -1;
    int now_max;
    int now_num = -1;

    for (int i = 0; i < k; i++) {
        now_max = 0;
        for (int j = 0; j < t; j++) {
            if (eat != j && now_max < v[j]) {
                now_max = v[j];
                now_num = j;
            }
        }
        //cout << "MAX = " << now_max << endl;
        //cout << "NUM = " << now_num << endl;
        if (now_max == 0) {
            cout << k - i << endl;
            return 0;
        } else {
            eat = now_num;
            v[now_num]--;
        }
    }
    cout << 0 << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			sc.close();
			int m1 = x2 - x1;
			int m2 = y2 - y1;
			int x3 = x2 - m2;
			int x4 = x1 - m2;
			int y3 = y2 + m1;
			int y4 = y1 + m1;
			System.out.println(x3+" "+y3+" "+x4+" "+y4);
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 23892
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut s: String = iterator.next().unwrap().to_string();

    while !s.is_empty() {
        let len = s.len();
        if s.ends_with("dream") {
            s.truncate(len - 5);
        } else if s.ends_with("dreamer") {
            s.truncate(len - 7);
        } else if s.ends_with("erase") {
            s.truncate(len - 5);
        } else if s.ends_with("eraser") {
            s.truncate(len - 6);
        } else {
            break;
        }
    }

    if s.is_empty() {
        return "YES".to_string();
    }

    return "NO".to_string()
}


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

#define sz(x) ((int)x.size())
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll; 
typedef long double ld; 


int main(){
  int n,k; cin>>n>>k; 
  vector<ld> p(max(n+1,2*k+1)); 
  for(int i=k;i<sz(p);i++){
    p[i]=1; 
  }
  for(int i=k-1;i>=1;i--){
    p[i]=0.5*p[2*i]; 
  }
  ld ans=0; 
  for(int i=1;i<=n;i++){
    ans+=p[i]; 
  }
  ans/=n; 
  printf("%.10llf\n",ans); 
}

Measured memory_bytes: 3328
n=int(input())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
ans="No"
for i in range(n-2):
    if ((a[i][0]==a[i][1]) and (a[i+1][0]==a[i+1][1]) and (a[i+2][0]==a[i+2][1])):
        ans="Yes"
        break
print(ans)

Measured memory_bytes: 9128
#include <stdio.h>
int main(){
  int x1,x2,x3,x4,x5;
  scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
  if(x1==0){
    printf("1");
  }else if(x2==0){
    printf("2");
  }else if(x3==0){
    printf("3");
  }else if(x4==0){
    printf("4");
  }else if(x5==0){
    printf("5");
  }
  return 0;
}

Measured memory_bytes: 1608
#include <iostream>
using namespace std;
int main(void){
    int n,x,k,a,b,c;
    

    
   
   while(1){
        cin >> n >> x;
        if(0==n+x)break;
        k=0;
        for(a=1;a<=n;a++){
            for(b=a+1;b<=n;b++){
                for(c=b+1;c<=n;c++){
                    if(x==a+b+c){
                        k++;
                    }
                }
            }
        }
        cout << k << endl;
    }
}


Measured memory_bytes: 3112
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
char s[100001];

int main() {
	cin >> s;

	rep(i, 0, 100001) {
		if (s[i] == '\0')break;
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

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

int main()
{
    int a;
    cin >> a;
    string s = "No";
    for (int i=1; i<10; i++)
    {
        for (int j=1; j<10; j++)
        {
            if (i*j==a)
            {
                s="Yes";i=10;break;
            }
        }
    }
    cout << s;
   return 0;
}


Measured memory_bytes: 3604