akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M,C=map(int,input().split())
    B=list(map(int,input().split()))
    ans=0
    for _ in range(N):
        A=list(map(int,input().split()))
        tmp=C
        for i in range(M):
            tmp+=A[i]*B[i]
        if tmp>0:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
local n = tonumber(io.read());

if n < 105 then
    print(0);
elseif n < 135 then
    print(1);
elseif n < 165 then
    print(2);
elseif n < 189 then
    print(3);
elseif n < 195 then
    print(4);
else
    print(5);
end

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll unsigned long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N;
  scanf("%lld", &N);

  bool zero = false;

  ll th = 1000000000000000000LL;
  // ll th = 10LL;

  vector<ll> list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = v;

    // cout << v << endl;

    if (v == 0) {
      zero = true;
    }
  }

  if (zero) {
    cout << 0 << endl;
    return 0;
  }

  ll a = 1;
  bool exceed = false;

  for (ll i = 0; i < N; i++) {
    ll v = list[i];

    // a *= v;
    // if (a > th) {
    //   exceed = true;
    //   break;
    // }

    ll t = (th / a);

    // cout << "t:" << t << endl;

    if (v > t) {
      exceed = true;
      break;
    }

    a *= v;
  }

  if (exceed) {
    cout << -1 << endl;
    return 0;
  }

  cout << a << endl;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110000];
int main(){
    ll n,k,l,ans=0,tmp=0;
    string s;
    cin>>s;
    bool p=true;
    rep(i,0,s.length()){
      if(i%2==0){
        if(s[i]=='R'||s[i]=='U'||s[i]=='D')continue;
        else {p=false;break;}
      }
      else{
        if(s[i]=='L'||s[i]=='U'||s[i]=='D')continue;
        else {p=false;break;}
      }
    }
    if(p)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<P,int> PP;

void Main() {
  int n;
  while(R n && n) {
    PP a[n];
    map<int,int> m,mm;
    rep(i,n) {
      cin >> a[i].F.F >> a[i].F.S >> a[i].S;
      if(!m.count(a[i].F.F)) {
        int s=m.size();
        m[a[i].F.F]=s;
        mm[s]=a[i].F.F;
      }
      if(!m.count(a[i].F.S)) {
        int s=m.size();
        m[a[i].F.S]=s;
        mm[s]=a[i].F.S;
      }
    }
    int N=m.size();
    int d[N][N];
    rep(i,N)rep(j,N)d[i][j]=MAX;
    rep(i,N)d[i][i]=0;
    rep(i,n) {
      d[m[a[i].F.F]][m[a[i].F.S]]=a[i].S;
      d[m[a[i].F.S]][m[a[i].F.F]]=a[i].S;
    }
    rep(k,N)rep(i,N)rep(j,N){
      if(d[i][k]!=MAX&&d[k][j]!=MAX) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
    int M=MAX,x;
    rep(i,N) {
      int sum=0;
      rep(j,N)if(d[i][j]!=MAX)sum+=d[i][j];
      if(sum<M) {
        M=sum;
        x=mm[i];
      } else if(sum==M) x=min(x,mm[i]);
    }
    pr(x,M);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


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

#define INF (1<<29)

int G[101][101];
int n, k;

void init(){
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      G[i][j] = INF;
      if(i == j) G[i][j] = 0;
    }
  }
}

int main(){
  while(cin >> n >> k){
    if(n == 0 && k == 0) break;
    init();

    int op, a, b, e;
    for(int cs = 0 ; cs < k ; cs++){
      cin >> op;
      if(op == 1){
	cin >> a >> b >> e;
	a--, b--;
	G[a][b] = min(G[a][b], e);
	G[b][a] = min(G[b][a], e);
	//	Warshall_Floyd();
	  for(int i = 0 ; i < n ; i++){
	    for(int j = 0 ; j < n ; j++){
	      G[i][j] = min(G[i][j], G[i][a] + G[a][b] + G[b][j]);
	      G[j][i] = G[i][j];
	    }
	  }
      }
      else if(op == 0){
	cin >> a >> b;
	a--, b--;
	if(G[a][b] == INF) cout << -1 << endl;
	else cout << G[a][b] << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll gcd(ll a,ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
int main()
{
    ll a,b,c,d,cd,cnt=0,t1,t2,tmp,tmp1;
    cin >> a >> b >> c >> d;
    //cout << gcd(d,c);
    cd = (c*d)/gcd(d,c);
    if(a%cd!=0)
        t1 = a+(cd-a%cd);
    else 
        t1 = a;
    if(b%cd!=0)
        t2 = b-(b%cd);
    else
        t2 = b;
    cnt = (t2-t1)/cd;
    cnt++;
    if(t2<t1)
    {
        cnt=0;
    }
    //cout << cnt << endl;
    if(a%c!=0)
        t1 = a+(c-a%c);
    else 
        t1 = a;
    if(b%c!=0)
        t2 = b-(b%c);
    else
        t2 = b;
    tmp = (t2-t1)/c;
    tmp++;
    tmp-=cnt;
    if(t2<t1)
    {
        tmp=0;
    }
    //cout << tmp << endl;
    if(a%d!=0)
        t1 = a+(d-a%d);
    else
        t1 = a;
    if(b%d)
        t2 = b-(b%d);
    else
        t2 = b;
    tmp1 = (t2-t1)/d;
    tmp1++;
    tmp1-=cnt;
    if(t2<t1)
    {
        tmp1=0;
    }
    //cout << tmp1 << endl;
    cout << b-a+1-cnt-tmp1-tmp << endl;
}


Measured memory_bytes: 256
#include <iostream>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

constexpr long long M = 1000000007;
modint<M> pow(int a, int n) {
    if (n <= 0) return 1;
    modint<M> x = pow(a, n/2);
    x *= x;
    if (n%2 == 1)
      x *= a;
    return x;
}

int main() {
    long long N;
    std::cin >> N;
    auto ans = pow(10, N);
    ans -= pow(9, N) * 2;
    ans += pow(8, N);
    std::cout << ans.a << std::endl;
}


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

typedef long long ll;
typedef string str;

typedef vector<int> vi;

#define pb push_back 
#define srt(v) sort(v.begin(), v.end())

#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,a,n) for (int i = n - 1; i >= a; i--)

#define f first
#define s second

#define sq(a) a * a

#define endl '\n'

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    
    int temp;
    cin >> temp;

    if (temp >= 30) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin>>n;
    ll sqrtn = sqrtl(n);
    ll ans = 0;
    for(ll i=1;i<=sqrtn;++i)
    {
        if((n-i)%i==0 && (n-i)/i>i)
        {
            ans += (n-i)/i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
//#include <functional>
//#include <cmath>

int64_t GetGcd(int64_t big, int64_t small){
    int64_t res = big % small;
    if(res == 0){
        return small;
    }
    else{
        return GetGcd(small, res);
    }
}

int64_t GetNumMulti(int64_t begin, int64_t end, int64_t factor){
    int64_t res = end/factor - begin/factor;
    if(begin % factor == 0){
        res++;
    }
    return res;
}

int main(){
    double W, H, x, y;
    std::cin >> W >> H >> x >> y;
    
    //max value of not larger area => half of the original size
    //the line on (x,y) (W-x, H-y) looks appropriate. -> and the area is HW/2
    double area = W * H / 2;
    int32_t flag = 0;
    if( x == W / 2 && y == H / 2){
        flag = 1;
    }
    std::cout << area << " " << flag;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
D, X = input().split(' ')
D = int(D)
X = int(X)
count = 0
for i in range(N):
  a = int(input())
  count += 1
  for j in range(1, D, 1):
    if (D - 1) - a * j >= 0:
      count += 1   
print(count + X)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC target ("avx")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()

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;
}
template<class T> inline int getidx(vector<T> &v, T a) {
	return lower_bound(all(v), a) - v.begin();
}

constexpr int mod=998244353;
constexpr int inf=3e18;

int gcd(int x, int y) {
	if (y == 0)
		return x;
	return gcd(y, x % y);
}
int R[4005],G[4005],B[4005];
int RR[4005],GG[4005],BB[4005];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;string S;
	cin>>N>>S;
	rep(i,N){
		if(S[i]=='R'){
			R[i]++;RR[i]++;
		}else if(S[i]=='G'){
			G[i]++;GG[i]++;
		}else {
			B[i]++;BB[i]++;
		}
		R[i+1]+=R[i];
		G[i+1]+=G[i];
		B[i+1]+=B[i];
	}
	for(int i=N-1;i>0;i--){
		RR[i-1]+=RR[i];
		GG[i-1]+=GG[i];
		BB[i-1]+=BB[i];
	}
	int ans=0;
	REP(i,N-1){
		if(S[i]=='R'){
			ans+=G[i-1]*BB[i+1];
			ans+=B[i-1]*GG[i+1];
		}
		else if(S[i]=='G'){
			ans+=R[i-1]*BB[i+1];
			ans+=B[i-1]*RR[i+1];
		}else {
			ans+=R[i-1]*GG[i+1];
			ans+=G[i-1]*RR[i+1];
		}
		REP(j,N+1){
			if(i-j<0||i+j>=N)break;
			if(S[i-j]!=S[i]&&S[i]!=S[i+j]&&S[i-j]!=S[i+j])ans--;
		}
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 3840
from itertools import permutations
from collections import Counter
N=int(input())
XY=[list(map(int,input().split())) for _ in range(N)]
if N==1:print(1);exit()
a=[((A[0]-B[0]),(A[1]-B[1])) for A,B in permutations(XY,2)]
cnt = Counter(a)
print(N-cnt.most_common()[0][1])

Measured memory_bytes: 3956
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let m: usize = read();

    let mut aa: Vec<usize> = (0..a).map(|_| read()).collect();
    let mut bb: Vec<usize> = (0..b).map(|_| read()).collect();
    let xyc: Vec<(usize, usize, usize)> = (0..m).map(|_| (read(), read(), read())).collect();

    let ans: usize = xyc
        .iter()
        .map(|&(x, y, c)| aa[x - 1] + bb[y - 1] - c)
        .min()
        .unwrap();

    aa.sort();
    bb.sort();

    println!("{}", std::cmp::min(ans, aa[0] + bb[0]));
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int N, M, color[700], ta, ha, d[700][700], dp[700][701];
vector<int> G[700];
vector<pair<int, int>> ve;

bool dfs(int v, int c){
	color[v] = c;
	if(c == 1) ta++; else ha++;
	for(int i=0; i<G[v].size(); i++){
		if(color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
		if(color[G[v][i]] == c) return false;
	}
	return true;
}

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		int a, b; cin >> a >> b;
		a--; b--;
		d[a][b] = 1; d[b][a] = 1;
	}
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(i != j){
				if(d[i][j] == 0) G[i].push_back(j);
			}
		}
	}
	int f = 0;
	for(int i=0; i<N; i++){
		if(color[i] == 0){
			if(!dfs(i, -1)) f = 1;
			else{
				ve.push_back({ta, ha});
			}
		}
		ta = 0; ha = 0;
	}
	if(f) cout << -1 << endl;
	else{
		int n = ve.size();
		dp[0][ve[0].first] = 1;
		dp[0][ve[0].second] = 1;
		for(int i=1; i<n; i++){
			for(int j=0; j<N+1; j++){
				if(ve[i].first <= j && dp[i-1][j-ve[i].first] == 1){
					dp[i][j] = 1;
				}
				if(ve[i].second <= j && dp[i-1][j-ve[i].second] == 1){
					dp[i][j] = 1;
				}
			}
		}
		int mi = 0;
		for(int i=0; i<N+1; i++){
			if(dp[n-1][i] == 1){
				if(abs(N - 2 * mi) > abs(N - 2 * i))
					mi = i;
			}
		}
		int ans = (mi * (mi - 1) + (N-mi) * (N-mi-1)) / 2;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 1e6;

int main(){
    vector<int> th(200);
    for(int i=1; i<=200; i++){
        th[i] = i*(i+1)*(i+2)/6;
    }
    vector<int> dp(MAX, MAX), dp2(MAX, MAX);
    dp[0]=0; dp2[0]=0;
    for(int i=0; th[i]<MAX; i++){
        for(int j=0; j+th[i]<MAX; j++){
            if(dp[j]+1 < dp[j+th[i]]){
                dp[j+th[i]] = dp[j]+1;
            }
        }
        if(th[i]%2==0) continue;
        for(int j=0; j+th[i]<MAX; j++){
            if(dp2[j]+1 < dp2[j+th[i]]){
                dp2[j+th[i]] = dp2[j]+1;
            }
        }
    }
    
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        cout << dp[n] << " " << dp2[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 10468
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, 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 1; } return 0; }

//参考: https://pyteyon.hatenablog.com/entry/2019/03/11/200000
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll find(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return find(x) == find(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[find(x)];
    }
};

int main() {
    int x, y;
    cin >> x >> y;
    
    UnionFind uf(13);
    uf.unite(1,3);
    uf.unite(3,5);
    uf.unite(5,7);
    uf.unite(7,8);
    uf.unite(8,10);
    uf.unite(10,12);

    uf.unite(4,6);
    uf.unite(6,9);
    uf.unite(9,11);
    
    if (uf.issame(x,y))cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3608
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);

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

	const int N = 100005;
	int n;
	pair<int, int> f1, s1, f2, s2, fr[N];
	for(int i = 0 ; i < N ; i++){
		fr[i].second = i;
		fr[i].first = 0;
	}
	cin >> n;
	int a[n];
	for(int i = 0 ; i < n ; i++){
		cin >> a[i];
	}
	for(int i = 0 ; i < n ; i += 2){
		++fr[a[i]].first;
	}
	sort(fr, fr + N);
	f1 = fr[N - 1];
	s1 = fr[N - 2];

	for(int i = 0 ; i < N ; i++){
		fr[i].second = i;
		fr[i].first = 0;
	}
	for(int i = 1 ; i < n ; i += 2){
		++fr[a[i]].first;
	}
	sort(fr, fr + N);
	f2 = fr[N - 1];
	s2 = fr[N - 2];

	if(f1.second != f2.second){
		cout << (n >> 1) - f1.first + (n >> 1) - f2.first;
	}else{
		if(s1.first < s2.first){
			cout << (n >> 1) - f1.first + (n >> 1) - s2.first;
		}else{
			cout << (n >> 1) - s1.first + (n >> 1) - f2.first;
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<set>
using namespace std;
int main(){
	string s;
	cin>>s;
	set<char>st;
	for(int i = 0 ; i < s.length() ; i++){
		st.insert(s[i]);
	}
	if(st.size() == 2){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}

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

int main() {
  int N, l, r, A;
  cin >> N;
  A=0;  
    for (int i=0;i<N;i++) {
      cin >> l >> r;
      A += r-l+1;
    }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string n;   cin >> n;
    int K;  cin >> K;
    vector<vector<vector<int> > >dp(n.size()+1, vector<vector<int> >(5, vector<int>(2)));
    dp[0][0][0] = 1;
    for(int i = 0; i < n.size(); i++){
        int d = n[i] - '0';
        for(int j = 0; j <= K; j++){
            rep(k, 2)   rep(c, 10){
                if(k == 0 && c > d) continue;
                dp[i+1][j + (c != 0)][k || (c < d)] += dp[i][j][k];
            }
        }
    }
    cout << dp[n.size()][K][0] + dp[n.size()][K][1] << endl;
}



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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

long long GCD(long long a, long long b) {
    return (b % a == 0) ? a : GCD(b % a, a);
}

long long LCM(long long a, long long b) {
    return (a / GCD(a, b)) * b;
}

int fac2(long long x) {
    int c = 0;
    while (x % 2 == 0) {
        x /= 2;
        c ++;
    }
    return c;
}

int main() {
    long long N, M;
    cin >> N >> M;
    vector<long long> a(N);
    for (int i=0; i<N; ++i) {
        cin >> a[i];
        a[i] /= 2;
    }

    for (int i=0; i<N-1; ++i) {
        if (fac2(a[i]) != fac2(a[i+1])) {
            cout << 0 << endl;
            return 0;
        }
    }

    long long l = a[0];
    for (int i=1; i<N; ++i) {
        l = LCM(l, a[i]);
        if (l > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (M / l + 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,len,flg;
	char s[3];
	scanf("%s",s);
	len=strlen(s);
	flg=0;
	for(i=1;i<=len;i++){
		if(s[1]=='B'){
			flg=1;
		}
		else{
			flg=0;
		}
	}
	if(flg==1){
		printf("ARC\n");
	}
	else{
		printf("ABC\n");
	}
	return 0;
}

Measured memory_bytes: 1660
io = STDIN
N,T=io.gets.split.map(&:to_i)
ct=[]
N.times do
  ct<<io.gets.split.map(&:to_i)
end
CT=ct.select{|c,t|t<=T}.sort_by!{|c,t|c}.first
if CT==nil
  puts "TLE"
else
  puts CT.first
end


Measured memory_bytes: 1788
H, W = map(int, input().split())
m = [input() for i in range(H)]

cnt = 0
for h in range(H):
    for w in range(W):
        if m[h][w] == '#':
            cnt += 1

def rec(x, y):
    if x == W - 1 and y == H - 1:
        return True

    if m[y][x] != '#':
        return False
    dx = [0, 1]
    dy = [1, 0]

    for i in range(2):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < W and \
           0 <= ny and ny < H:
            ret = rec(nx, ny)
            if ret:
                return ret
    return False


if rec(0, 0) and cnt == H + W - 1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3064
# your code goes here
from itertools import product
def inpl(): return map(int, input().split())

N = int(input())
F = [tuple(inpl()) for _ in range(N)]
P = [tuple(inpl()) for _ in range(N)]

result = -1 * 10**12
for T in product([0, 1], repeat=10):
    if sum(T) == 0:
        continue
    tmp = 0
    for i in range(N):
        c = sum([f*t for f, t in zip(F[i], T)])
        tmp += P[i][c]
    result = max(result, tmp)
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    map<int,queue<string>>kind;
    int sum=0;
    set<string>str;
    for(int i=0;i<N;i++)
    {
        string tmp;
        cin>>tmp;
        str.insert(tmp);
       
    }
    cout<<str.size()<<endl;
}    

Measured memory_bytes: 19232
def main():
    n, a, b = map(int, input().split(" "))
    x = list(map(int, input().split(" ")))
    fatigue = 0
    current = x[0]

    for x_i in x[1:]:
        fatigue = fatigue + min((x_i - current) * a, b)
        current = x_i
    print(fatigue)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    string s; cin >> s;
    if(s.size() == 2)cout << s << endl;
    else cout << s[2] << s[1] << s[0] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int ant[5], min, max, i, k;

    for (i = 0; i < 5; i++)
        scanf("%d", &ant[i]);

    scanf("%d", &k);

    min = max = ant[0];
    for (i = 1; i < 5; i++){
        if(min > ant[i]){
            min = ant[i];
        }else if(max < ant[i]){
            max = ant[i];
        }else{
            continue;
        }
    }
    printf("%s", (max - min <= k) ? "Yay!" : ":(");
    return 0;
}

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

int main(){
  int n,a[100];
  int k =0;

  for (int i=0;i<100;i++) a[i]=2;

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

  for(int i=0;i<n;i++){
    if ((i+1)%2==1 && a[i]%2==1){
      k++;
    }
  }
  cout<<k<<endl;
  
}


Measured memory_bytes: 3668
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a + b >= c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

cnt = S[1:].count("E")
ans = cnt
for i in range(1,N) :
    if S[i-1] == "W" :
        cnt += 1
    if S[i] == "E" :
        cnt -= 1
    
    ans = min(ans,cnt)
print(ans)

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
string S;
VL wsum, esum;

int main() {
    cin >> N >> S;
    wsum.resize(N + 2);
    esum.resize(N + 2);
    REP(i, N) {
        wsum[i + 1] += wsum[i] + (S[i] == 'W' ? 1 : 0);
        esum[N - i] += esum[N - i + 1] + (S[N - 1 - i] == 'E' ? 1 : 0);
    }
    ll ans = LINF;
    FOR(i, 1, N + 1) ans = min(ans, wsum[i - 1] + esum[i + 1]);
    cout << ans << "\n";
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, a, b;
  cin >> x >> a >> b;
  if(b <= a)
    cout << "delicious" << endl;
  else if(b > a && b <= a + x)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 256
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
n,w = MI()
if w>=n:
	print("unsafe")
else:
	print("safe")

Measured memory_bytes: 9188
import static java.lang.System.*;

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] $) {
		SC sc = new SC(in);
		int n = sc.nextInt();
		int inf=Integer.MAX_VALUE;
		Point[] red=new Point[n];
		for (int i=0;i<n;i++)red[i]=new Point(sc.nextInt(),sc.nextInt());
		Point[] blue=new Point[n];
		for (int i=0;i<n;i++)blue[i]=new Point(sc.nextInt(),sc.nextInt());
		Arrays.sort(blue,(p1,p2)->p1.x-p2.x);
		int ans=0;
		for (int i = 0; i < n; i++) {
			Point b=blue[i];
			int red_y=-1;
			int red_index=-1;
			for (int j = 0; j < n; j++) {
				Point r=red[j];
				if(d(b,r)){
					if(red_y<r.y){
						red_y=r.y;
						red_index=j;
					}
				}
			}
			if(red_index>-1){
				ans++;
				red[red_index]=new Point(inf,inf);
			}
		}
		pl(ans);
	}
	static boolean d(Point blue,Point red){
		return red.x<blue.x&&red.y<blue.y;
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 26708
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var AB = new (int A, int B)[N];

        for (int i = 0; i < N; i++)
        {
            var _AB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            AB[i] = (_AB[0], _AB[1]);
        }

        var sortedAB = AB.OrderBy(x => x.B).ToArray();

        var now = 0L;
        var ok = true;

        for (int i = 0; i < N; i++)
        {
            now += sortedAB[i].A;
            if(now > sortedAB[i].B)
            {
                ok = false;
                break;
            }
        }

        var ans = ok ? "Yes" : "No";

        WriteLine(ans);
    }
}


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

void print_func(string str, int a, int b) {
    for(int i=a; i<=b; ++i) {
        cout << str[i];
    }
    cout << endl;
}

string reverse_func(string str, int a, int b) {
    string result = "";
    string str_before_a = str.substr(0, a);
    string str_after_b = str.substr(b+1, str.size()-b);
    string str_middle = str.substr(a, b-a+1);

    result += str_before_a;
    for(int i=str_middle.size()-1; i>=0; --i) {
        char c = str_middle[i];
        string c_str = {c};
        result += c_str;
    }
    result += str_after_b;

    return result;
}

string replace_func(string str, int a, int b, string p) {
    string result = "";
    string str_before_a = str.substr(0, a);
    string str_after_b = str.substr(b+1, str.size()-b);

    result += str_before_a;
    result += p;
    result += str_after_b;

    return result;
}

int main() {
    string str;
    cin >> str;

    int q;
    cin >> q;

    string op;
    for(int i=0; i<q; ++i) {
        cin >> op;

        if(op == "print") {
            int a, b;
            cin >> a >> b;
            print_func(str, a, b);
        } else if (op == "reverse") {
            int a, b;
            cin >> a >> b;
            str = reverse_func(str, a, b);
        } else if (op == "replace") {
            int a, b;
            string p;
            cin >> a >> b >> p;
            str = replace_func(str, a, b, p);
        }
    }

    return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>
#include<string.h>
#define SIZE 100000

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[SIZE];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%SIZE;
}

P dequeue(){
  P x;
  x=Q[head];
  head=(head+1)%SIZE;

  return x;

}

int min(int a,int b){
  if(a>b){
    return b;
  }
  else{
    return a;
  }
}

int main(){
  int time=0;
  int c,i,q;
  P p;

  scanf("%d%d",&n,&q);

  for(i=1;i<n+1;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    p=dequeue();
    c=min(q,p.t);
    p.t=p.t-c;
    time=time+c;
    if(p.t>0){
      enqueue(p);
    }
    else{
      printf("%s %d\n",p.name,time);
    }
  }

  return 0;
}
      
  



Measured memory_bytes: 11852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R') cout<<3;
    else if( (s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R') ) cout<<2;
    else if( s[0]=='R'|| s[1]=='R'|| s[2]=='R') cout<<1;
    else cout<<0;

    cout<<endl;
}


Measured memory_bytes: 3624
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; m],
    }

    let mut s = 0;
    for x in a {
        s += x;
    }

    let res = if s > n {
        -1
    } else {
        (n - s) as isize
    };

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


Measured memory_bytes: 2244
N,M=map(int,input().split())
set_list=[]
sets=set()
for i in range(N):
    s=input().split()
    s.pop(0)
    set_list.append(set(s))
for set in set_list:
    if len(sets)==0:
        sets=set
    else:
        sets=sets.intersection(set)
print(len(sets))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod ll(1e9+7)
ll exp(ll a,ll b)
{
	if(b==0)
	 return 1;
	if(b%2==0){
		return exp(a*a%mod,b/2);
	}
	return a*exp(a*a%mod,(b-1)/2)%mod;
}
int main()
{
	int n;
	cin>>n;
	vector<ll>arr1(n),arr2(n);
	for(int i=0; i<n; i++){
		ll x,y;
		cin>>x>>y;
		arr1[i]=x-y;
		arr2[i]=x+y;
	}
	sort(arr1.begin(),arr1.end());
	sort(arr2.begin(),arr2.end());
	ll ans1=arr1[n-1]-arr1[0];
	ll ans2=arr2[n-1]-arr2[0];
	cout<<max(ans1,ans2);
	return 0;
	
	
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}

#define ll long long
#define f first
#define s second
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

int main()
{
	// 入力
	ll N, M;
	cin >> N >> M;
	vector<string> A(N), B(M);
	REP(i, N) {
		cin >> A[i];
	}
	REP(i, M) {
		cin >> B[i];
	}

	bool isequal = true;
	REP(i, N - M + 1) {		//縦の位置
		REP(j, N - M + 1)	{	//横の位置
			//一致確認
			REP(k, M) {
				isequal = true;
				if (A[k + i].substr(j, M) == B[k]) {
					// debug(A[k + i]);
					// debug(B[k]);
					continue;
				}
				else {
					isequal = false;
					break;
				}
			}
			if (isequal) {
				cout << "Yes" << endl;
				return 0;
			}
		}

	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,l[2001];
ll w[2001];
ll cur;
ll k;
int main() {
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>l[i];
	}
	sort(l+1,l+n+1);
	
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			if(l[i]+l[j]<=l[j+1])
				continue;
			ll le=j+1,r=n;
			while(le<r)
			{
				ll m = (le+r)/2;
				if(l[m]>=l[i]+l[j])
					r=m;
				else
				{
					if(l[m+1]<l[i]+l[j])
						le=m+1;
					else
					{
						le=m;
						break;
					}
				}
			}
			k+=le-j;
		}
	}
	
	cout<<k;
}

Measured memory_bytes: 256
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            N.append(input())
        except EOFError:
            break
    return N

N = int(input())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]

for i in range(1,4):
    P = 0
    for j in range(N):
        P += (math.fabs(X[j]-Y[j]))**i
    P = P**(1/i)
    print(P)

P4 = []
for i in range(N):
    P4.append(math.fabs(X[i]-Y[i]))
print(max(P4))



Measured memory_bytes: 5744
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, m;
    cin >> n >> m;
    int cost[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    vector<int> dp(n + 1);
    rep(i, n + 1) dp[i] = -1;
    dp[0] = 0;
    Rep(i, 1, n + 1) rep(j, m) if (i - cost[a[j]] >= 0) dp[i] = max(dp[i], dp[i - cost[a[j]]] + 1);
    int N = dp[n];
    rep(i, N) rep(j, m)
    {
        if (n - cost[a[j]] < 0)
            continue;
        if (dp[n] == dp[n - cost[a[j]]] + 1)
        {
            cout << a[j];
            n -= cost[a[j]];
            break;
        }
    }
    cout << endl;
}

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

#define fastio 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

string n;
int k;

long long cc[101][4][2];

long long dp(int idx, int nonZero, int check){
  if(idx == (int)n.size())
    return nonZero == k;
  if(nonZero > k)
    return 0;
  long long &ans = cc[idx][nonZero][check];
  if(~ans)
    return ans;
  ans = 0;
  if(check){
    for(int i = 0; i <= (n[idx] - '0'); i++){
      ans += dp(idx + 1, nonZero + (i != 0), i == (n[idx] - '0'));
    }
  }else{
    for(int i = 0; i <= 9; i++){
      ans += dp(idx + 1, nonZero + (i != 0), 0);
    }
  }
  return ans;
}

void solve(){
  cin >> n >> k;
  memset(cc, -1, sizeof cc);
  cout << dp(0, 0, 1) << '\n';
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL); 

  pre();

  int t = 1;
  // cin >> t;
  while(t--){
    solve();
  }

  ktj();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  for(int i=1;i<=10000;i++){
    if(floor(i*0.08)==a&&floor(i*0.1)==b){
      cout<<i<<endl;
      exit(0);
    }
  }
   cout<<"-1"<<endl;
}

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

using namespace std;

int field[13][13];
int cont = 0;
int dx[] = {0, 1, 0, -1} , dy[] = {1, 0, -1, 0};
int dfs(int sx, int sy)
{
	if(field[sy][sx])
	{
		field[sy][sx] = 0;
		for(int i = 0; i < 4; i++)
		{
			for(int j = 0; j < 4; j++)
			{
				int nx = sx + dx[i] , ny = sy + dy[i];

				if(nx >= 0 && ny >= 0 && ny < 12 && nx < 12 && field[ny][nx] == 1)
				{
					dfs(nx, ny);
				}
			}
		}
	}
}

int main()
{
	int cont = 0;
	int sx, sy;
	char w;
	while(cin >> w)
	{
		//cin.ignore();
		//field[0][0] = w - '0';
		for(int i = 0; i < 12; i++)
		{
			for(int j = 0; j < 12; j++)
			{
				if(i != 0 || j != 0) cin >> w;
				field[i][j] = w - '0';
			}
		}
		for(int i = 0; i < 12; i++)
		{
			for(int j = 0; j < 12; j++)
			{
				if(field[i][j] == 1)
				{
					dfs(j, i);
					cont++;
				}
			}
		}
		cout << cont << endl;
		cont = 0;
	}
}

Measured memory_bytes: 0
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] t = new long[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextLong();
		}
		sc.close();

		long ans = 1;
		for (int i = 0; i < n; i++) {
			ans = lcm(ans, t[i]);
		}
		System.out.println(ans);
	}

	static long lcm(long a, long b) {
		BigInteger ba = BigInteger.valueOf(a);
		BigInteger bb = BigInteger.valueOf(b);
		return ba.multiply(bb).divide(ba.gcd(bb)).longValue();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int W,H,x,y;
    cin>>W>>H>>x>>y;
    double ans=(double)H*(double)W/2.0;
    if(2*x==W&&2*y==H){
        cout<<ans<<" 1"<<endl;
    }else{
        cout<<ans<<" 0"<<endl;
    }
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s,t;
  cin >> s >> t;
  bool a = true;
  rep(i,3){
    if(s.at(i)!=t.at(2-i)){
      a=false;
    }
  }
  if(a){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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

namespace AtTest.ABC_166
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int[] hs = ReadInts();
            bool[] ok = new bool[n];
            for(int i = 0; i < n; i++)
            {
                ok[i] = true;
            }

            for (int i = 0; i < m; i++)
            {
                int[] ab = ReadInts();
                int a = ab[0] - 1;
                int b = ab[1] - 1;
                if (hs[a] <= hs[b])
                {
                    ok[a] = false;
                }
                if (hs[b] <= hs[a])
                {
                    ok[b] = false;
                }
            }

            int res = 0;
            for(int i = 0; i < n; i++)
            {
                if (ok[i])
                {
                    res++;
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 48660
#include <cstdio>
#include <algorithm>
#define N 100005

int n;
int c[5];
char s[N][5], ans[N];

int main() {
    int *a = c - 'A';
    scanf("%d%d%d%d", &n, a + 'A', a + 'B', a + 'C');
    for (int i = 1; i <= n; ++i) scanf("%s", s[i]);
    for (int i = 1; i <= n; ++i)
        if (!a[s[i][0]] && !a[s[i][1]]) {
            puts("No");
            return 0;
        } else if (a[s[i][0]] < a[s[i][1]] || (a[s[i][0]] == a[s[i][1]] && i < n && (s[i][0] == s[i + 1][0] && s[i][1] != s[i + 1][1] || s[i][0] == s[i + 1][1] && s[i][1] != s[i + 1][0]))) ++a[s[i][0]], --a[s[i][1]], ans[i] = s[i][0];
        else --a[s[i][0]], ++a[s[i][1]], ans[i] = s[i][1];
    puts("Yes");
    for (int i = 1; i <= n; ++i) printf("%c\n", ans[i]);
}


Measured memory_bytes: 2316
def main(str)
  lines = str.split("\n")
  ss = lines[1..-1]
  ans = ss.each_with_object({"AC" => 0, "WA" => 0, "TLE" => 0, "RE" => 0}) do |x, m|
    m[x] += 1
  end
  ans.map { |x, n| "#{x} x #{n}" }.join("\n")
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("AC x 3
WA x 1
TLE x 2
RE x 0", main("6
AC
TLE
AC
AC
WA
TLE"))
    assert_equal("AC x 10
WA x 0
TLE x 0
RE x 0", main("10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC"))
  end
end




Measured memory_bytes: 19532