akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    let n: usize = read();
    let mut isp = vec![true; n+1];

    let mut ptn = 1;
    for i in 2..n+1 {
        if !isp[i] {
            continue
        }
        let mut nn = n;
        let mut mul = 1;
        while nn >= 1 {
            mul += nn / i;
            nn /= i;
        }
        ptn *= mul as i64;
        ptn %= MOD;

        let mut ii = i * 2;
        while ii <= n {
            isp[ii] = false;
            ii += i;
        }
    }
    println!("{}", ptn);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
int c[20000001];
char ch[20],a[20];
int C(char x){
    if(x=='A') return 1;
    if(x=='C') return 2;
    if(x=='G') return 3;
    return 4;
}

int search(int k, int x, int y, int t){
    if(k==strlen(a)){
        if(!t) c[x]=1;
        return c[x];
    }
    return search(k+1,x+C(a[k])*y,y*4,t);
}

int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        scanf("%s %s",ch,a);
        if(ch[0]=='i') search(0,0,1,0);
        else{
            if(search(0,0,1,1)) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 7176
def main():

    N, T = map(int, input().split())
    C = []
    for _ in range(N):
        A, B = map(int, input().split())
        C.append([B, A])

    dp = [[0, set()] for _ in range(T)]
    ans = 0
    for i in range(T):
        for j in range(N):
            if j not in dp[i][1]:
                k = i+C[j][1]
                if k > T-1:
                    ans = max(ans, dp[i][0] + C[j][0])
                else:
                    if dp[i][0]+C[j][0] > dp[k][0]:
                        dp[k][0] = dp[i][0]+C[j][0]
                        dp[k][1] = dp[i][1] | {j}
        ans = max(ans, dp[i][0])

    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 287492
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int h, w, kk;
	cin >> h >> w >> kk;
	vector<string> s(h);
	rep(snip_i, h) cin >> s.at(snip_i);
	vector<vector<int>> tr(h, vector<int>(w));
	rep(i, h){
		rep(j, w){
			int add = s.at(i)[j] - '0';
			tr.at(i).at(j) = add;
		}
	}

	int ans = 1001001001;
	rep(i, 1<<(h-1)){
		int a_ans = 0;
		vector<int> gr(1, 0);
		rep(j, h-1){
			if((i & (1 << j)) != 0){
				gr.push_back(0);
				a_ans++;
			}
		}
		rep(j, w){
			int index = 0, add = 0;
			vector<int> temp(gr.size());
			bool flag = false;
			rep(k, h){
				add += tr.at(k).at(j);
				if((i & (1 << k)) != 0 || k == h-1){
					// cerr << i << " " << j << " " << k << " " <<  add << endl;
					if(add > kk){
						goto skip;//一列>kk、つまり不可能
					}
					gr.at(index) += add;
					temp.at(index) = add;
					if(gr.at(index) > kk || flag == true){
						flag = true;
					}
					index++;
					add = 0;
				}
			}
			if(flag == true){
				rep(k, gr.size()){
					gr.at(k) = temp.at(k);
				}
				a_ans++;
			}
		}
		ans = min(ans, a_ans);
		skip:;
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	string s;
	cin >> s;
	ll i;
	rep(i,0,s.size()){
		cout << 'x';
	}
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}



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

int N;
vector<int> dataS(200);
bool EvenorNot = true;
int countEven = 0;
int kaisu = 0;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> dataS.at(i);
	}

	while (EvenorNot) {
		for (int i = 0; i < N;i++) {
			if (dataS.at(i) % 2 == 0) {
				dataS.at(i) /= 2;
				countEven++;
			}
			else {
				EvenorNot = false;
				
			}
			if (countEven == N) {
				kaisu++;
				countEven = 0;
			}
			
		}
	}
	cout << kaisu << endl;
	
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class D109
    {
        static void Main(string[] args)
        {
            int[] h = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int H = h[0], W = h[1];

            List<int[]> list = new List<int[]>();

            int[] col = new int[H];
            for (int i = 0; i < H; i++)
            {
                int[] a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
                int[] b = (int[])a.Clone();
                for (int j = 0; j < W - 1; j++)
                {
                    if (b[j] % 2 == 1)
                    {
                        int[] r = { i + 1, j + 1, i + 1, j + 2 };
                        list.Add(r);
                        b[j]--; b[j + 1]++;
                    }
                }
                col[i] = b[W - 1];
            }

            for(int i = 0; i < H - 1; i++)
            {
                if(col[i] % 2 == 1)
                {
                    int[] r = { i+1, W, i + 2, W };
                    list.Add(r);
                    col[i]--; col[i + 1]++;
                }
            }

            Console.WriteLine(list.Count);
            foreach(int[] r in list)
            {
                Console.WriteLine(string.Join(" ", r));
            }

        }

    }
}


Measured memory_bytes: 29228
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == B) 
    cout << C << endl;
  else if (A == C) 
    cout << B << endl;
  else 
    cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int nn = n;
    if(n%2==1) --nn;
    vector<pair<int,int>> edges;
    rep(i,0,n) rep(j,i+1,n) {
        bool edge = true;
        if(i<nn && j==nn-1-i)  edge = false;
        if(edge) edges.emplace_back(i,j);
    }
    int m = edges.size();
    cout << m << "\n";
    rep(i,0,m) cout << edges[i].first+1 << " " << edges[i].second+1 << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,W;
	cin >> N >> W;
	vector<ll> v[4];
	ll w1=0,w,vi;
	FOR(i,0,N){
		cin >> w >> vi;
		if(w1==0)w1=w;
		v[w-w1].push_back(vi);
	}
	FOR(i,0,4){SORT(v[i]);v[i].push_back(0);REV(v[i]);}
	FOR(i,0,4)FOR(j,1,v[i].size())v[i][j]+=v[i][j-1];
	ll ans=0;
	FOR(i,0,v[0].size()){
		FOR(j,0,v[1].size()){
			FOR(k,0,v[2].size()){
				FOR(l,0,v[3].size()){
					ll cost = w1*(i+j+k+l)+j+2*k+3*l;
					if(cost>W)continue;
					ans = max(ans,v[0][i]+v[1][j]+v[2][k]+v[3][l]);
				}
			}
		}
	}
	cout << ans <<endl;
}

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

RES={"AC": 0, "WA":0, "TLE":0, "RE": 0}

N=II()
for i in range(N):
    RES[input()] += 1


for s in ["AC", "WA", "TLE", "RE"]:
    print("{} x {}".format(s, RES[s]))


Measured memory_bytes: 9276
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

L, R = map(int, read().split())

if R - L > 1000:
    print(0)
    exit()
x = np.arange(L, R + 1)
x = x[:, None] * x[None, :] % 2019
np.fill_diagonal(x, 2019)
answer = x.min()
print(answer)


Measured memory_bytes: 15828
# a = [13,19,9,5,12,8,7,4,21,2,6,11]
gets
a=gets.split(' ').map(&:to_i)
def ins(a)
  for i in 1..a.length-1
    c = 0
    s=""
    a.each do |b|
      s += "#{b}"
      s += " " if c != a.length-1
      c += 1
    end
    puts s
    v = a[i]
    while i >= 1 && a[i-1] > v
      a[i] = a[i-1]
      i -= 1
    end
    a[i] = v
  end
end
ins(a)
s=""
    c = 0

    a.each do |b|
      s += "#{b}"
      s += " " if c != a.length-1
      c += 1
    end
    puts s

Measured memory_bytes: 10448
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  string s;
  cin >> s;
  ll n = s.size();
  // vec2int dp(n, vecint(2019, 0));
  vecll dpold(2019, 0);
  vecll dpnew(2019, 0);
  ll ans = 0;
  dpold[s[0] - '0'] = 1;
  REP(i, n) {
    ll tmp = s[i] - '0';
    dpnew[tmp] = 1;
    REP(k, 2019) {
      if (i == 0) continue;
      dpnew[(10 * k + tmp) % 2019] += dpold[k];
    }
    ans += dpnew[0];
    REP(k, 2019) {
      // if (i == 0) continue;
      dpold[k] = dpnew[k];
      dpnew[k] = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  int n, m;
  n = (2 * y - x) / 3;
  m = (2 * x - y) / 3;
  if (n < 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  } 

  Combination c(n + m);
  mint ans = c(n + m, n);
  cout << ans.x << endl;
  
  return 0;
}


Measured memory_bytes: 13828
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;
int n,m;
int a[23333];
int main()
{
	scanf("%d",&n);
	int fl=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(fl)
		{
			fl=0;
			continue;
		}
		if(a[i]==a[i-1])ans++,fl=1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
/*



*/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define ll long long
typedef pair<ll,int> pii;
const int maxn=2e3+10;
struct edge{
    int a,b,flow,cap;
    ll cost;
};
int parent[maxn],source,sink,mflow,maxflow,n;
ll dp[maxn],pot[maxn],rez;
vector<edge>e;
vector<int>vect[maxn];
int inf=1e9;
ll offset=1e10;
void add_edge(int a,int b,int cap,ll cost){

    cost=-cost;
    cost+=offset;

    vect[a].pb(e.size());
    e.pb({a,b,0,cap,cost});

    vect[b].pb(e.size());
    e.pb({b,a,cap,cap,-cost});
}
ll flow(){

    memset(parent,-1,sizeof(parent));
    for(int i=source;i<=sink+4;i++)dp[i]=1e18;

    set<pii>st;
    st.insert({0,source});
    dp[source]=0;
    while(st.size()){

        int x=(*st.begin()).ss;
        st.erase(st.begin());

        for(int i=0;i<vect[x].size();i++){
            int id=vect[x][i];
            ll w=pot[x]+e[id].cost-pot[e[id].b];
            if(e[id].flow>=e[id].cap || dp[x]+w>=dp[e[id].b])continue;

            int id2=e[id].b;
            st.erase({dp[id2],id2});
            dp[id2]=dp[x]+w;
            parent[id2]=id;
            st.insert({dp[id2],id2});
        }

    }

    for(int i=source;i<=sink+4;i++)pot[i]=dp[i];

    int x=sink;
    int flow=1e9;
    while(x!=source){
        int id=parent[x];
        flow=min(flow,e[id].cap-e[id].flow);
        x=e[id].a;

        ///printf("%d %d %d X\n",x,e[id].a,e[id].b);
    }

    mflow+=flow;

    x=sink;
    ll cost=0;
    while(x!=source){
        int id=parent[x];
        cost+=e[id].cost;
        x=e[id].a;

        e[id].flow+=flow;
        e[id^1].flow-=flow;
    }

    cost-=4*offset;
    cost=-cost;
    cost*=(ll)flow;

    ///printf("%lld AA COST\n",cost);

    return cost;
}
void go(){

    while(mflow<maxflow)
        rez+=flow();

}
int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%d",&n);
    source=0;
    sink=2*n+1;
    for(int i=1;i<=n;i++){
        ll x,y,w;
        scanf("%lld %lld %lld",&x,&y,&w);

        maxflow+=(int)w;

        add_edge(source,i,w,0);
        add_edge(i,sink+1,inf,x+y);
        add_edge(i,sink+2,inf,x-y);
        add_edge(i,sink+3,inf,-x+y);
        add_edge(i,sink+4,inf,-x-y);
    }
    for(int i=1;i<=n;i++){
        ll x,y,w;
        scanf("%lld %lld %lld",&x,&y,&w);

        add_edge(i+n,sink,w,0);
        add_edge(sink+1,i+n,inf,-x-y);
        add_edge(sink+2,i+n,inf,-x+y);
        add_edge(sink+3,i+n,inf,x-y);
        add_edge(sink+4,i+n,inf,x+y);
    }

    go();

    printf("%lld\n",rez);

	return 0;
}


Measured memory_bytes: 1180
N,M = map(int, input().rstrip().split())
L_max = -10**10
R_min = 10**10
for i in range(M):
    L,R = map(int, input().split())
    if L_max < L:
        L_max = L
    if R < R_min:
        R_min = R
print(R_min-L_max+1 if L_max <= R_min else 0)


Measured memory_bytes: 3060
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

warshallFloyd1 :: Int -> U.Vector (Int, Int, Int64) -> V.Vector (U.Vector Int64)
warshallFloyd1 !n !edges = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  U.forM_ edges $ \(a,b,c) -> do
    UM.write (arr V.! a) b c
    UM.write (arr V.! b) a c
  forM_ [0..n-1] $ \a -> do
    UM.write (arr V.! a) a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr V.! k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr V.! i
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.read a_i k
        a_kj <- UM.read a_k j
        UM.modify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

warshallFloyd2 :: Int -> Int -> V.Vector (U.Vector Int64) -> V.Vector (U.Vector Int)
warshallFloyd2 !n !l !graph = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  forM_ [0..n-1] $ \a -> do
    let !a_a = arr V.! a
    forM_ [0..n-1] $ \b -> do
      let v = graph V.! a U.! b
      when (v <= fromIntegral l) $ do
        UM.write a_a b 1
    UM.write a_a a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr V.! k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr V.! i
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.read a_i k
        a_kj <- UM.read a_k j
        UM.modify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

main = do
  [n,m,l] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [a,b,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1,fromIntegral c)
  let w1 = warshallFloyd1 n edges
      w2 = warshallFloyd2 n l w1
  q <- readLn
  queries <- U.replicateM q $ do
    [s,t] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (s,t)
  U.forM_ queries $ \(s,t) -> do
    let d = w2 V.! (s-1) U.! (t-1)
    print $ if d > 10^9 then -1 else d - 1


Measured memory_bytes: 6652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}
int main() {
	ll A, B;
	cin >> A >> B;
	ll g = gcd(A, B);
	ll ans = 1;
	for (ll i = 2; i*i <= g; i++) {
		if (g%i == 0) {
			ans++;
			while (g%i == 0) g /= i;
		}
	}
	if (g > 1) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B = LI()

    print(min(A * N, B))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10096
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] l = new int[N];
    for (int i = 0; i < N; i++) {
      l[i] = sc.nextInt();
    }
    Arrays.sort(l);
    
    int ans = 0;
    for (int i = 0; i < K; i++) {
      ans += l[N-1-i];
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1000000007;
struct mint
{
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator^=(const mint a)
  {
    (x ^= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint operator^(const mint a) const { return mint(*this) ^= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  mint ans = 0;
  for (ll i = 0; i < 60; ++i)
  {
    int cnt = 0;
    for (int j = 0; j < N; ++j)
    {
      if (A[j] & (1LL << i))
        cnt++;
    }
    mint sum = (1LL << i);
    sum *= mint(cnt * (N - cnt));
    ans += sum;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) {
    if (a >= b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;   
}

int main() {
    int k,s;
    int count=0;
    cin>>k>>s;
    rep(i,k+1){
        rep(j,k+1){
            if(s-i-j>=0&&s-i-j<=k){
                count++;
            }
        }
    }
    cout<<count<<endl;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

string s;
ll a,b;
const ll m=8003;

void solve(){
 cin >> s >> a >> b;
 vector<bitset<16005>> dp(2);
 dp[0].set(m);
 dp[1].set(m); 
  
 vvll d(2); 
  
 ll flag=0;
 ll n=s.size();
  for(int i=0;i<n;){
     ll cnt=0;
   while(i<n&&s[i]=='F') {
     cnt++;
     i++;
   }
    d[flag].eb(cnt);
   while(i<n&&s[i]=='T') {
     flag=1-flag;
     i++; 
   }
  }
   
  rep(i,0,2){
    rep(j,0,d[i].size()){
      bitset<16005> mask;
      swap(mask,dp[i]);
    rep(k,0,16005){
     if(mask[k]){ 
       if(k+d[i][j]<16005) dp[i].set(k+d[i][j]);
       if(k-d[i][j]>=0&&(i!=0||j!=0)) dp[i].set(k-d[i][j]);
     }
    }
    }
  }
  
  if(dp[0][m+a]&&dp[1][m+b]) cout << "Yes" << endl;
  else cout << "No" << endl;
 
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char a,b;
int main()
{
    cin>>a>>b;
    if (a<b)
      cout<<"<"<<endl;
    if (a>b)
      cout<<">"<<endl;
    if (a==b)
      cout<<"="<<endl;
    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

int main(int argc, char **argv) {
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  ll n; cin >> n;
  ll res = 1e18;
  for(ll i=1; i*i<=n; i++) {
    if(n%i == 0) {
      res = min(res, i+n/i-2);
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int buri[26]={};
    int H,W;
    scanf("%d %d",&H,&W);
    for(int i=0;i<H*W;i++){char po;scanf(" %c",&po);buri[po-'a']++;}
    int futatu=0;
    int kisu=0;
    for(int i=0;i<26;i++){
        if(buri[i]%2==1){kisu++;buri[i]--;}
        if(buri[i]%4==2)futatu++;
    }
    if((H*W)%2==1){
        if(kisu==1&&futatu<=(H+W)/2-1)printf("Yes");
        else printf("No");
    }
    else if((H%2==1)||(W%2==1)){
        int po;
        if(H%2==0)po=H;
        else po=W;
        if(kisu==0&&futatu<=po/2)printf("Yes");
        else printf("No");
    }
    else{
        if(kisu==0&&futatu==0)printf("Yes");
        else printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fo(i, n) for(int i = 1; i <= (n); i ++)
#define out(x) cout << #x << " = " << x << "\n"
using namespace std;
typedef long long ll;
//by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
int n;
bitset<2000 * 2100> b;
main(void) {
  read(n);
  b[0] = 1;
  fo(i, n) {
    int x; read(x);
    b |= b << x;
  }
  int cnt = (b.count()) / 2;
  for(int i = 1; ; i ++) 
    if(b[i]) 
      if(-- cnt == 0)
	return cout << i << "\n", 0;
}


Measured memory_bytes: 1920
// Created by martinezdiego on 27/5/19

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  int ans = 0;
  if (a >= 13) ans = b;
  if (6 <= a and a <= 12) ans = b/2;
  cout << ans << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int k, x; cin >> k >> x;
	int offset = x-k+1;
	for( int i = 0; i < 2*k-1; ++i ){
		cout << offset+i;
		if( i != 2*k-2 ) cout << ' '; 
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
    int n; cin >> n;
    unordered_map<int,int> um;
    if(n <= 9) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = 2; i <=n; i++) {
        int tmp = i;
        int j = 2;
        while(tmp != 1) {
            if(tmp%j == 0) {
                tmp /= j;
                um[j]++;
                continue;
            }
            j++;
        }
    }
    int ans = 0;
    int a = 0;
    int b = 0;
    // 3*5*5 -> 2*4*4
    for(int i = 2; i <=100; i++) {
        if(um[i] >= 4) {
            a++;
        }
        if(um[i] >= 2) {
            b++;
        }
    }
    ans += a*(a-1)/2*(b-2);
    // cout << ans << endl;

    // 3*25 -> 2*24
    a = 0;
    b = 0;
    for(int i = 2; i <=100; i++) {
        if(um[i] >= 24)
            a++;
        if(um[i] >= 2)
            b++;
    }
    ans += a*(b-1);
    // cout << ans << endl;

    // 5*15 -> 4*14
    a = 0;
    b = 0;
    for(int i = 2; i <=100; i++) {
        if(um[i] >= 14)
            a++;
        if(um[i] >= 4)
            b++;
    }
    ans += a*(b-1);
    // cout << ans << endl;

    // 75 -> 74
    for(int i = 2; i <=100; i++) {
        if(um[i] >= 74)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#include<map>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;

LL N,M,K,ans,num;
string S;


int main() {
	cin >> S;
	ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '2') {
			ans ++;
		}
	}
	cout << ans << endl;
	return 0;
	

	
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

struct Node_t {
  int id_, left_, right_, parent_;
  Node_t() { id_ = left_ = right_ = parent_ = -1; }
};

void preorder(vector<Node_t>& nodes, int id, vector<int>& ids)
{
  if (id == -1) { return; }
  ids.push_back(id);
  preorder(nodes, nodes[id].left_, ids);
  preorder(nodes, nodes[id].right_, ids);
}

void inorder(vector<Node_t>& nodes, int id, vector<int>& ids)
{
  if (id == -1) { return; }
  inorder(nodes, nodes[id].left_, ids);
  ids.push_back(id);
  inorder(nodes, nodes[id].right_, ids);
}

void postorder(vector<Node_t>& nodes, int id, vector<int>& ids)
{
  if (id == -1) { return; }
  postorder(nodes, nodes[id].left_, ids);
  postorder(nodes, nodes[id].right_, ids);
  ids.push_back(id);
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<Node_t> nodes(n);
  for (int i = 0; i < n; ++i) {
    int id, l, r;
    fscanf(stdin, "%d %d %d", &id, &l, &r);
    nodes[id].id_ = id;
    nodes[id].left_ = l;
    nodes[id].right_ = r;
    if (l != -1) { nodes[l].parent_ = id; }
    if (r != -1) { nodes[r].parent_ = id; }
  }
  int root_id = -1;
  for (int i = 0; i < n; ++i) {
    if (nodes[i].parent_ == -1) {
      root_id = nodes[i].id_;
      break;
    }
  }

  vector<int> pre, in, post;
  preorder(nodes, root_id, pre);
  fprintf(stdout, "Preorder\n");
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, " %d", pre[i]);
  }
  fprintf(stdout, "\n");

  inorder(nodes, root_id, in);
  fprintf(stdout, "Inorder\n");
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, " %d", in[i]);
  }
  fprintf(stdout, "\n");

  postorder(nodes, root_id, post);
  fprintf(stdout, "Postorder\n");
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, " %d", post[i]);
  }
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 1224
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
cnt = [0]*N
p = 0
ans = 1
MOD = 10**9+7

for Ai in A:
    if Ai==0:
        cnt[Ai] += 1
        p += 1
    else:
        ans *= cnt[Ai-1]
        ans %= MOD
        cnt[Ai-1] -= 1
        cnt[Ai] += 1

if p==1:
    ans *= 3
elif p==2:
    ans *= 6
elif p==3:
    ans *= 6
else:
    ans = 0

print(ans%MOD)

Measured memory_bytes: 53356
S = input().replace("><", "> <").split()
ans = 0
for s in S:
    up = s.count("<")
    down = len(s) - up
    if up < down: 
        up -= 1
        ans += up * (up+1) // 2 + down * (down+1) // 2
    else:
        down -= 1
        ans += up * (up+1) // 2 + down * (down+1) // 2
print(ans)

Measured memory_bytes: 19148
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

	
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<pii>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define re(n) for (int i = 0; i < n; ++i)
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define eb emplace_back

//OutPut
#define ps(x) cout << x << endl;
#define ps_end(x) {ps(x); return;}


const int md = 1e9 + 7; //998244353 ;
const int dir[4][2] = {{-1,0}, {1, 0}, {0, -1}, {0, 1}};
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; }
ll pw(auto x, auto y) {	 ll s = 1; while(y) { if (y & 1) s = s * x % md; x= 1LL * x * x % md; y /= 2; } return s;}

const int maxn = 1e6 + 10;

int n, m, nq, nk;
string str;

void task() {
	cin >> n;
	vi a(n);
	re(n) cin >> a[i];
	sort(all(a));
	int ans = 0;
	re(n) rep(j, i+1, n) rep(k, j+1, n) if (a[i] < a[j] && a[j] < a[k] && a[i] + a[j] > a[k]) ans++;
	ps(ans);
	//Read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  int T = 1;
  //cin >> T;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;




int n,k;
const int MOD = 1000000007;
const int nax = 1000005;
ll int f[nax] , iv[nax];

ll int powermod(ll int base, ll int exp, ll int mod) {
    ll result = 1;
    while (exp != 0) {
        if ((exp % 2) == 1) {
            result = (result * base) % mod;
        }
        base = (base * base) % mod;
        exp /= 2;
    }
    return result;
}
ll C(ll n,ll r){
	if(n<r)return 0;
	ll ans=(f[n]*iv[r])%MOD;
	ans=(ans*iv[n-r])%MOD;
	return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    f[0] = 1;
    iv[0] = 1;
    for (size_t i = 1; i < nax; i++) {
        f[i] = (i*f[i-1]) % MOD;
        iv[i] = powermod(f[i] , MOD-2 , MOD) % MOD;
    }
    /*iv[nax-1] = powermod(f[nax-1],MOD-2  , MOD);
	for(ll int i=nax-2;i>=0;--i)iv[i]=(iv[i+1]*(i+1))%MOD;*/

    cin>>n>>k;

    vector<int> v(n);

    REP(i,n){cin>>v[i];}

    sort(ALL(v));

    ll int ans = 0, mx  = 0 , mn = 0;
    for (size_t i = 0 ; i < n ; i++) {
        ll int left  = i , right = n - 1 - i;
        mx = (mx + v[i] * C(left , k-1 )) % MOD;
        mn = (mn + v[i] * C(right , k-1 )) % MOD;

    }
    ans = (mx - mn + MOD) % MOD;
    while(ans < 0){
        ans  = (ans + MOD) % MOD;
    }
    cout<<ans<<"\n";
    return 0;

}


Measured memory_bytes: 16256
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String N=sc.next();
    if(N.equals("ABC")){
      System.out.println("ARC");
    }else{
      System.out.println("ABC");        
    }




  }
}


Measured memory_bytes: 35724
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  int sum =0;
  for(int i=0;i<n;i++) sum+=a[i];

  int cnt = 0;
  for(int i=0;i<n;i++){
    int r = sum/(4*m);
    if(sum%(4*m)!=0) r++;

    if(a[i] >= r){
      cnt++;
    }
  }

  if(cnt >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
std::mt19937 mt{std::random_device{}()};
int main()
{
    int H, W;
    std::cin >> H >> W;
    int N;
    std::cin >> N;
    std::vector<std::vector<int>> ans(H, std::vector<int>(W, -1));
    int h = 0, w = 0;
    for (int i = 0, a; i < N; i++) {
        std::cin >> a;
        for (int n = 0; n < a; n++) {
            ans[h][w] = i + 1;
            if (h % 2 == 0 and w == W - 1) {
                h++;
            } else if (h % 2 == 1 and w == 0) {
                h++;
            } else {
                w = (h % 2 == 0 ? w + 1 : w - 1);
            }
        }
    }
    for (int i = 0, n = 0; i < H; i++) {
        for (int j = 0; j < W; j++, n++) {
            std::cout << ans[i][j] << " ";
        }
        std::cout << std::endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <string>
#include <math.h>
#include <stdint.h>
#include <bitset>
#include <iomanip>

using namespace std;


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

  string result = "No";
  if(N==M) {
    result = "Yes";
  }

  cout << result << endl; 
}

Measured memory_bytes: 256
def create_array(n: int, r: int, mod, mod2):
    m_ls = [1] * (r + 1)

    for i, j in zip(range(n, 0, -1), range(1, r + 1)):
        m_ls[j] = (m_ls[j - 1] * i * pow(j, mod2, mod)) % mod
    return m_ls


def main():
    n, a, b = map(int, input().split())
    _mod = 1000000007
    _mod2 = 1000000005

    m_ls = create_array(n, b, _mod, _mod2)

    _all_cnts = pow(2, n, _mod) - 1
    ans = _all_cnts + (_mod - m_ls[a]) + (_mod - m_ls[b])
    ans %= _mod

    print(ans)


main()


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

typedef long long ll;


bool check(int i, map<int,bool> m){
  
  bool flg = true;
  while(i >= 1){
    int tmp = i % 10;
    cerr << tmp << endl;
    if(m.count(tmp) == 0){
   
    } else { 
      flg = false;
      break;
    }
    i = i / 10;
  }
  return flg;
}

int main(){
  int N,K;
  cin >> N >> K;
  map<int,bool> m;
  for(int i = 0; i < K; i++){
    int tmp;
    cin >> tmp;
    m[tmp] = true;
  }
  
  for(int i= 1; i <= 100000; i++){
    if(i >= N && check(i, m)){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve() {
    while (true) {
        int grid[300][300] = {};
        int n;
        cin >> n;
        if (n == 0) return;
        vector<pair<pair<int, int>, pair<int, int>>> inputs;
        map<int, int> zip[2];
        REP(i, n) {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            a *= 2;
            b *= 2;
            c *= 2;
            d *= 2;

            b++;
            c++;

            inputs.push_back(mp(mp(a, d), mp(c-1, b-1)));
            zip[0][a]++;
            zip[0][c]++;
            zip[0][c - 1]++;

            zip[1][d]++;
            zip[1][b]++;
            zip[1][b - 1]++;
        }
        
        REP(t, 2) {
            int cnt = 1;
            for (auto i = zip[t].begin(); i != zip[t].end(); ++i) {
                i->second = cnt;
                cnt++;
            }
        }

        REP(i, inputs.size()) {
            inputs[i].first = mp(zip[0][inputs[i].first.first], zip[1][inputs[i].first.second]);

            inputs[i].second = mp(zip[0][inputs[i].second.first], zip[1][inputs[i].second.second]);
            for (int q = inputs[i].first.first; q < inputs[i].second.first; ++q) {
                for (int j = inputs[i].first.second; j < inputs[i].second.second; ++j) {
                    grid[q][j] += (1LL << i);
                }
            }
        }
        int ans = 0;
        const int dx[4] = { 1,-1,0,0 };
        queue<pair<int, int>> next;
        REP(i, 200) {
            REP(q, 200) {
                if (grid[i][q] == -1) continue;
                int target = grid[i][q];
                grid[i][q] = -1;
                next.push(mp(i, q));
                ans++;
                while (next.empty() == false) {
                    pair<int, int> now = next.front();
                    next.pop();
                    REP(q, 4) {
                        int x = now.first + dx[q];
                        int y = now.second + dx[3 - q];
                        if (!(x >= 0 && x < 200 && y >= 0 && y < 200)) continue;
                        if (grid[x][y] == target) {
                            grid[x][y] = -1;
                            next.push(mp(x, y));
                        }
                    }
                }
            }
        }

        cout << ans << endl;
    }
}

#undef int
int main() {
    init();
    solve();
}



Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0)
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  IO;
  int n; ll W; cin>>n>>W;
  vector<ll> dp(n*1000+1, 1e15);
  dp[0] = 0;

  for (int i = 1; i <= n; i++) {
    ll w, v; cin>>w>>v;
    for (int tval = n*1000; tval >=v; tval--) {
      dp[tval] = min(dp[tval], dp[tval-v] + w);
    }
  }

  for (int tval = n*1000; tval >= 0; tval--) if (dp[tval] <= W) return cout<<tval<<"\n", 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll W;
    cin >> W;
    ll H;
    cin >> H;
    ll x;
    cin >> x;
    ll y;
    cin >> y;
    cout << fixed << setprecision(6);
    cout<<(double)H*W/2<<" ";
    if(x*2==W&&y*2==H)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int a[100000];
int n;
int search(int key){
  int left=0,right=n,mid;
  while(1){
    if(left>=right) break;
    mid=(left+right)/2;
    if(key==a[mid])
      return 1;
    else if(key<a[mid])
	right=mid;
    else if(key>a[mid])
      left=mid+1;
    }
  return 0; 
}
int main(){
  int i,m,x;
  int sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&x);
    if(search(x)){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}



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

static const int MAX =100;
static const int INFTY=numeric_limits<int>::max();

typedef enum {
    WHITE,
    GRAY,
    BLACK,
}Color;

int n,M[MAX][MAX];

int Prim(){
    int u,minv;
    int d[MAX],p[MAX];
    Color color[MAX];

    for(int i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }

    d[0]=0;

    while(true){
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }        
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1){
            sum+=M[i][p[i]];
        }
    }

    return sum;
}

int main(){
    cin>>n;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int k;
            cin>>k;
            M[i][j]=(k==-1) ? INFTY : k;
        }
    }

    cout<<Prim()<<endl;

    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll ans = 0,i=0;
    while(n>0)
    {
        ans+=pow(2,i);
        i++;
        n/=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl

// ランレングス
// 例 s = "aabccc" => [2, 1, 3]
VI run_length(string s){
  char prev = s[0];
  VI V;
  ll cnt = 1;
  FOR(i, 1, s.size()){
    char c = s[i];
    if(c!=prev){
      V.push_back(cnt);
      // reset
      cnt = 1;
      prev = c;
    }else{
      cnt++;
    }
  }
  V.push_back(cnt);
  return V;
}

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

    // input
    string s; cin >> s;
    ll L = s.size();
    ll K; cin >> K;

    // 全部同じ文字
    set<char> se;
    for(char c : s) se.insert(c);
    if(se.size()==1){
      ll length = s.size()*K;
      p(length/2);
      return 0;
    }

    ll n = 0;
    auto V = run_length(s);

    ll ans;
    // 先端と後端が同じのときは少し複雑
    if(s[0]==s.back()){
      ll head_and_tail = V[0] + V.back();

      // head & tail以外
      FOR(i, 1, V.size()-1){
        n += V[i]/2;
      }
      ans = n*K;
      
      // はじっこ
      ans += (head_and_tail/2)*(K-1);
      ans += V.back()/2;
      ans += V[0]/2;
    }
    // 先端と後端が違うので簡単
    else{
      for(ll v : V){
        n += v/2;
      }
      ans = n*K;
    }
    p(ans);

    return 0;
}

Measured memory_bytes: 256
#17:34
n,k = map(int,input().split())
mod = 10 ** 9 + 7
def inv(x):
  y = 1
  while x != 1:
    y *= mod // x + 1
    y %= mod
    x = x - mod % x
  return y
p = 1
q = n-k+1
ans = n-k+1
for i in range(k):
  print(ans)
  ans *= k-1-i
  ans %= mod
  ans *= inv(i+1)
  ans %= mod
  ans *= n-k-i
  ans %= mod
  ans *= inv(i+2)
  ans %= mod

Measured memory_bytes: 3316