akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

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

int main() {
    int n, k, sum = 0, m = 0;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        sum += p[i];
        if (i >= k) {
            sum -= p[i - k];
        }
        m = max(m, sum);
    }
    cout << fixed << setprecision(10);
    cout << (m + k) / 2.0 << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> a(3*N);
    for (int i=0; i<3*N; i++) cin >> a.at(i);
    sort(a.begin(), a.end(), greater<int>());
    long long sum = 0;
    for (int i=0; i<N; i++) sum += a.at(i*2+1);
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 20;
const int MM = 1000000007;

int D[MX], vst[MX], cnt[MX], cycle[MX];
	ll T[MX], U[MX], V[MX];
int N;

void dfs(int x, int c = 1){
	if( vst[x] ){
		if( vst[x] == -1 ) cnt[x] = c - 1;
		else{
			int t = x;
			do{
				cycle[D[t]] = t;
				t = D[t];
			}while(t != x);
			cnt[x] = vst[x] - 1;
		}
		return;
	}
	vst[x] = c;
	dfs(D[x], c+1);
	vst[x] = -1;
}

int indeg[MX];

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", D+i), indeg[D[i]]++;
	for(int i = 1; i <= N; i++){
		if( indeg[i] >= 3 ) return !printf("0\n");
	}
	for(int i = 1; i <= N; i++){
		if( vst[i] || indeg[i] ) continue;
		dfs(i);
	}
	for(int i = 1; i <= N; i++){
		if(vst[i]) continue;
		dfs(i);
	}
	for(int i = 1; i <= N; i++) if( !cycle[i] && cnt[i] ) return !printf("0\n");

	ll ans = 1;
	for(int i = 1; i <= N; i++){
		if( !cnt[i] ) continue;
		int x = i;
		for(int j = 1; j < cnt[i]; j++){
			x = cycle[x];
			if( cnt[x] ) return !printf("0\n");
		}
		if( !cnt[cycle[x]] ) ans = ans*2 % MM;
	}

	for(int i = 1; i <= N; i++) vst[i] = 0;
	map<int, int> L;
	int c1 = 0;
	for(int i = 1; i <= N; i++){
		if( vst[i] || !cycle[i] ) continue;
		int tt = 0, ch = 1;
		int x = i;
		do{
			x = D[x]; vst[x] = 1;
			if( cnt[x] ) ch = 0;
			tt++;
		}while(x != i);
		if( ch ) L[tt] += 1;
	}
	for(auto c : L){
		T[0] = 1; T[1] = c.first >= 2 && c.first%2 == 1 ? 2 : 1;
		for(int i = 2; i <= c.second; i++){
			T[i] = (T[i-1] * T[1] + T[i-2] * c.first % MM * (i-1)) % MM;
		}
		ans = ans * T[c.second] % MM;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 14464
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {

	int w, h, n, x[100], y[100], a[100], s;
	

	cin >> w >> h >> n;

	int minx = 0, maxx = w, miny = 0, maxy = h;

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

		if (a[i] == 1) {
			minx = max(minx, x[i]);
		}
		else if (a[i] == 2) {
			maxx = min(maxx, x[i]);
		}
		else if (a[i] == 3) {
			miny = max(miny, y[i]);
		}
		else {
			maxy = min(maxy, y[i]);
		}

		//printf("minx%d,maxx%d;miny%d,maxy%d\n", minx, maxx, miny, maxy);
	}

	s = max(0, (maxx - minx))*max(0, (maxy-miny));

	cout << s << "\n";

	return 0;
}

Measured memory_bytes: 256
// Author: HarshKumar
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);

    string s;
    cin >> s;
    for (char c : s)
        cout << (c != '?' ? c : 'D');
}


Measured memory_bytes: 3772
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  let blackboard = input[1].map(Number);

  let answer = 0;

  while (true) {
    if (blackboard.some((A) => A % 2 !== 0)) {
      break;
    }

    blackboard = blackboard.map((A) => A / 2);

    answer += 1;
  }

  return answer;
};

console.log(main(read()));


Measured memory_bytes: 29712
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
// --------------------------------------------------</TEMPLATE>--------------------------------------------------

void solve()
{
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    //sort(arr,arr+n);
    ll ans=0;
    for(ll i=0;i<n-2;i++)
    {
        for(ll j=i+1;j<n-1;j++)
        {
            if(arr[i]==arr[j])
                continue;
            for(ll k=j+1;k<n;k++)
            {
                if(arr[j]==arr[k] || arr[i]==arr[k])
                continue;
                if(arr[i]+arr[j]>arr[k] && arr[i]+arr[k]>arr[j] && arr[j]+arr[k]>arr[i])
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
}

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


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

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

    let answer = solve(&buf);

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

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

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();
    let h: Vec<usize> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();
    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..m {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        let b: usize = iterator.next().unwrap().parse().unwrap();
        graph[a - 1].push(b - 1);
        graph[b - 1].push(a - 1);
    }

    let mut count: usize = 0;
    for i in 0..n {
        let mut is_good = true;
        for j in graph[i].iter() {
            if h[i] <= h[*j] {
                is_good = false;
                break;
            }
        }
        if is_good {
            count += 1;
        }
    }
    return count.to_string();
}


Measured memory_bytes: 10900
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

intt arr[305][305], pos[305], used[305], cnt[305];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt n, m;
    cin >> n >> m;
    for (intt i = 1; i <= n; i++)
        for (intt j = 1; j <= m; j++)
            cin >> arr[i][j];
    for (intt i = 1; i <= n; i++)
        pos[i] = 1;
    intt res = INF;
    for (intt j = 1; j <= m; j++) {
        memset (cnt, 0, sizeof (cnt));
        for (intt i = 1; i <= n; i++) {
            for (; used[arr[i][pos[i]]]; pos[i]++);
            cnt[arr[i][pos[i]]] ++;
        }
        intt mx = 0, idx;
        for (intt i = 1; i <= m; i++)
            if (cnt[i] > mx)
                mx = cnt[i], idx = i;
        res = min (res, mx), used[idx] = 1;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())

coins = list(map(float, input().split()))

dp = [[0 for i in range(N+1)] for j in range(N)]

dp[0][0] = 1 - coins[0]
dp[0][1] = coins[0]

for j in range(1, N):
    for h in range(j+2):
        if h == 0:
            dp[j][h] = (1 - coins[j]) * dp[j-1][0]
        else:
            dp[j][h] = (1 - coins[j]) * dp[j-1][h] + coins[j] * dp[j-1][h-1]
     
print(sum(dp[-1][head] for head in range(N//2 + 1, N+1)))


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
#define int long long 
using namespace std;
const int mod = 998244353;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int n,f[300010][3][3][2];
char a[1000010];
inline int Not(){
	int fl=1;
	for(rint i=2;i<=n;++i)
	{
		if(a[i]==a[i-1]) fl=0; 
	}return fl;
}
signed main()
{
	scanf("%s",a+1);n=strlen(a+1);
	int fl=1;
	for(rint i=2;i<=n;++i) if(a[i]!=a[i-1]) fl=0;
	if(fl){
		cout<<1;return 0;
	}
	if(n<=3){
	    if(n==2) puts("2");
	    else{
	      if(a[1]!=a[2]&&a[1]!=a[3]&&a[2]!=a[3]) puts("3");
	      else if(a[1]==a[3]) puts("7");
	      else puts("6");
	    }
	    return 0;
    }
	int Sum=0;
	for(rint i=1;i<=n;++i) Sum+=(a[i]-'a');
	Sum%=3;
	f[1][0][0][0]=f[1][1][1][0]=f[1][2][2][0]=1;
	for(rint i=1;i<n;++i)
		for(rint j=0;j<=2;++j)
			for(rint k=0;k<=2;++k)
				for(rint p=0;p<2;++p)
					for(rint S=0;S<=2;++S)
						(f[i+1][(j+S)%3][S][p|(S==k)]+=f[i][j][k][p])%=mod;
	cout<<((f[n][Sum][0][1]+f[n][Sum][1][1])%mod+f[n][Sum][2][1]+Not())%mod;
	return 0;
}

Measured memory_bytes: 30208
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int[][] grid = new int[3][3];
		boolean[][] vis = new boolean[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				grid[i][j] = input.nextInt();
			}
		}
		int N = input.nextInt();
		boolean Bingo = false;
		for (int i = 0; i < N; i++) {
			int x = input.nextInt();
			for (int r = 0; r < 3; r++) {
				for (int c = 0; c < 3; c++) {
					if (grid[r][c]==x) {
						vis[r][c]=true;
						if (Row(vis,r)||Col(vis,c)||Diag(vis)||Diag2(vis)) {
							Bingo=true;
							break;
						}
					}
				}
				if (Bingo) break;
			}
			if (Bingo) break;
		}
		System.out.println(Bingo?"Yes":"No");
	}
	public static boolean Row(boolean[][] vis, int r) {
		for (int c = 0; c < 3; c++) {
			if (!vis[r][c]) return false;
		}
		return true;
	}
	public static boolean Col(boolean[][] vis, int c) {
		for (int r = 0; r < 3; r++) {
			if (!vis[r][c]) return false;
		}
		return true;
	}
	public static boolean Diag(boolean[][] vis) {
		for (int i = 0; i < 3; i++) {
			if (!vis[i][i]) return false;
		}
		return true;
	}
	public static boolean Diag2(boolean[][] vis) {
		for (int i = 0; i < 3; i++) {
			if (!vis[i][2-i]) return false;
		}
		return true;
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1001001001;



int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int pre = 0;
  int cnt = 0;
  int ans = 0;

  rep(i, n) {
    int cur = a[i];
    if (pre != cur) {
      if (cnt >= pre) ans += cnt - pre;
      else ans += cnt;

      pre = cur;
      cnt = 0;
    }
    cnt++;
  }
  if (cnt >= pre) ans += cnt - pre;
  else ans += cnt;

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    n %= 10;

    if(n == 3){
        cout << "bon" << endl;
    }else if(n == 0 || n == 1  || n == 6 || n == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%lld",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define mp make_pair
ll f[105][12];
ll p[105][12];
int main()
{
	ll i,j,k;
	ll n;
	sd(n);
	for(i=1;i<=n;i++)
	{
		for(j=0;j<10;j++)
		{
			sd(f[i][j]);
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=10;j++)
		{
			sd(p[i][j]);
		}
	}
	ll ans=-3e18;
	for(i=1;i<(1<<10);i++)
	{
		ll x=i;
		ll cnt[105];
		for(j=1;j<=n;j++)
			cnt[j]=0;
		for(j=0;j<10;j++)
		{
			ll y=x%2;
			if(y)
			{
				for(k=1;k<=n;k++)
				{
					if(f[k][j])
						cnt[k]++;
				}
			}
			x/=2;
		}
		ll temp=0;
		for(j=1;j<=n;j++)
			temp+=p[j][cnt[j]];
		ans=max(ans,temp);
	}
	printf("%lld\n",ans );
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end(), greater<long long>());
	long long ans = 0;
	for (int i = 0; i < N - 1; i++) ans += A[(i+1) / 2];
	cout << ans << endl;
}

Measured memory_bytes: 4840
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        long x = scan.nextLong();
        long y = scan.nextLong();
        if(x == y){
            System.out.println(1);
            return;
        }
        for(int i = 1; ; i++){
            if(x * (long)(Math.pow(2, i)) > y){
                System.out.println(i);
                return;
            }
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  //mint(ll x = 0):x((x%mod+mod)%mod) {} // for minus
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(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 ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
bool operator==(const mint& a, const mint& b){
  return a.x == b.x;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 2000005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;

int main(){
  int S;
  cin >> S;

  if(S == 1 || S == 2){
    cout << 0 << endl;
    return 0;
  }

  mint ret(0);
  
  REP(k,1,S){
    ll M = S - 3LL*k;
    if(M < 0) continue;

    ret += mutil.comb(M+k-1,M);
  }
  
  cout << ret << endl;
  
  return 0;
}



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

using namespace std;

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

    int n; cin >> n;
    string s, t; cin >> s >> t;
    for (int i = 0; i < n; ++i) cout << s[i] << t[i];

    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int r; cin >> r;
  cout << r * 2 * 3.141592653589 << endl;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    int n,m,v;
    cin>>n>>m;
    vector<string> s(n);
    for(auto&c:s) cin>>c;
    mf_graph<int> g(n*m+2);
    int S=n*m,T=n*m+1;
    fr(i,n) fr(j,m){
        if(s[i][j]=='#') continue;
        v=i*m+j;
        if((i+j)%2) g.add_edge(S,v,1);
        else g.add_edge(v,T,1);
        if(i && s[i-1][j]=='.'){
            if((i+j)%2) g.add_edge(v,v-m,1);
            else g.add_edge(v-m,v,1);
        }
        if(j && s[i][j-1]=='.'){
            if((i+j)%2) g.add_edge(v,v-1,1);
            else g.add_edge(v-1,v,1);
        }
    }
    cout<<g.flow(S,T)<<'\n';
    for(auto[fr,to,_,fl]:g.edges()){
        if(fr==S||to==T||fl==0) continue;
        if(fr>to) swap(fr,to);
        if(fr/m==to/m){
            s[fr/m][fr%m]='>';
            s[to/m][to%m]='<';
        }
        else{
            s[fr/m][fr%m]='v';
            s[to/m][to%m]='^';
        }
    }
    for(auto&c:s) cout<<c<<'\n';
}

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

Measured memory_bytes: 5468
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    int ans=0;
    if(n<=k)ans=n*x;
    else{
        ans=k*x+(n-k)*y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i=0; i<n; ++i)
        cin >> x[i] >> y[i];

    map<pair<int, int>, int> cnt;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            if(i == j)
                continue;
            int dy = y[i] - y[j];
            int dx = x[i] - x[j];
            ++ cnt[make_pair(dy, dx)];
        }
    }

    int ans = n;
    for(const auto& p : cnt)
        ans = min(ans, n - p.second);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import math
N = int(input())
C = str(input())

C = C.replace('W', '1').replace('R', '0')
C = list(C)
sort_C = sorted(C)

cnt = 0

for i in range(N):
    if C[i] != sort_C[i]:
        cnt += 1

print(math.ceil(cnt/2))

Measured memory_bytes: 12688
#include<bits/stdc++.h>
using namespace std;
const int ms = 1000;
int vet[ms];

int main(){
	vet[1] =vet[3] = vet[5] = vet[7] = vet[8] = vet[10]= vet[12] = 1;
	vet[4] = vet[6] = vet[9] = vet[11] = 2;
	vet[2] = 3;
	
	int a,b;
	cin >> a >> b;
	if(vet[a] == vet[b])
		cout<<"Yes";
	else
		cout<<"No";
		

}


Measured memory_bytes: 256
n, a, b, c ,d = map(int, input().split())
s = input()[:max(c,d)]

def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[a:c-2]:
        return "No"

    if c < d:
        return "Yes"
    
    else:

        if "..." in s[b-2:d+1]:
            return "Yes"
                
        return "No"

print(main())

Measured memory_bytes: 3572
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        ArrayDeque<Integer> l = new ArrayDeque<>();
        for (int i = 0; i < c; i++) {
            String op = sc.next();
            switch (op) {
                case "insert":
                    l.push(sc.nextInt());
                    break;
                case "delete":
                    l.remove(sc.nextInt());
                    break;
                case "deleteFirst":
                    l.removeFirst();
                    break;
                case "deleteLast":
                    l.removeLast();
                    break;
            }
        }
        StringBuilder sb = new StringBuilder();
        sb.append(l.poll());
        for (int n : l) {
            sb.append(" ").append(n);
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 482768
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  long long X = 0, x = 0, ans = 1000000000000000000LL;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    X += a[i];
  }
  for (int i = 0; i < n; i++) {
    x += a[i];
    if (i + 1 < n)
      ans = min(ans, abs(X - 2 * x));
  }
  cout << ans << endl;
}


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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	int x;
	scanf("%d",&x);
	printf("%s\n",x >= 30 ? "Yes":"No" );
	return 0;
}

Measured memory_bytes: 3684
// Problem: B - Go to Jail
// Contest: AtCoder - AtCoder Beginner Contest 179
// URL: https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9;
#define ld long double
#define PI 3.14159265358979323846
#pragma GCC optimize("-O2")
const int INF = 10000000;

int getIInput() {
	cout.flush();
	#ifdef LOCAL
	return generateLocalInputOrAnythingYouWant();
	#else
	int x;
	cin>>x;
	return x;
	#endif
}

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
//1. Ends here
 
//2. Extra Functions here
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	vector<array<int,2>>ar;
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		ar.push_back({x,y});
	}
	
	for(int i=2;i<n;i++){
		if(ar[i][0]==ar[i][1]){
			if(ar[i-1][0]==ar[i-1][1]){
				if(ar[i-2][0]==ar[i-2][1]){
					cout<<"Yes\n";
					return;
				}
			}
		}
	}
	
	
	cout<<"No\n";
    return;
}
// how r u bro

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main(){
string S1;
cin>>S1;
for(int i = 0; i<=S1.size();i++){
  S1[i]='x';
}
cout<<S1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
 
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   // freopen("./input.txt","r",stdin);
  //  freopen("./output.txt","w",stdout);
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;

    long long int c_low,c_high;
    c_low = a/c;
    if(a%c!=0)
        c_low++;
    c_high = b/c;

    long long int d_low,d_high;
    d_low = a/d;
    if(a%d!=0)
        d_low++;
    d_high = b/d;

    long long int e_low,e_high;
    long long int e = (d*c/__gcd(c,d));
    e_low = a/e;
    if(a%e!=0)
        e_low++;
    e_high = b/e;

    long long ans = b-a+1;
    // cout<<c_high<<endl<<c_low<<endl<<d_high<<endl<<d_low<<endl<<e_high<<endl<<e_low<<endl;
    cout<<ans-(c_high+d_high - e_high -c_low-d_low+e_low + 1);

    // cout<<e<<endl<<c_low<<endl<<c_high<<endl<<d_low<<endl<<d_high<<endl<<e_low<<endl<<e_high<<endl;

}

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

#define  BeatMeScanf  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  tc(x)        int x; cin >> x; while(x--)
#define  ll           long long
#define  vi           vector<int>
#define  pii          pair<int,int>
#define  mii          map<int,int>
#define  inf          1<<28
#define  mem(x,y)     memset(x, y, sizeof(x))
#define  ps(x,y)      fixed<<setprecision(y)<<x
#define  show(val)    cout<< #val << " -> " << val << endl
#define  Case         cout<< "Case "<< ++cs << ": "
#define  all(v)       (v).begin(), (v).end()
#define  rall(v)      (v).rbegin(), (v).rend()
#define  MOD          1000000007
#define  MAX          100005

int main()
{
    BeatMeScanf;
    int n;
    cin >> n;

    string str;
    cin >> str;
    
    int sz = str.size();
    if(sz <= n) cout << str << '\n';
    else
    {
        for (int i = 0; i < n; ++i)
            cout <<str[i];
        cout << "..." << '\n';

    }

    return 0;
}


Measured memory_bytes: 3636
/**
 * Space Coconut Grab
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	static final int[] y2 = new int[1001];
	static final int[] z3 = new int[101];
	static final int[] ys = new int[1000001];
	static final int[] zs = new int[1000001];

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		for (int i = 0; i <= 1000; i++) {
			y2[i] = i * i;
			ys[y2[i]] = i;
		}
		for (int i = 2; i <= 1000000; i++) {
			if (ys[i] == 0) ys[i] = ys[i - 1];
		}
		for (int i = 0; i <= 100; i++) {
			z3[i] = i * i * i;
			zs[z3[i]] = i;
		}
		for (int i = 2; i <= 1000000; i++) {
			if (zs[i] == 0) zs[i] = zs[i - 1];
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int e = parseInt(line);
			if (e == 0) break;

			int min = 1000001;
			for (int z = zs[e]; z >= 0; z--) {
				int _min = 0;
				_min += z;
				for (int y = ys[e - z3[z]]; y >= 0; y--) {
					_min += y;
					_min += e - z3[z] - y2[y];
					min = Math.min(min, _min);
				}
			}
			System.out.println(min);
		} //end while
	} //end main
}

Measured memory_bytes: 30472
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int[] X = new int[N];
		for(int i=0; i<N; i++)
			X[i] = sc.nextInt();
		
		long ans = 0;
		for(int i=1; i<N; i++)
			ans += Math.min((long)A*(X[i]-X[i-1]), B);
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 32036
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string s;
    cin >> s;
    int a = s[0] + s[1] + s[2] - ('0'*3);
    cout << a << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let c: Vec<char> = read::<String>().chars().collect::<Vec<char>>();
    let c = c[0] as u8;
    
    if 97 <= c {
        println!("a");
    } else {
        println!("A");
    }
}


Measured memory_bytes: 2136
#include <iostream>
#include <cstdio>
#include <set>
#define N 400
#define M 30
using namespace std;

typedef long long ll;
ll n, m = 26, c[M], s[N][M], ans[N];
set<ll> v[M];

ll score() {
	ll i, re = 0;
	set<ll>::iterator it1, it2;
	for (i = 0; i < m; i++) {
		it1 = it2 = v[i].begin();
		it2++;
		for (; it2 != v[i].end(); it1++, it2++) {
			ll t = *it2 - *it1;
			re -= t * (t - 1) / 2 * c[i];
			re += s[*it2][i];
		}
		ll t = n - *it1;
		re -= t * (t - 1) / 2 * c[i];
	}
	return re;
}

int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < m; i++) scanf("%lld", &c[i]);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%lld", &s[i][j]);
		}
	}
	for (i = 0; i < m; i++) v[i].insert(-1);
	for (i = 0; i < n; i++) {
		ll mx = -1e18, mi;
		for (j = 0; j < m; j++) {
			set<ll>::reverse_iterator it;
			it = v[j].rbegin();
			ll t = s[i][j] + (i - *v[j].rbegin()) * c[j];
			if (t > mx) mx = t, mi = j;
		}
		v[mi].insert(i);
		ans[i] = mi;
	}
	for (i = 0; i < n; i++) printf("%lld\n", ans[i] + 1);
//	cout << score() << endl;
    return 0;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin>>a>>b;
  int price=0;
  if(a==1){
    price+=300000;
  }else if(a==2){
    price+=200000;
  }else if(a==3){
    price+=100000;
  }
  if(b==1){
    price+=300000;
  }else if(b==2){
    price+=200000;
  }else if(b==3){
    price+=100000;
  }
  if(a==1 && b==1){
    price+=400000;
  }
  cout<<price<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n , k , q , arr[100006];
int main() {
	cin>>n>>k>>q;
	for(int i = 0; i<  q ; i++){
		int x ; cin>>x;
		arr[x]++;
	}
	for(int i = 1 ; i<= n ; i++){
		int mi = (q - arr[i]);
		arr[i] = 0;
		arr[i] -= mi;
		arr[i]+=k;
		if(arr[i] <=0)
			cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d) cout<<"Left"<<endl;
    else if(a+b<c+d) cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [10**9+7] * (10**5+2)
dp[0] = 0

for i in range(1, N+1):
    w, v = wv[i-1]
    for j in range(10**5, 0, -1):
        if j-v >= 0:
            dp[j] = min(dp[j], dp[j-v]+w)

ret = 0
for i in range(1, 10**5+1):
    if dp[i] <= W:
        ret = i

print(ret)


Measured memory_bytes: 41964
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sqrt

fun main(args: Array<String>) {
    var (a,b,h,m) = readLine()!!.split(" ").map { it.toInt() }

    var hd = (h + (m / 60.0)) / 6.0
    var md = m / 30.0

    var d = abs(hd - md)
    println(sqrt(a * a + b * b - 2 * a * b * cos(d * PI) ))

}

Measured memory_bytes: 36688
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  int num=1;
  for(int i=0; i<N; i++){
  if(num>K){
  num+=K;}
    else{
    num*=2;}
  }
  cout << num <<endl;
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		n %= k;
		if (k > n) {
			n = Math.min(n, Math.abs(n - k));
		}
		System.out.println(n);
	}
}


Measured memory_bytes: 22996
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
ll N;
ll M;
ll dp[305][305][305];
const ll K = 1E9 + 7 + 1E-5;
vector<pair<int, int>> v[305]; // v[r] = vector{l, x};
bool check(int r, int g, int b) {
  int k = max({r, b, g});
  for(auto pp: v[k]) {
    int ct = 0;
    int l = pp.first;
    if (r >= l) ct++;
    if (g >= l) ct++;
    if (b >= l) ct++;

    if (ct != pp.second) return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    int l, r, x;
    cin >> l >> r >> x;
    v[r].push_back({l, x});
  }
  dp[0][0][0] = 1;
  ll ret = 0;
  for(int r = 0; r <= N; ++r) {
    for(int g = 0; g <= N; ++g) {
      for(int b = 0; b <= N; ++b) {
        auto c = dp[r][g][b];
        if (!c) continue;

        if (!check(r, g, b)) {
          dp[r][g][b] = 0;
          continue;
        }
      
        int k = max({r, g, b}) + 1;
        if (k - 1 == N) {
          ret += dp[r][g][b];
          ret %= K;
        }
        dp[k][g][b] += dp[r][g][b] % K;
        dp[r][k][b] += dp[r][g][b] % K;
        dp[r][g][k] += dp[r][g][b] % K;

      }
    }
  }

  cout << ret << endl;
}


Measured memory_bytes: 221568
#include<iostream>
using namespace std;
long long gcd(long long x,long long y){return y?gcd(y,x%y):x;}
long long lcm(long long x,long long y){return x*y/gcd(x,y);}
long long N,M;
string S,T;
int main(){
    cin>>N>>M>>S>>T;
    long long L=lcm(N,M),n=N/gcd(N,M),m=M/gcd(N,M);
    for(int i=0;i<gcd(N,M);i++)if(S[n*i]!=T[m*i]){cout<<-1<<endl;return 0;}
    cout<<L<<endl;
    return 0;
}

Measured memory_bytes: 512
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

h,w,n, *xyxy = map(int,read().split())

def f(x,y):
    if y==0: return x
    elif x==h: return h+y
    elif y==w: return h+w+h-x
    else: return h+w+h+w-y    

m = iter(xyxy)
res = []
idx = 0
for x1,y1,x2,y2 in zip(m,m,m,m):
    if (x1*(h-x1)==0 or y1*(w-y1)==0) and (x2*(h-x2)==0 or y2*(w-y2)==0):
        res.append((f(x1,y1),idx))
        res.append((f(x2,y2),idx))
        idx += 1


res.sort()
#print(res)

st = []
for d,i in res:
    if st and st[-1] == i:
        st.pop()
    else:
        st.append(i)

if st:
    print("NO")
else:
    print("YES")











Measured memory_bytes: 52944
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/9/7.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5+5;
typedef long long ll;
ll a[N];

ll umin(ll a, ll b){
    return a<b? a:b;
}
ll umax(ll a, ll b){
    return a>b? a:b;
}

ll maxor(int n){
    int rank=0;
    
    int j;
    for(int i=59; i>=0; i--){
        for(j=rank; j<n; j++){
            if(a[j]& (1LL<<i)) break;
        }
        if(j==n) continue;
        
        if(j>rank) swap(a[j], a[rank]);
        
        for(j=rank+1; j<n; j++){
            a[j]=min(a[j], a[j]^a[rank]);
        }
        
        rank++;
    }
    ll ans=0;
    for(int i=0; i<n; i++)
        ans=umax(ans, ans^a[i]);
    
    return ans;
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n; cin>>n;
    
    ll all=0;
    for(int i=0; i<n; i++){
        cin >>a[i];
        all^=a[i];
    }
    for(int i=0; i<n; i++){
        a[i] &= (~all);
    }
    
        
    ll ans = all+2*maxor(n);;
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4404
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void solve(){
	string n;
	int k;
	cin >> n >> k;
	int len = n.length();
	int dp[len+1][5];
	memset(dp,0LL,sizeof(dp));
	int cur = 0;
	for(int i =1;i<=len;i++){
		for(int j = 0;j<n[i-1]-'0';j++)
			dp[i][min(cur+(j!=0),4)]+=1;
 
		for(int j =0;j<=k;j++)
		{
			dp[i][j]+=dp[i-1][j];
			dp[i][j+1] +=dp[i-1][j]*9;
		}
		cur+=(n[i-1]!='0');
	}
	if(cur==k)
		dp[len][k]++;
	cout << dp[len][k] << endl;
}
 
int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
 
	// int t;cin >> t;while(t--)
		solve();
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int x;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>x;
	cout<<1-x<<endl;
	return 0;
}


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

int main(){
    int dp[110][10010] = {0};
    int v[110], w[110];
    int N, W;

    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> v[i] >> w[i];

    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(w[i] > j){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7404
n,k,q = map(int, input().split())
a = list(map(int, input().split()))

ans=10**15
for i in range(n):
    x=a[i]
    y_cand=[]
    lis=[]

    for j in range(n):
        if a[j] < x:
            if len(lis)-k+1 >= 0:
                lis.sort()
                y_cand.extend(lis[:len(lis)-k+1])
            lis=[]
        else:
            lis.append(a[j])

    if len(lis)-k+1 >= 0:
        lis.sort()
        y_cand.extend(lis[:len(lis)-k+1])

    if len(y_cand) >= q:
        y_cand.sort()
        y = y_cand[q-1]
        ans = min(ans,abs(x-y))

print(ans)

Measured memory_bytes: 47452
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int n,s[101],t=0;
	cin>>n;
	int h=110;
	for(int i=0;i<n;++i){
		cin>>s[i];
		t+=s[i];
		if(s[i]%10>0){
			h=min(h,s[i]);
		}
	}
	if(t%10!=0)cout<<t<<endl;
	else if(h!=110)cout<<t-h<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int n; cin >> n;
  set<string> s;
  rep(k,n) {
    string S,T; cin >> S >> T;
    if (S == "insert") s.insert(T);
    else if (s.count(T)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int h = 0, sk = 0, tk = 0;
  while(h < n) h += a, sk += b;
  h = 0;
  while(h < n) h += c, tk += d;
  cout << min(sk, tk) << endl;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int n=s.size();
    int ans=0;
    rep(i,n/2) {
        if (s[i]!=s[n-1-i]) ++ans;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3652
N = int(input())
li = list("".join(sorted(input())) for _ in range(N))
dic = {}
ans = 0
for i in range(N):
  if li[i] in dic:
    ans += dic[li[i]]
    dic[li[i]] += 1
  else:
    dic[li[i]] = 1
print(ans)

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

int main() {
  int n;
  int car_num;
  int car_max;
  bool has_error = false;
  cin >> n;
  cin >> car_num;
  car_max = car_num;

  for( int i = 0; i < n; i++ ) {
    int in_num, out_num;
    cin >> in_num >> out_num;
    car_num = car_num + in_num - out_num;
    car_max = max( car_num, car_max );
    if( car_num < 0 ) {
      has_error = true;
    }
  }

  cout << ( has_error ? 0 : car_max ) << endl;

  return EXIT_SUCCESS;
}

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

int main() {
  int n;
  cin >> n;
  
  string a;
  int b,c;
  vector<tuple<string, int, int>> t(n);
  for(int i=0;i<n;i++){
    c=i+1;
    cin >> a >> b;
    b*=-1;
    t.at(i)=make_tuple(a,b,c);
  }
  
  sort(t.begin(),t.end());
  
  for(int j=0;j<n;j++){
    tie(a,b,c)=t.at(j);
    cout << c << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int i, j, H, W;
    
    while (1) {
        scanf("%d %d", &H, &W);
        
        if ( H == 0 && W == 0)
            break;
            
        for ( j=0; j<W; ++j)
            putchar('#');
        putchar('\n');
        
        for ( i=0; i<H-2; ++i) {
            putchar('#');
            for ( j=0; j<W-2; ++j)
                putchar('.');
            putchar('#');
            putchar('\n');
        }
        
        for ( j=0; j<W; ++j)
            putchar('#');
        putchar('\n');
        
        putchar('\n');
    }
    
    return 0;
}


Measured memory_bytes: 2048
h,w,d,f;main(i){for(;scanf(f="%d %d\n",&h,&w)*h;printf(f,h,w)){for(d=i=h*h+w*w;;d++)for(h=d!=i?:h+1;h<(w=sqrt(d-h*h));h++)if(w*w==d-h*h)goto c;c:;}}

Measured memory_bytes: 600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr int MOD = 1000000007;

int main() {

    int H, W, K;
    cin >> H >> W >> K;
    K--;

    vector<vector<int>> dp(H + 1, vector<int>(W, 0));
    dp[0][0] = 1;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for (int k = 0; k < (1 << (W - 1)); k++) {
                bool good = true;
                for (int l = 0; l < W - 1; l++)if ((k >> l) % 4 == 3) good = false;
                if (!good) continue;

                for (int l = -1; l <= 1; l++) {
                    if (l == 0) {
                        bool b = true;
                        if (j > 0) if (k & (1 << (W - j - 1))) b = false;
                        if (j < W - 1) if (k & (1 << (W - j - 2))) b = false;
                        if (b) {
                            dp[i + 1][j] += dp[i][j];
                            dp[i + 1][j] %= MOD;
                        }
                    } else {
                        int to = j + l;
                        if (to >= 0 && to < W) {
                            int d = (l == -1) ? to : j;
                            if (k & (1 << ((W - 2) - d))) {
                                dp[i + 1][to] += dp[i][j];
                                dp[i + 1][to] %= MOD;
                            }
                        }
                    }
                }
            }
        }
    }

    cout << dp[H][K] << endl;

}














































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

int main() {
  int m, f, b, ans;

  cin >> m >> f >> b;
  ans = m - b;
  if (ans >= 0) cout << "0" << endl;
  else if (ans < 0 && f + ans >= 0) cout << ans * -1 << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 3092