akhauriyash/Code-Regression huggingface dataset:
using System;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int cycle = 1;
            while (true)
            {
                int input = int.Parse(Console.ReadLine());
                if (input == 0)
                {
                    return;
                }
                Console.WriteLine("Case " + (cycle++) + ": " + input);
            }
        }
    }
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    int val = c - b;
    if (val <= 0) cout << "delicious";
    else if (val <= a) cout << "safe";
    else cout << "dangerous";
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
int main() {
    string s;
    cin >> s;

    for(int i = 0; i < 3; i++){
        if(s[i] == '1'){
            s[i] = '9';
        }else if(s[i] == '9'){
            s[i] = '1';
        }
    }

    cout << s;

}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ba = b - a > 0 ? b - a : -(b - a);
  int cb = c - b > 0 ? c - b : -(c - b);
  int ca = c - a > 0 ? c - a : -(c - a);
  if (ba <= d && cb <= d || ca <= d) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <stack>

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string S = buf;

  int res = 0;
  std::stack<char> st;
  for (auto c: S) {
    if (st.empty() || st.top() == c) {
      st.push(c);
    } else {
      st.pop();
      res += 2;
    }
  }
  printf("%d\n", res);
}


Measured memory_bytes: 512
import sys

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

n=int(input())
ap=list(map(int,input().split()))
amin=min(ap)
amax=max(ap)

if amax==1:
    print("pairwise coprime")
    sys.exit()

if amin!=1:
    bp=enum_div(amin)+[amin]
#    bp.sort()
    bp=bp[1:]
    for bpi in bp:
        yn=""
        for ai in ap:
            if ai%bpi!=0:
                yn="coprime"
                break
        if yn=="":
            print("not coprime")
            sys.exit()

if n>=78500 :
    print("setwise coprime")
    sys.exit()

aa=[0]*(amax+1)
for ai in ap:
    aa[ai]+=1

#p=get_primenumber(amax)

#for pp in p:
for pp in range(2,amax+1):
    psum=sum(aa[pp: :pp])
#    print("pp:",pp,psum)
    if psum>=2:
            print("setwise coprime")
            sys.exit()
## max_13.txt ... max_16.txt : "setwise coprime"
print("pairwise coprime")
   


Measured memory_bytes: 181040
while True:
    kei = 0
    i = int(input())
    if i == 0:
        break
    else:
        num = 1000 - i
        if num >= 500:
            num %= 500
            kei += 1
        if num >= 100:
            num1 = num // 100
            kei += num1
            num %= 100
        if num >= 50:
            num %= 50
            kei += 1
        if num >= 10:
            num1 = num // 10
            kei += num1
            num %= 10
        if num >= 5:
            num %= 5
            kei += 1
        if num >= 1:
            num1 = num // 1
            kei += num1
    print(kei)


Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S,T;cin>>S>>T;
    int ans=INF;
    for(int i=0;i<si(S);i++){
        if(i+si(T)>si(S)) continue;
        int sum=0;
        for(int j=0;j<si(T);j++){
            if(S[i+j]!=T[j]) sum++;
        }
        chmin(ans,sum);
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int n, k, s;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> k >> s;
	
	for (int i = 0; i < k; ++i) cout << s << ' ';
	
	if (s + 1 <= 1e9) 
		for (int i = 0; i < n - k; ++i) cout << s + 1 << ' ';
	else
		for (int i = 0; i < n - k; ++i) cout << s - 1 << ' ';
	cout << '\n';
	
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	llong a,b,k;
	cin>>a>>b>>k;
	
	if(a>=k){
		a-=k;
		cout<<a<<' '<<b<<endl;
		return 0;
	}
	
	k-=a;
	a=0;
	if(b>=k){
		b-=k;
	}else{
		b=0;
	}
	
	cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:

    void rec(Int i, string s = "", char next = 'a') {
        if (i == 0) {
//            for (auto e : s) {
//
//            }
            cout << s << endl;
            return;
        }

        for (char c = 'a'; c < next; ++c) {
            string t = s;
            t += c;
            rec(i - 1, t, next);
        }
        string t = s;
        t += next;
        rec(i - 1, t, static_cast<char>(next + 1));
    }

    void solve() {
        Int N;
        cin >> N;

        rec(N);
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1536
n = int(input())

a = list(map(int, input().split()))

a = sorted(a)

m = a[-1]
f = 1
if m % 2 == 1:
    s = m // 2 + 1
    count = 0
    if n == 2:
        if a[0] != 1 or a[1] != 1:
            f = 0
    elif a[0] != s or a[2] == s:
        f = 0
    else:
        for i in range(n):
            if a[i] < s:
                continue
            elif a[i] == s:
                if count == 0:
                    count = 1
                else:
                    count = 0
                    s += 1
            else:
                f = 0
                break
        if count == 1:
            f = 0
else:
    s = m // 2 + 1
    count = 0
    if a[0] != s-1 or a[1] == s-1:
        f = 0
    else:
        for i in range(1, n):
            if a[i] < s:
                continue
            elif a[i] == s:
                if count == 0:
                    count = 1
                else:
                    count = 0
                    s += 1
            else:
                f = 0
                break
        if count == 1:
            f = 0
        
if f == 1:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 3064
<?php
list($n, $m) = explode(" ", trim(fgets(STDIN)));
$array = explode(" ", trim(fgets(STDIN)));
sort($array);
$d = [];
for($i = 0; $i < $m - 1; $i++){
    $d[] = $array[$i + 1] - $array[$i];
}
sort($d);
for($i = 1; $i < $n; $i++){
    array_pop($d);
}
echo array_sum($d);

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

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


Measured memory_bytes: 256
def func():
    n = int(input())
    a = [str(bin(int(x))) for x in input().split()]
    cnt = float('inf')
    for i in range(n):
        cnt = min(cnt, len(a[i]) - 1 - a[i].rfind('1'))
    print(cnt)


if __name__ == "__main__":
    func()

Measured memory_bytes: 9084
loop do
  n, m = gets.split.map(&:to_i)
  break if n==0 && m==0

  current_state = 1
  rules = Array.new(n) { |i| i = 0 }
  actions = Array.new(m) { |i| i = 0 }

  n.times do |i|
    rules[i] = gets.to_i
  end

  m.times do |i|
    actions[i] = gets.to_i
  end

  actions.each_with_index do |action, i|
    current_state += action
    if current_state >= n
      p i+1
      break
    end
    current_state += rules[current_state-1]
    if current_state >= n
      p i+1
      break
    end
  end
end

Measured memory_bytes: 8696
def get_min(h, w):
    res = float("inf")
    for i in range(1, h):
        up = [w // 2 * i, (w - w // 2) * i, w * (h - i)]
        res = min(res, max(up) - min(up))
        down = [w * i, w // 2 * (h - i), w - (w - w // 2) * (h - i)]
        res = min(res, max(down) - min(down))
    return res


H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()

ans = min(H, W)
ans = min(ans, get_min(H, W))
ans = min(ans, get_min(W, H))
print(ans)


Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(auto& v: a) scanf("%lld", &v);

	i64 ans = 1000;
	std::vector<i64> dp(202); dp[201] = 1000;
	for(int i = 0; i < n; i++) {
		std::vector<i64> to = dp;
		for(int j = 0; j < 200; j++) {
			i64 nxt = j + dp[j] * a[j];
			
			to[201] = std::max(to[201], j + dp[j] * a[i]);
		}

		i64 now = to[201];
		to[now % a[i]] = now / a[i];

		ans = std::max(ans, now);
		dp.swap(to);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

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

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> input = Arrays.asList(br.readLine().split(""));
            
            String ans = "";
            for (int i = 0; i < input.size(); i++) {
                if (!input.get(i).equals("B")) {
                    ans += input.get(i);
                } else {
                    if (ans.length() > 0) {
                        ans = ans.substring(0, ans.length() - 1);
                    }
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
const int maxn=1e5+5;
typedef pair<int,int> par;

par dp[maxn];

par ins(par a,par b){
	par ans;
	ans.X=max(a.X,b.X);
	ans.Y=min(a.Y,b.Y);
	return ans;
}

int n,k;
vector<int>G[maxn];
int fa[maxn];
int a[maxn];

bool flag=1;
const int inf=1e6;
int col[maxn];
void dfs(int u){
	for(auto v:G[u]){
		if(v==fa[u])continue;
		fa[v]=u;
		col[v]=col[u]^1;
		dfs(v);
	}
	if(a[u]==-1){	
		dp[u]=par(-inf,inf);
		for(auto v:G[u]){
			if(v==fa[u])continue;
			dp[u]=ins(dp[u],par(dp[v].X-1,dp[v].Y+1));
		}
	}else{
		dp[u]=par(a[u],a[u]);
		for(auto v:G[u]){
			if(v==fa[u])continue;
			dp[u]=ins(dp[u],par(dp[v].X-1,dp[v].Y+1));
		}
	}
}
int anss[maxn];
void dfs2(int u){

	if(dp[u].X==dp[u].Y){
		anss[u]=dp[u].X;
	}else{
		if(dp[u].X<=anss[fa[u]]-1&&anss[fa[u]]-1<=dp[u].Y){
			anss[u]=anss[fa[u]]-1;
		}else{
			anss[u]=anss[fa[u]]+1;
		}
	}
	for(auto v:G[u]){
		if(v==fa[u])continue;
		fa[v]=u;
		dfs2(v);
	}
}


int main(){
	memset(a,-1,sizeof a);
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int k;
	scanf("%d",&k);
	int root=1;
	for(int i=1;i<=k;i++){
		int x,y;scanf("%d%d",&x,&y);
		root=x;
		a[x]=y;
	}
	col[root]=a[root]&1;
	
	dfs(root);

	for(int i=1;i<=n;i++){

//		printf("%d:[%d,%d]\n",i,dp[i].X,dp[i].Y);

		if(dp[i].X>dp[i].Y)
			flag=0;
		if(dp[i].X==dp[i].Y&&(dp[i].X&1)!=col[i])
			flag=0;
	}
	if(!flag){
		puts("No");
		return 0;
	}
	dfs2(root);

	puts("Yes");
	for(int i=1;i<=n;i++)
		printf("%d\n",anss[i]);
	return 0;
}

Measured memory_bytes: 14976
#include<iostream>
 
int main()
{
	using namespace std;
	int a,b,c,x,y,t;
	int flag=0;
	long int sum=0;
	cin>>a>>b>>c>>x>>y;
	double aver=(a+b)/2;
	if(aver>c)
	{
		t=x-y;
		if(t<0)      //x<y
		{
			t*=-1;
			sum+=x*c*2;
			sum+=t*b;
			if(sum>y*c*2)
			{
				sum=y*c*2;
			}
		}
		else{
			sum+=y*c*2;
			sum+=t*a;
			if(sum>c*x*2)
			{
				sum=c*x*2;
			}
		}
	}
	else
	{
		sum+=a*x+b*y;
		if(sum>c*2*(x<y?y:x))
			sum=c*2*(x<y?y:x);
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	string s;
	cin >> s;
	if(s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(ReadLine());
            var aArray = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            var q = long.Parse(ReadLine());
            var queries = new long[q][];
            for(var i = 0; i < q; i++)
            {
                queries[i] = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            }

            long sum = 0;
            var dictionary = new Dictionary<long, int>();
            foreach(var a in aArray)
            {
                sum += a;

                if(!dictionary.ContainsKey(a))
                {
                    dictionary.Add(a, 0);
                }
                dictionary[a]++;
            }

            var answers = new List<long>();

            foreach(var query in queries)
            {
                if(!dictionary.ContainsKey(query[0]))
                {
                    answers.Add(sum);
                    continue;
                }
                sum += (query[1] - query[0]) * dictionary[query[0]];
                answers.Add(sum);
                if(!dictionary.ContainsKey(query[1]))
                {
                    dictionary.Add(query[1], dictionary[query[0]]);
                }
                else
                {
                    dictionary[query[1]] += dictionary[query[0]];
                }
                dictionary[query[0]] = 0;
            }

            answers.ForEach(value => WriteLine(value));
        }
    }
}


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

ULL mpow(ULL a,ULL i,ULL M) {
 if(i==0) return 1;
 ULL r=mpow(a*a%M,i>>1,M);
 if(i&1) r=r*a%M;
 return r;
}

// NTT WEST
void NTT(vector<ULL>& A,ULL M,ULL g){
 int N=A.size();
 for(int i=0,j=0; j<N; j++){
  if(i<j) swap(A[i],A[j]);
  for(int k=N>>1; k>(i^=k); k>>=1);
 }
 for(int i=1; i<N; i<<=1){
  ULL q=mpow(g,(M-1)/i/2,M);
  ULL qj=1;
  rep(j,i){
   for(int k=j; k<N; k+=i*2){
    ULL l=A[k],r=A[k+i]*qj%M;
    A[k]=(l+r); if(A[k]>=M) A[k]-=M;
    A[k+i]=(l+M-r); if(A[k+i]>=M) A[k+i]-=M;
   }
   qj=qj*q%M;
  }
 }
}

struct Fuse{ ULL M,G; };

// trinitrotoluene EXPLODING!!
vector<ULL> TNT(const vector<ULL>& A,const vector<ULL>& B,Fuse F) {
 int Z=1; while(Z<A.size()+B.size()) Z<<=1;
 vector<ULL> Ax(Z),Bx(Z);
 ULL iZ=mpow(Z,F.M-2,F.M);
 rep(i,Z) Ax[i]=Bx[i]=0;
 rep(i,A.size()) Ax[i]=A[i];
 rep(i,B.size()) Bx[i]=B[i];
 NTT(Ax,F.M,F.G);
 NTT(Bx,F.M,F.G);
 rep(i,Z) Ax[i]=Ax[i]*Bx[i]%F.M;
 NTT(Ax,F.M,mpow(F.G,F.M-2,F.M));
 rep(i,Z) Ax[i]=Ax[i]*iZ%F.M;
 return move(Ax);
}

const Fuse fuse[2] = {{998244353,3},{1107296257,10}};

LL ExtGcd(LL a,LL b,LL& x,LL& y){
 if(b==0){ x=1; y=0; return a; }
 LL g=ExtGcd(b,a%b,y,x);
 y-=a/b*x;
 return g;
}

struct ModEq{
 ULL c1,c2,t1,t2,M;
 ModEq(LL m1,LL m2) {
  LL buf1,buf2;
  ExtGcd(m1,m2,buf1,buf2);
  c1=(buf1+m2)%m2;
  c2=(buf2+m1)%m1;
  t1=m1; t2=m2;
  M=m1*m2;
 }
 ULL operator()(ULL a1, ULL a2) {
  ULL d=a1+(a2+t2-a1)*c1%t2*t1;
  return d;
 }
};

const ULL M=200003;
int N;
int I[M];
vector<ULL> A;
vector<ULL> C[2];

int main() {
 scanf("%d", &N);
 for (int i = 0, j = 1; i < M - 1; i++, j = j * 2 % M) I[j] = i;
 A.resize(M - 1);
 rep(i, N) {
  int a; scanf("%d", &a);
  if (a) A[I[a]]++;
 }
 rep(i, 2) C[i] = TNT(A, A, fuse[i]);
 ModEq X(fuse[0].M, fuse[1].M);
 rep(i, C[0].size()) C[0][i] = X(C[0][i], C[1][i]);
 rep(i, M - 1) C[0][i * 2] -= A[i];
 for (ULL& c : C[0]) c /= 2;

 ULL ans = 0;
 for (int i = 0, j = 1; i < C[0].size(); i++, j = j * 2 % M)
  ans += C[0][i] * j;

 cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 17976
require("fs").readFileSync("/dev/stdin","utf8").split(/\s/).map(function(i){i?console.log(i>91?'heavy':i>81?'light heavy':i>75?'middle':i>69?'light middle':i>64?'welter':i>60?'light welter':i>57?'light':i>54?'feather':i>51?'bantam':i>48?'fly':'light fly'):0})

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M, X;
    cin >> N >> M >> X;

    Vl C(N);
    vector<Vl> books(N, Vl(M));
    for (ll i = 0; i < N; i++) {
        cin >> C[i];
        for (ll j = 0; j < M; j++) {
            cin >> books[i][j];
        }
    }

    ll ans = L_INF;
    ll charge;
    Vl score;
    for (ll mask = 0; mask < (1LL << N); mask++) {
        score.assign(M, 0);
        charge = 0;

        for (ll i = 0; i < N; i++) {
            if ((mask >> i) & 1) {
                charge += C[i];
                for (ll j = 0; j < M; j++) {
                    score[j] += books[i][j];
                }
            }
        }

        bool great = true;
        for (ll i = 0; i < M; i++) {
            if (score[i] < X) {
                great = false;
                break;
            }
        }

        if (great) {
            ans = min(ans, charge);
        }
    }

    if (ans == L_INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

#define ff        first
#define ss        second
#define int       long long
#define pb        push_back
#define mp        make_pair
#define vi        vector<int>
#define pii       pair<int,int>
#define mii       map<int,int>
#define w(x)      int x; cin>>x; while(x--)
#define all(x)      (x).begin(),(x).end()
#define rep(i,a,b)  for(int i=(a);i<(b);i++)
#define mod       1000000007


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

const int MAXN = 3002;

double dp[MAXN][MAXN],P[MAXN];
int vis[MAXN][MAXN],N;

double solve(int pos,int heads){
    
    if(heads < 0) return 0.0;

    if(pos == 0){
        return (heads == 0);
    }

    if(vis[pos][heads]) return dp[pos][heads];
    vis[pos][heads] = 1;

    return dp[pos][heads] =  (P[pos])*solve(pos-1,heads-1) + (1.0 - P[pos])*solve(pos-1,heads);

}

int32_t main(){
    //c();
    cin >> N;
    for(int i = 1;i<=N;i++){
        cin >> P[i];
    }

    double tot = 0;
    for(int heads = 0;heads<=N;heads++){
        int tails = N - heads;
        if(heads > tails) tot += solve(N,heads);
    }

    printf("%.12lf\n",tot);

    return 0;

}

Measured memory_bytes: 140672
N = int(input())
S = input()
W_count = 0
W_cumulative = []
for i in range(N):
    if S[i] == "W":
        W_count += 1
    W_cumulative.append(W_count)

ans = N
W_cumulative.insert(0,0)
for i in range(1,N+1):
    count = W_cumulative[i-1]
    count += N - W_cumulative[-1] - i + W_cumulative[i]
    ans = min(ans,count)

print(ans)

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll x, y, z;
  cin >> x >> y >> z;
  cout << (x - z) / (y + z) << endl;
  return 0;
}


Measured memory_bytes: 3616
L = input()
B = len(L)

MOD = 10**9 + 7
ans = 0
cnt = 0
for i in range(B):
    if L[i] == '1':
        ans += (pow(2, cnt, MOD) * pow(3, B-i-1, MOD))
        cnt += 1
ans += pow(2, cnt, MOD)
print(ans % MOD)

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

int main()
{
  string S,T,U;
  int A,B;
  cin>>S>>T;
  cin>>A>>B;
  cin>>U;
  if(U.compare(S)==0)
    cout<<(A-1)<<" "<<B;
  else
    cout<<A<<" "<<(B-1);
  
  return 0;
}
  

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
	
		Scanner scan = new Scanner(System.in);
		Scanner scan2 = new Scanner(System.in);
	
	int ak = 0, bk = 0;
	int a, b, j, w, u;
	
	int kai = scan.nextInt();
	
	for(int i=0; i<kai; i++){
		String stra = scan.next();
		String strb = scan.next();
		
		char[] A = stra.toCharArray();
		char[] B = strb.toCharArray();
		
		int x = 0;
		int c = 0;
		
		for(j=0; j<A.length; j++){}
		for(w=0; w<B.length; w++){}
		
		if(j < w){
			u = j;}
		else{
			u = w;}
		
		for(int q=0; q<u; q++){
			a = A[q];
			b = B[q];
			
			if(a < b){
				bk += 3;
				c = 1;
				break;}
			else if(a > b){
				ak += 3;
				c = 1;
				break;}}

			if(c == 0){
				if(j == w){
					ak++;	bk++;}
				else if(j > w){
					ak += 3;}
				else{
					bk += 3;}}}
				
		System.out.println(ak+" "+bk);
	}
}


Measured memory_bytes: 30628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define M_PI           3.14159265358979323846
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	double n;
	cin>>n;
	double x=2*M_PI*n;
	cout<<setprecision(12)<<x;
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <math.h>
using namespace std;
 
int main (){
  	int A,B,C,T[6],ans;
  	cin >> A >> B >> C;
  	
  	T[0] = (A * 10 + B) + C;
  	T[1] = (B * 10 + C) + A;
  	T[2] = (C * 10 + B) + A;
  	T[3] = (B * 10 + A) + C;
  	T[4] = (C * 10 + A) + B;
  	T[5] = (A * 10 + C) + B;
  
  	for(int i = 0;i < 6;i++){
      //cout << T[i] << endl;
    	if(T[i]>T[i - 1]){
        	ans = T[i];
        }
    }
  	cout << ans;
}	

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

int main() {
	int i,a,b,c,count=0;
	cin >> a >> b >> c;
	for (i = a; i <= b; i++) {
		if (c%i == 0) {
			++count;
		}
	}
	cout<< count<<"\n";
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
なぞなぞか
first有利そう

2
2
1

2
2

2  1
1  1

1  1

2 1 0 S
21 2 1 0 F
22 21 2 1 0 S


*/
int main(){
  ll N,b=0; cin>>N;
  for(ll i=0; i<N; i++) {
    ll a; cin>>a;
    if(a%2==1){
      cout<<"first"<<endl;
      return 0;
    }
  }
  cout<<"second"<<endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template <typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n]++;
    }
    return res;
}
template <typename T>
T gcd(T a, T b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    sort(a.rbegin(), a.rend());
    int s = 0;
    rep(i,n)s += a[i];
    string ans;
    if(a[m-1] * 4 * m >=s)ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    cin(i,a);
    ld b = 0.0;
    rep(i,n){
        ld c = 1.0/a[i];
        b += c;
    }
    cout << 1 / b << endl;
    return 0;
}

Measured memory_bytes: 256
/*input
3141592653589793
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
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> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int s(ll n){
	int ret=0;
	while(n){
		ret+=n%10;
		n/=10;
	}
	return ret;
}

int main(){
	IOS;
	ll n;
	cin>>n;
	ll ans=s(n);
	if(ans==1) ans+=9;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(){
    int n;
    double ans = 0.0;
    cin >> n;
    double x[n],y[n];
    char j[3];
    for(int i=0;i<n;i++){
        cin >> x[i] >> j;
        if(j[0]=='J')y[i]=0.0;else y[i]=1.0;
    }
    for(int i=0;i<n;i++){
        if(y[i]==1)ans+=380000.0*x[i];
        else ans+=x[i];
    }
    cout << ans << endl;
}



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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 30001
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

signed main() {
    int count = 0;
    int N;
    string S;
    cin >> N >> S;
    for (int i = 0; i < 1000; i++) {
        int j = 0;
        bool check = false;
        for (; j < N; j++) {
            if ((int)(S[j] - '0') == (i / 100)) {
                break;
            }
        }
        j++;
        for (; j < N; j++) {
            if ((int)(S[j] - '0') == ((i / 10) % 10)) {
                break;
            }
        }
        j++;
        for (; j < N; j++) {
            if ( (int)(S[j] - '0') == (i % 10)) {
                check = true;
                break;
            }
        }
        if (check) {
            count++;
            check = false;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long int N, s, d, i, j, k, b, c, l = ((long long int)1);
long long int m[5] = {0x55555555, 0x33333333, 0xF0F0F0F, 0xFF00FF, 0xFFFF};
 
inline long long int R(long long int a){
    int ret = 16;
    for(k = 16; k >= 1; k >>= 1){
        if(a & (((1 << k) - 1) << ret)){
            ret += (k >> 1);
        }else{
            ret -= k == 1 ? 1 : (k >> 1);
        }
    }
    return ret;
}
 
int main(){
    scanf("%lld", &N);
    for(; i < N; i++){
        scanf("%lld%lld", &s, &d);
        if(s * d > 0){
            if(s < 0){s = -s; d = -d; swap(s, d);}
            c = R(s ^ d);
            s &= (1 << (c + 1)) - 1;
            d &= (1 << (c + 1)) - 1;
            s -= 1 << c;
            d -= 1 << c;
        }
        s = -s;
        for(j = 0; j < 5; j++){
            s = (s & m[j]) + ((s >> (1 << j)) & m[j]);
            d = (d & m[j]) + ((d >> (1 << j)) & m[j]);
        }
        cout << s + d << endl;
    }
    return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

ll dp[101010][2];


int main(){
  string L; cin>>L;
  int N=L.length();
  dp[0][0]=1;
  rep(i,N){
    if(L[i]=='0'){
      dp[i+1][0]=dp[i][0];
      dp[i+1][1]=dp[i][1]*3%MOD;
    }else{
      dp[i+1][0]=dp[i][0]*2%MOD;
      dp[i+1][1]=(dp[i][0]+dp[i][1]*3)%MOD;
    }
  }
  cout<<(dp[N][0]+dp[N][1])%MOD<<endl;
  return 0;
}


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

int main(){

    int H, W;
    cin >> H >> W;
    string board[50];

    for (int i = 0; i < H; i++) 
    {
        cin >> board[i];
    }

    const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
    const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

    for (int i =0; i < H; i ++)    {
        for (int j = 0; j < W; j ++)    {
            if (board[i][j] == '#')   
                continue;
            int num = 0;
            for (int d = 0; d < 8; d ++){
                const int ni = i + dy[d];
                const int nj = j + dx[d];            

                if (ni < 0 or ni >= H) continue;
                if (nj < 0 or nj >= W) continue;
                if (board[ni][nj] == '#') num ++;
            }
            board[i][j] = char(num + '0');
        }
    }
  for (int i =0; i < H; i ++)    {
        cout << board[i] << endl;
    }    

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
typedef long long ll ; 
#define M 1000000007
 
#define PI 3.141592653589793238462643383279502884197169
using namespace std; 

/*     bool comp(pair<ll,ll> a,pair<ll,ll>b ) {
    if(a.second==b.second) return a.first<b.first;
    else return a.second<b.second;
} */

 /*ll power(ll a,ll b){
     ll res=1;
     while(b>0){
         a%=M;
         if(b&1)
         res=res*a %M;
         a=a*a%M;
         b>>=1;
     }
     return res;
 }
 bool isPrime(ll n){
     for(int i=2;i<=sqrt(n);++i)
     if(n%i==0)
     return 0;
     return 1;
 }
 int cnt=0;
 vector<bool>col(8,false),diag1(8,false),diag2(8,0);

void search(int x,vector<string>s){
if(x==8){
    ++cnt;
    return;
}
for(int i=0;i<8;++i){
    if(col[i]||diag1[x+i]||diag2[7+x-i]||s[x][i]=='*') continue;
    col[i]=diag1[x+i]=diag2[7+x-i]=true;
    search(x+1,s);
    col[i]=diag1[x+i]=diag2[7+x-i]=false;
}
} */
struct pt{
    int x,y,num,val;
    bool operator<(const pt& p) const{
        if(y==p.y) return x<p.x;
        else return y<p.y;
    }
};
bool comp(pt&a,pt&b){
    if(a.x==b.x) return a.y<b.y;
    else return a.x<b.x;
}
int main()
{
       /*  int t;
 cin>>t;
 for(int x1=0;x1<t;++x1){


 }   
 */
 /*  int n;
 cin>>n;
 vector<int>v(n);
 for(int i=0;i<n;++i)
 cin>>v[i];
sort(v.begin(),v.end());
int i=0,j=n-1;
int t=0;
int sum=0;
while(i<n){
    if(sum+v[i]<=v[j])
    {sum+=v[i];
    ++i;


}  */
 int n,k;
 cin>>n>>k;
 vector<int>v(n);
 for(int i=0;i<n;++i)
 cin>>v[i];
 sort(v.begin(),v.end());
 ll sum=0;
 for(int i=0;i<k;++i)
 sum+=v[i];
 cout<<sum;

 

    return 0;
}

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { for (auto& _e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	ll N;
	cin >> N;
	vec<ll> A(N);
	vec<ll> B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		B[i] = A[i] - (i + 1);
	}
	sort(ALL(B));
	int b = B[N / 2];
	
	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += abs(A[i] - (b + i + 1));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
def count(xs, ys):
    """Returns a count of elements in ys which is also in xs.
    - xs: a sequence of integers sorted in ascending order.
    - ys: a sequence of different integers.

    >>> count([1, 2, 3], [1, 3])
    2
    >>> count([1, 2, 3, 4, 5], [3, 4, 1])
    3
    >>> count([1, 2, 3], [5])
    0
    >>> count([1, 1, 2, 2, 3], [1, 2])
    2
    """
    def binsearch(i, j, n):
        while i <= j:
            mid = (i + j) // 2
            if xs[mid] > n:
                j = mid - 1
            elif xs[mid] < n:
                i = mid + 1
            else:
                return True

        return False

    return [binsearch(0, len(xs)-1, y) for y in ys].count(True)

def run():
    _ = input()  # flake8: noqa
    s = [int(i) for i in input().split()]
    _ = input()  # flake8: noqa
    t = [int(j) for j in input().split()]

    print(count(s, t))


if __name__ == '__main__':
    run()



Measured memory_bytes: 16904
import java.util.Scanner;

public class Main {
	static int max(int a, int b, int c) {
		return Math.max(Math.max(a, b),c);
	}
	static int min(int a, int b, int c) {
		return Math.min(Math.min(a, b),c);
	}
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			System.out.println(min(a,b,c) + " " + max(a,b,c));

		}
	}
}



Measured memory_bytes: 26312
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int v,d;
  int f[1004];
  f[0]=f[1]=1;
  REP(i,1002) {
    f[i+2]=(f[i+1]+f[i])%1001;
  }
  while(cin>>v>>d) {
    vector<int> vec(f+2, f+2+v);
    sort(ALL(vec));
    int res = 1;
    REP(i, v-1)
      if (vec[i+1] - vec[i] >= d)
        res++;
    cout << res << endl;
  }
}

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

int main(void)
{
	int a[5];
	int i, j;
	int work;
	int sum = 0;
	
	for(i = 0; i < 5; i++) {
		scanf("%d", &a[i]);
	}
	
	for(i = 0; i < 4; i++) {
		for(j = 0; j < 5 - i - 1; j++) {
			if( ((a[j] - 1) % 10) < ((a[j + 1] - 1) % 10) ) {
				work = a[j];
				a[j] = a[j + 1];
				a[j + 1] = work;
			}
		}
	}
	
	for(i = 0; i < 4; i++) {
		if(a[i] % 10 == 0) {
			sum += a[i];
		} else {
			sum += a[i] + ( 10 - (a[i] % 10) );
		}
	}
	sum += a[4];
	
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <sstream>
#define SSTR( x ) static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
using namespace std;

// n個の重複しない整数(min ~ max)用いてsを表す組み合わせの数
int ci(int n, int s, int min, int max, string str) {
  if (s < min || n < 1) return 0;
  if (n == 1) {
    if (s > max) return 0;
    //cout << str << s << endl;
    return 1;
  }
  int r = 0;
  for (int i=min; i<s && i<=max; i++) {
    r += ci(n - 1, s - i, i + 1, max, str + SSTR(i) + " ");
  }
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0, 9, "") << endl;
  }
  return 0;
}


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

int main(){
  	int n = 5;
  	vector<int>arr(n);
  	for(int i = 0; i < n; i++) cin >> arr[i];
	for(int i = 0; i < n;i++){
    	if(arr[i] == 0) {
        	cout << i + 1 << endl;
          return 0;
        }
    	}
  return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

char s[110][110];
unordered_map<int,int>mp;
class BGridCompression {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m;
		in >> n >> m;
		for (int i = 0; i < n; ++i) {
			in >> s[i];
		}
		int rl, rr, cl, cr;
		rl = n; cl = m; rr = cr = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				if(s[i][j] == '#'){
					rl = min(rl, i);
					rr = max(rr, i);
					cl = min(cl, j);
					cr = max(cr, j);
				}
			}
		}
		mp.clear();
		for (int j = cl; j <= cr; ++j) {
			int sum = 0;
			for (int i = rl; i <= rr; ++i) {
				if(s[i][j] == '#')sum++;
			}
			if(!sum)mp[j] = 1;
		}
		for (int i = rl; i <= rr; ++i) {
			int sum = 0;
			for (int j = cl; j <= cr; ++j) {
				if(s[i][j] == '#')sum ++;
			}
			if(!sum)continue;
			for (int j = cl; j <= cr; ++j) {
				if(mp[j] == 1)continue;
			    out << s[i][j];
			}
			out << '\n';
		}
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	BGridCompression solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

int main() {
    vector<int> A(5);
    for (int i=0; i<5; i++) cin >> A.at(i);
    vector<int> cnt(5);
    int ans = 0;
    for (int i=0; i<5; i++) {
        int num = A.at(i);
        while (num % 10 != 0) {
            num++;
            cnt.at(i)++;
        }
        ans += num;
    }
    sort(cnt.begin(), cnt.end());
    ans -= cnt.at(4);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int N, W;
vector<int> v, w;

ll dp[110][100100];

void input() {
	cin >> N >> W;
	v.resize(N);
	w.resize(N);
	rep(i,N) cin >> w[i] >> v[i];
}

ll solve() {
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= W; j++) {
			if (j - w[i] >= 0) {
				dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			} else {
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	return dp[N][W];
}


int main() {
	input();
	cout << solve() << endl;
}

Measured memory_bytes: 89668
import sys
import numpy as np
def main():
    s = sys.stdin.readlines()
    N, M, _ = map(int, s[0].split())
    X = np.zeros((N, N), dtype=int)
    for L, R in (map(int, e.split()) for e in s[1:M + 1]): X[L - 1][R - 1] += 1
    S = np.cumsum(np.cumsum(X, axis=1)[::-1], axis=0)[::-1]
    print('\n'.join(map(str, (S[p - 1][q - 1] for p, q in (map(int, e.split()) for e in s[M + 1:])))))
if __name__ == '__main__':
    main()

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

int main()
{
	int n;
	while (cin >> n, n)
	{
		int count = 0;
		bool next = true;
		bool L = false, R = false;

		for (int i = 0; i < n; i++)
		{
			string s;
			cin >> s;
			if (s == "lu") L = true;
			if (s == "ru") R = true;
			if (s == "ld") L = false;
			if (s == "rd") R = false;
			if (L == next && R == next)
			{
				next = !next;
				count++;
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;
 
mt19937 _gen(chrono::system_clock::now().time_since_epoch().count());
int rd(int a, int b) {
	return uniform_int_distribution<int>(a, b)(_gen);
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string str;
	cin >> str;

	bool ok = true;
	int n = size(str);
	REP(i, n) {
		if(i % 2 == 0 && str[i] == 'L') ok = false;
		if(i % 2 == 1 && str[i] == 'R') ok = false;
	}

	if(ok) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256