akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self, n):
        self.par = [-1] * (n + 1)  # 頂点番号とindexをそろえるためにn+1
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])  # 再帰で根までたどる.その過程で根とつなぎかえる
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)  # 根同じならTrue違うならFalseを返す

    def size(self, x):
        return -self.par[self.find(x)]


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)
res = n*(n-1)//2
ans = []
ans.append(res)
for i in range(1, m)[::-1]:
    a = ab[i][0]
    b = ab[i][1]
    if not uf.same_check(a, b):
        res -= uf.size(a)*uf.size(b)
    uf.union(a, b)
    ans.append(res)
ans.reverse()
for i in range(m):
    print(ans[i])



Measured memory_bytes: 115032
package main

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

type MyScanner struct {
	sc *bufio.Scanner
}

type MyWriter struct {
	stdout io.Writer
}

type MyPut interface{}

func getScanner(fp io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 500001), 500000)
	return sc
}

func getHugeScanner(fp io.Reader, size int) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, size), size)
	return sc
}

func (mysc *MyScanner)String() string {
	mysc.sc.Scan()
	return mysc.sc.Text()
}

func (mysc *MyScanner)Int() int {
	i, _ := strconv.Atoi(mysc.String())
	return i
}

func (mysc *MyScanner)Int64() int64 {
	i, _ := strconv.ParseInt(mysc.String(), 10, 64)
	return i
}

func (mysc *MyScanner)Float64() float64 {
	i, _ := strconv.ParseFloat(mysc.String(), 64)
	return i
}

func (mw MyWriter)Puts(v MyPut) {
	_, _ = fmt.Fprintf(mw.stdout, "%v\n", v)
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := MyScanner{getScanner(stdin)}
	mw := MyWriter{stdout}

	b := sc.String()

	switch(b[0]) {
	case 'A':
		mw.Puts(string('T'))
	case 'T':
		mw.Puts(string('A'))
	case 'G':
		mw.Puts(string('C'))
	case 'C':
		mw.Puts(string('G'))
	}

}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n;
    scanf("%d",&n);
    char a[101];
   scanf("%s",a);
    int i,j,k,l,max=0;

    for(i=0; i<=strlen(a)-2; i++)
    {
        int cont[10000]={0};
        for(j=0; j<=i; j++)
        {

            for(k=i+1; k<=strlen(a)-1; k++)
            {
                if(a[j]==a[k])
                {
                    int x=(int)a[j];
                    cont[x]++;

                }
            }



        }
        int sum=0;
            for(l=0; l<10000; l++)
            {
                if(cont[l]!=0)
                    sum=sum+1;
            }
            if(max<sum)
                max=sum;

    }

 printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 256
def sum_of_digits(arg: int) -> int:
    arg_str = str(arg)
    sum_digits = 0
    for char in arg_str:
        sum_digits += int(char)

    return sum_digits


# main
input_num = int(input())

if input_num % sum_of_digits(input_num) == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

int ctoi(char c) {
  if( c >= '0' && c <= '9' ) return c-'0';
  else return -1;
}
signed main() {
  
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  
  map<int, int> amari;
  amari[0] = 1;
  
  int now = 0;
  int keta = 1;
  for( int i = 0; i < S.size(); i++ ){
    now += ctoi(S.at(i))*keta;
    now %= 2019;
    if( amari.count(now) ) amari[now]++;
    else amari[now] = 1;
    keta *= 10;
    keta %= 2019;
  }
  
  int ans = 0;
  for( auto p : amari ){
    ans += p.second * (p.second-1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define  _CRT_SECURE_NO_DEPRECATE
using namespace std;
#define maxv 100005
#define che 1LL<<32
#define modi 1000000007
int main()
{
    ll n,x;
    cin>>n>>x;
    ll i,a[n];
    for(i=0;i<n;i++)
    {
        ll x;
        cin>>a[i];
        if(i!=0)
            a[i]+=a[i-1];
    }
    ll c=0;
    for(i=0;i<n;i++)
    {
        if(a[i]<=x)
            c++;
    }
    cout<<c+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n;
  cin>>n;
  bool shiritori=true;
  vector<string>s(n);
  rep(i,n) cin>>s[i];
  rep(i,n-1){
    if(s[i].back()!=s[i+1].front())
      shiritori=false;
  }
  rep(i,n){
    rep(j,i){
      if(s[j]==s[i])
        shiritori=false;
    }
  }
  if(shiritori==false)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}
    

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int main(){
	int n,count,i,l,j,num;
	int **a;
	
	scanf("%d",&n);

	a = (int**)malloc(sizeof(int*)*n);
	for( i = 0 ; i < n ; i++ ) a[i] = (int*)malloc(sizeof(int)*n);

	for( i = 0 ; i < n ; i++ ){
		for( j = 0 ; j < n ; j++ ) a[i][j] = 0;
	}

	for( i = 0 ; i < n ; i++ ){
		scanf("%d %d",&l,&count);
		for( j = 0 ; j < count ; j++ ){
			scanf("%d",&num);
			a[i][num-1] = 1;
		}
	}

	for( i = 0 ; i < n ; i++ ) {
		for( j = 0 ; j < n-1 ; j++ ) printf("%d ",a[i][j]);
		printf("%d\n",a[i][n-1]);
	}
	free(a);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	vector<int> v = { x1,x2,x3,x4,x5 };
	for (int i = 0; i < v.size(); i++) {
		if (v[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3628
/*input
10 7 5
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  100005
void solve()
{
	lld n,a,b;
	cin >> n >> a >> b;
	cout << min(a,b) << " " << max(0LL,a+b-n) << endl;	 
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};



int main() {

    ll H,W,K;
    cin >>H>>W>>K;
    vector<string> S(H+1);
    rep(i,H) cin >>S[i];
    vector<vector<ll>> R(H+1,vector<ll>(W+1));
    vector<vector<ll>> R2(H+1,vector<ll>(W+1));
    rep(i,H) rep(j,W) R[i][j] = ctoi(S[i][j]);
    R2 = R;
    if(K<=1){
        ll ans = 0;
        ll min = INF;
        rep(i,H){
            rep(j,W){
                chmin(min,R[i][j]);
                ans+=R[i][j];
            }
        }
        cout << ans-min<<endl;
        return 0;
    }


    ll fans = 0;
    rep(h,H) rep(w,W){
    ll ans = 0;
    R=R2;
    R[h][w] = -1;
    ll flag = 0;
    rep(m,H){
        ll p2 =pow(2,m); 
        rep(j,W){
            vector<ll> tmp;
            rep(i,H){
                if(R[H-1-i][j] != -1){
                    tmp.pb(R[H-1-i][j]);
                }
            }
            rep(i,H){
                if(i<tmp.size()){
                    R[H-1-i][j] = tmp[i];
                }else{
                    R[H-1-i][j] = -1;
                }
            }
        }
        rep(i,H){
            ll cnt=0;
            ll p=-1;
            rep(j,W){
                if(R[i][j] == p && R[i][j] != -1){
                    cnt++;
                    if(j==W-1){
                        if(cnt>=K){
                            flag = 1;
                            ans += R[i][j-1]*cnt*p2;
                            rep(k,cnt){
                               R[i][j-k] = -1;
                            }
                        }
                    }
                }else{
                    if(cnt>=K){
                        flag = 1;
                        ans += R[i][j-1]*cnt*p2;
                        rep(k,cnt){
                            R[i][j-k-1] = -1;
                        }
                    }
                    cnt = 1;
                }
                

                p = R[i][j];
            }
        
        
        }

        if(flag ==0) break;
    }


        chmax(fans,ans);
    }

    cout << fans<<endl;
    
    return 0;
    

}


Measured memory_bytes: 4112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    if (a >= k) {
        cout << 1 << endl;
        return 0;
    }

    k -= a;
    a -= b;
    if (a > 0) {
        cout << (k + a - 1) / a * 2 + 1 << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
from collections import defaultdict


def main():
    A, B = [int(a) for a in input().split()]
    # MAP = [list(input().strip()) for _ in range(N)]

    if A % 2 != 0 and B % 2 != 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    long long n;
    cin>>n;
    map<long long, long long> mp;
    std::vector<long long> v(n);
	for(long long  i=0; i<n; i++){
        long long  wk; cin>>wk; mp[wk]++;
		v[i]=wk;
    }
	ll ans,sum;
	ans=0;
	sum=0;
	for(long long i=1;i<=n;i++){
		sum+=mp[i]*(mp[i]-1)/2;
	}
	
	for(long long i=0;i<n;i++){
		if(mp[v[i]]>=2){
			mp[v[i]]--;
			ll wk=mp[v[i]]*(mp[v[i]]-1)/2;
			mp[v[i]]++;
			ll wk1=mp[v[i]]*(mp[v[i]]-1)/2;
			printf("%lld\n",sum-(wk1-wk));
	    }
		else{
			printf("%lld\n",sum);
		}
	}
	
	return 0;
}


Measured memory_bytes: 16768
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

#define int long long
#define double long double
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << '\n';
#define fi first
#define se second
#define pb push_back
//typedef long long ll;
typedef pair<int, int> pii;
 
void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

const int mod = 1e9 + 7;

int add(int a, int b) {
	a += b;
	if (a >= mod) return a - mod;
	return a;
}

int mult(int a, int b) {
	return a * b % mod;
}

int sub(int a, int b) {
	a -= b;
	if (a < 0) return a + mod;
	return a;
}

const int N = 2010;
int c[N][N];

signed main() {
	fast();
	int s;
	cin >> s;
	for (int i = 0; i < N; i++) {
		c[i][0] = c[i][i] = 1;
	}
	for (int i = 2; i < N; i++) {
		for (int j = 1; j < i; j++) {
			c[i][j] = add(c[i - 1][j], c[i - 1][j - 1]);
		}
	}
	int res = 0;
	for (int i = 1; 3 * i <= s; i++) {
		res = add(res, c[s - 2 * i - 1][i - 1]);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 26420
// IOI 2021
 
#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 998244353;//1e9 + 7;

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

const int N = 3e5 + 5;

int FAC[N], INV[N];

int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}
int C(int n, int k) { return k > n ? 0 : 1LL * INV[k] * INV[n - k] % MOD * FAC[n] % MOD; }

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	FAC[0] = 1;
	for (int i = 1; i < N; i++) FAC[i] = 1LL * FAC[i - 1] * i % MOD;
	INV[N - 1] = Power(FAC[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; i--) INV[i] = 1LL * INV[i + 1] * (i + 1) % MOD;
	
	int n, a, b, ans = 0; cin >> n >> a >> b;
	ll k; cin >> k;
	for (int i = 0; i <= n && k >= 0; i++, k -= a) {
		if (k % b != 0 || k / b > n) continue;
		ans = (ans + 1LL * C(n, i) * C(n, k / b) % MOD) % MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n, m, d = getList()
    if d == 0:
        each = n
    else:
        each = (n - d) * 2
    # igai = pow(n, m-2)
    all = each * (m-1) / (n * n)
    ans = all

    print(ans)
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 69112
N = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[N-1])

Measured memory_bytes: 38384
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
ans = 1000
left = 0
right = 0
while left < n:
    right = left
    while right + 1 < n and a[right] <= a[right + 1]:
        right += 1
    ans = ans // a[left] * a[right] + ans % a[left]
    left = right
    left += 1
print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  int N=S.size();
  int s=0;
  int odd=0;
  int even=0;
  char prev='R';
  int ans[N];
  REP(i,N)ans[i]=0;
  REP(i,S.size()){
    if(prev!=S[i] and S[i]=='L'){
      if((i-s)%2==0){
        ans[i]+=even;
        ans[i-1]+=odd;
      }else{
        ans[i]+=odd;
        ans[i-1]+=even;
      }
      odd=0;
      even=0;
      s=i;
    }else if(prev!=S[i] and S[i]=='R'){
      ans[s]+=even;
      ans[s-1]+=odd;
      odd=0;
      even=0;
      s=i;
    }
    if((i-s)%2==0)even++;
    else odd++;
    prev = S[i];
  }
  ans[s]+=even;
  ans[s-1]+=odd;
  REP(i,N)cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}


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

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

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

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

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

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

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


void Main() {
	ll N; cin >> N;
	vll A(N); cin >> A;
	bool flag = true;
	for (int i = 0; i < N-1; i++) {
		flag &= (A[i] < A[i+1]);
	}
	if (flag) { cout << 1 << endl; return; }
	
	int ng = 1, ok = 300000;
	while (abs(ng-ok) > 1) {
		int p = (ng+ok)/2;
		int cnt[105] = {};
		for (int i = 1; i < N; i++) {
			if (A[i-1] >= A[i]) {
				if (A[i] < 105) {
					cnt[A[i]]++;
					for (int j = A[i]; j > 0; j--) {
						if (cnt[j] == p) {
							cnt[j] = 0;
							cnt[j-1]++;
						}
					}
					for (int j = A[i]+1; j < 105; j++) {
						cnt[j] = 0;
					}
				}
			}
		}	
		if (cnt[0] == 0) ok = p;
		else ng = p;
	}
	cout << ok << endl;
}

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


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a[9]={1,2,3,4,5,6,7,8,9},b[9]={1,2,3,4,5,6,7,8,9};
	int N,flag=0;;
	scanf("%d",&N);
	int i,j;
	int num = 0;
	int c[10010];
	for(i=0;i<9;i++)
      {
      	for(j=0;j<9;j++)
      	c[num++]=a[i]*b[j];
      }
    for(i=0;i<=num-1;i++)
	{
	if(c[i]==N){
		flag=1;
	break;
}
}
	{
		if(flag==1)
		printf("Yes");
		else
		printf("No");
	}
	
	return 0;
}
	

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	cin>>t;
	if(400<=t&&t<=599)cout<<8;
	else
	if(600<=t&&t<=799)cout<<7;
	else
	if(800<=t&&t<=999)cout<<6;
	else
	if(1000<=t&&t<=1199)cout<<5;
	else
	if(1200<=t&&t<=1399)cout<<4;
	else
	if(1400<=t&&t<=1599)cout<<3;
	else
	if(1600<=t&&t<=1799)cout<<2;
	else
	cout<<1;
	return 0;
}

Measured memory_bytes: 3608
import numpy as np

a,b,h,m=list(map(int,input().split()))

deg = min(abs(h*360/12+m*360/12/60-m*360/60),360-abs(h*360/12+m*360/12/60-m*360/60))
theta = deg * np.pi /180
ans = np.sqrt(np.power(a,2)+np.power(b,2)-2*a*b*np.cos(theta))

print(ans)

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

using namespace std;
using ll = long long;

// Utility
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll lmin(ll a,ll b){return a>b?b:a;}
ll lmax(ll a,ll b){return a>b?a:b;}

// Sorting
void insertionSort(int n,int*a,int g=1){for(int i=g;i<n;++i){int v=a[i],j=i-g;while(j>=0&&a[j]>v){a[j+g]=a[j];j-=g;}a[j+g]=v;}}
void shellSort(int n,int*a){vector<int>G;for(int h=1;;){if(h>n)break;G.push_back(h);h=3*h+1;}for(int i=G.size()-1;i>=0;--i)insertionSort(n,a,G[i]);}
int bubbleSort(int n,int*a){int s=0,j;bool f=1;for(int i=0;f;++i){f=0;for(j=n-1;j>=i+1;--j){if(a[j]<a[j-1]){swap(a[j],a[j-1]);f=1;s++;}}}return s;}
int selectionSort(int n,int*a){int s=0,j,m;for(int i=0;i<n-1;++i){m=i;for(j=i;j<n;++j)if(a[j]<a[m])m=j;swap(a[i],a[m]);if(i!=m)++s;}return s;}

// Searching
int binarySearch(int n,int*a,int k){int m,l=0,r=n;while(l<r){m=l+(r-l)/2;if(k<a[m])r=m;else if(a[m]<k)l=m+1;else return m;}return-1;}

// Mathematics
int gcd(int a,int b){!b?a:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}

// Visualization
void printArray(int n,int*a){for(int i=0;i<n;++i)printf(i>0?" %d":"%d",a[i]);printf("\n");}

int main(){
	ll a,b,k;
	cin >> a >> b >> k;
	if(a >= k){
		cout << a-k << " " << b << endl;
	}else if(a+b > k){
		cout << 0 << " " << b-(k-a) << endl;
	}else{
		cout << 0 << " " << 0 << endl;
	}
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;
vi a,b;
int suma,sumb;
vi diff;
int ans;
int req;

signed main(){

    in(n);
    resz(n,a,b,diff);
    in(a);
    in(b);
    rep(i,n){
        suma+=a[i];
        sumb+=b[i];
        diff[i]=a[i]-b[i];
        if(diff[i]<0) {
            ans++;
            req-=diff[i];
        }
    }
    if(suma<sumb){
        out(-1);
        return 0;
    }
    sort(rall(diff));
    //show(diff,req);
    rep(i,n){
        if(req<=0){
            ans+=i;
            break;
        }
        req-=diff[i];
    }

    out(ans);

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lld long double
#define vc vector
typedef pair<ll,ll>pairs;
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,r,c,f;
	cin>>n;
	vector<ll>a(n+1);
	map<ll,ll>m;
	i=1;
	while(i<=n)
	{
	    cin>>a[i];
	    if(m.find(a[i])==m.end())
	    m.insert({a[i],1});
	    else
	        m[a[i]]++;
	    i++;
    }
    sort(a.begin()+1,a.end());
    ll mi=a[1];
    /*if(m.size()==1)
    {
        cout<<0;
        exit(0);
    }*/
	j=1;c=0;
	for(i=1;i<=n;i++)
	{
	    f=1;
	    k=a[i];
	    if(m[k]>1)
	        continue;
	    if(m.find(1)!=m.end()&&a[i]!=1)
	        {
	            if(a.size()!=2)
	            {
	                f=0;break;
	            }
	        }
	    for(j=2;(j*j<=k)&&(k/j>=mi);j++)
	    {
	        
	        if(k%j==0)
	        {
	             if(m.find(j)!=m.end()||m.find(k/j)!=m.end())
	            {
	                f=0;
	                break;
	            }
	            
	        }
	    }
	    if(f)
	    {
	        c++;
	        //i++;
	    }
	    
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 17096
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n,k,a,b;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>a>>b;
		int r=min(min(b-1,n-b),min(a-1,n-a));
		int c=r%3+1;
		cout<<c<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  vector<int64_t> x(87);
  x.at(0) = 2;
  x.at(1) = 1;
  int N;
  cin >> N;
  for(int i = 2; i < N+1; i++){
    x.at(i) = x.at(i-2) + x.at(i-1);
  }
  cout << x.at(N);
}
  

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

int main(){

  int N, K, ans=0;
  cin >> N >> K;
  int x[N];
  for(int i=0; i<N; i++){
    cin >> x[i];
  }

  for(int i=0; i<N; i++){
    ans += 2*min(x[i], K-x[i]);
  }

  cout << ans << endl;

  return 0;
}

// 

Measured memory_bytes: 256
local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs

local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

local function getdivisorparts(x, primes)
  local prime_num = #primes
  local tmp = {}
  local lim = mce(msq(x))
  local primepos = 1
  local dv = primes[primepos]
  while primepos <= prime_num and dv <= lim do
    if x % dv == 0 then
      local t = {}
      t.p = dv
      t.cnt = 1
      x = mfl(x / dv)
      while x % dv == 0 do
        x = mfl(x / dv)
        t.cnt = t.cnt + 1
      end
      table.insert(tmp, t)
      lim = mce(msq(x))
    end
    if primepos == prime_num then break end
    primepos = primepos + 1
    dv = primes[primepos]
  end
  if x ~= 1 then
    local t = {}
    t.p, t.cnt = x, 1
    table.insert(tmp, t)
  end
  return tmp
end

local n, p = io.read("*n", "*n")
local primes = getprimes(1000000)
local dvp = getdivisorparts(p, primes)
local ret = 1
for id = 1, #dvp do
  local v, cnt = dvp[id].p, dvp[id].cnt
  local z = cnt // n
  for i = 1, z do
    ret = ret * v
  end
end
print(ret)


Measured memory_bytes: 20664
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <set>
typedef long long ll;

using namespace std;

int main()
{
    ll x,n,i,ans=10000001;
    cin>>x>>n;
    ll a;
    set<ll>s;
    for(i=0; i<n; i++)
    {
        cin>>a;
        s.insert(a);
    }
    ll pos=10000001;
    for(i=-150; i<=150; i++)
    {
        if(s.count(i))
            continue;
        if(abs(x-i)<ans)
        {
            pos=i;
            ans=abs(x-i);
        }
    }
    cout<<pos<<endl;
}





Measured memory_bytes: 3152
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	while (k > 0) {
		if (a >= b) {
			b *= 2;
			k--;
		}
		else break;
	}
	while (k > 0) {
		if (b >= c) {
			c *= 2;
			k--;
		}
		else break;
	}
	if (a < b && b < c)print("Yes");
	else print("No");
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>

typedef long long LL;

const int N = 1e5 + 1;

int pa[N];
LL v[N];

void init() {
  for (int i = 0; i < N; ++i) {
    pa[i] = i;
    v[i] = 0;
  }
}

int find(int x) {
  if (x != pa[x]) {
    int p = pa[x];
    pa[x] = find(pa[x]);
    v[x] += v[p];
  }
  return pa[x];
}

void unite(int x, int y, int z) {
  int px = find(x);
  int py = find(y);
  if (px != py) {
    pa[px] = py;
    v[px] = v[y] - v[x] + z;
  }
}

bool check(int x, int y) {
  int px = find(x);
  int py = find(y);
  return px == py;
}

int main() {
  int n, q;
  while (std::cin >> n >> q) {
    init();
    while (q --) {
      int op;
      std::cin >> op;
      if (op == 0) {
        int x, y, z;
        std::cin >> x >> y >> z;
        unite(x, y, z);
      } else {
        int x, y;
        std::cin >> x >> y;
        if (check(x, y)) {
          std::cout << v[x] - v[y] << std::endl;
        } else {
          std::cout << "?" << std::endl;
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 5468
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());		

const ll mod=1e9+7;

map<ll,priority_queue<ll>>fact;

void factorize(int n)
{
	for(int i=2;i*i<=n;i++)
	{
		ll cnt=0;
		while(n%i==0)
		{
			n/=i;
			cnt++;
		}
		if(cnt) fact[i].push(cnt);
	}
	
	if(n>1) fact[n].push(1);
}

void solve()
{
	int n;
	cin>>n;
	
	vector<ll>vec(n);
	for(ll &x: vec) cin>>x;
	
	for(ll x: vec) factorize(x);
	
	auto add=[&](ll a,ll b)
	{
		return (a+b)%mod;
	};
	
	auto mul=[&](ll a,ll b)
	{
		return (a*b)%mod;
	};
	
	auto power=[&](ll b,ll k)
	{
		ll ans=1;
		for(;k>0;k/=2,b=mul(b,b))
		{
			if(k&1) ans=mul(ans,b);
		}
		return ans;
	}; 
	
	ll l=1;
	
	for(auto it: fact)
	{
		ll b=it.first;
		ll k=it.second.top();
		
		l=mul(l,power(b,k));
	}
	
	ll sum=0;
	
	for(ll x: vec)
	{
		ll temp=mul(power(x,mod-2),l);
		sum=add(sum,temp);
	}
	
	cout<<sum;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 4792
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>


namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  usize k = scan<usize>();

  std::vector<u64> h(n);
  for (auto &e : h) {
    std::cin >> e;
  }
  std::sort(h.begin(), h.end(), std::greater<>());
  u64 ans = 0;
  for (const auto e : h) {
    if (k > 0) {
      k -= 1;
    } else {
      ans += e;
    }
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define SUCCESS 0LL
#define FAIL -1LL
#define DEBUG 0

using namespace std;

typedef long long ll;

ll array_size[256];
map<ll, ll > array[256];
bool ans;

class Parser
{
public:
	string exp;
	void program (void );
	ll assignment (string );
};

ll stoll (string s )
{
	stringstream ss (s );
	ll res;
	ss >> res;

	return res;
}

// ツ配ツ療アツづ鳴づ個妥」ツ禿シ
ll Parser::assignment (string str )
{
	if (isdigit (str[0] ) ){
		ll value = stoll (str );
		return value;
	} // end if

	ll val = assignment (str.substr (2, str.length()-3 ) );
	int v = str[0];	
	if (array[v].find (val ) == array[v].end() ){
		ans = false;
	} // end if

	return array[v][val];
}

void Parser::program (void )
{
	rep (i, exp.length() ){
		if (exp[i] == '=' ){
			ll right = assignment (exp.substr (i+1 ) );
			ll left  = assignment (exp.substr (2, i-3 ) );
			if (left >= array_size[(int)exp[0]] ){
				ans = false;
			} // end if
			array[(int)exp[0]][left] = right;
			return;
		} // end if
	} // end rep

	string val = exp.substr (2, exp.length() - 3 );
	array_size[(int)exp[0]] = stoll (val );
}


int run (vector <string> row )
{
	Parser parser;
	int n = row.size();
	rep (i, n ){
		ans = true;
		parser.exp = row[i];
		parser.program ();
		if (ans == false ){
			return i+1;
		} // end if
	} // end rep

	return 0;
}

void init_val (void )
{
	rep (i, 256 )
		array[i].clear();
	memset (array_size, 0, sizeof (array_size ) );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.bug_hunt", "r", stdin );
	string in = "";
	vector <string> row;
	init_val ();
	row.clear();
	while (cin >> in ){
		if (in == "." ){
			int res = run (row );
			cout << res << endl;
			init_val();
			row.clear();
			cin >> in;
			if (in == "." ) 
				break;
			else
				row.push_back (in ); 
		}else{
			row.push_back (in );
		} // end if
	} // end loop

//	printf ("%d\n", res );
		
	return 0;
}

Measured memory_bytes: 1080
use std::io::{Write, stdout, BufReader};
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_until<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {break;}
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
}
fn main() {
    let stdin = std::io::stdin();
    let stdin = BufReader::new(stdin.lock());
    let stdout = std::io::stdout();
    let stdout = stdout.lock();
    let read = Read::new(stdin);
    solve(read, stdout);
}

fn solve<R: std::io::BufRead>(mut r: Read<R>, mut o: std::io::StdoutLock) {
    let n:usize = r.read_until();
    let m:usize = r.read_until();
    let c:i32 = r.read_until();
    let mut b:Vec<i32> = Vec::new();
    let mut a:Vec<Vec<i32>> = Vec::with_capacity(n * m);
    for i in 0..m {
        b.push(r.read_until());
    }
    for i in 0..n {
        a.push(Vec::new());
        for j in 0..m {
            a[i].push(r.read_until());
        }
    }
    let mut ans = 0;
    for i in 0..n {
        let mut sum:i32 =0;
        for j in 0..m {
            sum+=a[i][j]*b[j];
        }
        if sum + c > 0 {
            ans += 1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4476
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
  A = list(map(int, input().split()))
  sum = 0
  for j in range(M):
    sum += A[j]*B[j]
  if sum+C > 0:
    ans += 1
print(ans)


Measured memory_bytes: 3060
L = "qwertasdfgzxcvb"
while 1:
	key = raw_input()
	if key == "#": break
	c = 0
	h = 1 if key[0] in L else 0
	for i in range(1,len(key)):
		p = 1 if key[i] in L else 0
		c += abs(h-p)
		h = p
	print c

Measured memory_bytes: 4216
#include<stdio.h>
int main()
{
  int n,i;
  n<999;
  scanf("%d",&n);
  i=n%10;
  switch(i)
  {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9: printf("hon");break;
  case 0:
  case 1:
    case 6:
    case 8: printf("pon");break;
    case 3: printf("bon");break;

  }
  return 0;
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int n;
long long k;
vector<pii>f;
int main() {
 cin >> n >> k;
 for(int i = 1; i <= n; ++i) {
     int a, b; cin >> a >> b;
     f.push_back(pii(a, b));
 }
sort(f.begin(), f.end());
long long t = 0;
for(int i = 0; i < n; ++i) {
t += f[i].second;
if (t >= k) {
 cout << f[i].first << endl;
return 0;
}
}
}

Measured memory_bytes: 1400
from collections import*
class u():#UnionFind f-根探し u-連結 s-連結? c-要素数
  def __init__(self,n):self.n,self.r=[-1]*n,[0]*n
  def f(self,x):
    if self.n[x]<0:return x
    else:self.n[x]=self.f(self.n[x]);return self.n[x]
  def u(self,x,y):
    x,y=self.f(x),self.f(y)
    if x==y:return
    elif self.r[x]>self.r[y]:self.n[x]+=self.n[y];self.n[y]=x
    else:self.n[y]+=self.n[x];self.n[x]=y;self.r[y]+=self.r[x]==self.r[y]
  def s(self,x,y):return self.f(x)==self.f(y)
  def c(self,x):return -self.n[self.f(x)]
n,k,l=map(int,input().split())
d=u(n);t=u(n)
for _ in range(k):a,b=map(int,input().split());d.u(a-1,b-1)
for _ in range(l):a,b=map(int,input().split());t.u(a-1,b-1)
p=[(d.f(i),t.f(i))for i in range(n)]
c=Counter(p)
print(*[c[p[i]]for i in range(n)])

Measured memory_bytes: 47332
import Control.Monad(replicateM)
main = do
    [as,bs,cs,x] <- replicateM 4 readLn :: IO [Int]
    print $ length [a+b+c | a <- [0..as],b <- [0..bs],c <- [0..cs],500*a + 100*b + 50*c == x]

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<int> enumdiv(int n) { 
    vector<int> S;
    for (int i = 1; 1LL*i*i <= n; i++) if (n%i == 0) { S.push_back(i); if (i*i != n) S.push_back(n / i); }
    sort(S.begin(), S.end());
    return S;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;

    int ans = 0;
    rep(i, 1, N + 1) if (i % 2 == 1) {
        auto ed = enumdiv(i);
        if (ed.size() == 8) ans++;
    }
    cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main() {
    string s;
    cin>>s;
    int y=700;
    if(s[0]=='o')y+=100;
    if(s[1]=='o')y+=100;
    if(s[2]=='o')y+=100;
    cout<<y<<endl;
    return 0;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var (
	s string
	k int64
)

func main() {
	fmt.Scanln(&s)
	fmt.Scanf("%d\n",&k)
	for _,x := range s {
		v := x-48
		if v==1{
			k-=1
			if k<=0 {
				fmt.Println(1)
				break
			}
		}	else {
			k-=int64(math.Pow(float64(v),5*math.Pow(10,15)))
			if k<=0 {
				fmt.Println(v)
				break
			}
		}
	}
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;

inline int read()
{
  char ch=getchar(); int p=0; int f=1;
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}

int n;
int sum[N]; int a[N];

int main()
{

  n=read(); n+=2; a[1] = a[n] = 0; for(int i=2;i<n;i++) a[i] = read();
  for(int i=1;i<=n;i++) sum[i] = sum[i-1] + abs(a[i] - a[i-1]);
  for(int i=2;i<n;i++)
  {
    printf("%d\n",sum[i-1] + (sum[n] - sum[i+1]) + abs(a[i-1] - a[i+1]));
  }

  return 0;
}

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

int main() {
    string S;
    cin >> S;
    if (S.at(0) == 'A') {
        int cnt = 0;
    
        for (int i=2;i<S.size()-1;i++) {
            if (S.at(i) == 'C') {
                cnt++;
                S.at(i) = tolower(S.at(i));
        }
        if(cnt == 1) {
            for (int j=1;j<S.size();j++){
                if (!islower(S.at(j))) break;
                if (j == S.size()-1) {
                    cout << "AC" << endl;
                    return 0;
                }
            }
        }
    }
    }
    cout << "WA" << endl;
}


Measured memory_bytes: 3632