akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

inline long long mul(long long a, long long b, long long m) {
    a = mod(a, m); b = mod(b, m);
    if (b == 0) return 0;
    long long res = mul(mod(a + a, m), b>>1, m);
    if (b & 1) res = mod(res + a, m);
    return res;
}

long long pow(long long a, long long n, long long m) {
    if (n == 0) return 1 % m;
    long long t = pow(a, n/2, m);
    t = mul(t, t, m);
    if (n & 1) t = mul(t, a, m);
    return t;
}

vector<pair<long long, long long> > prime_factor(long long n) {
    vector<pair<long long, long long> > res;
    for (long long i = 2; i*i <= n; ++i) {
        if (n % i == 0) {
            int exp = 0;
            while (n % i == 0) {
                ++exp;
                n /= i;
            }
            res.push_back(make_pair(i, exp));
        }
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

const long long L = 50;
long long solve(long long A, long long M) {
    if (A == 0) return M;
    if (A == 1) return 1;
    if (M == 1) return L;
    long long phiM = M;
    vector<pair<long long, long long> > divM = prime_factor(M);
    for (int i = 0; i < divM.size(); ++i) {
        long long p = divM[i].first;
        phiM *= p - 1;
        phiM /= p;
    }
    long long y = solve(A, phiM);
    long long lcm = LCM(phiM, M);
    long long res = pow(A, y, lcm);
    while (res < L) res += lcm;
    return res;
}
int main() {
    int Q;
    while (cin >> Q) {
        for (int i = 0; i < Q; ++i) {
            long long a, m; cin >> a >> m;
            long long res = solve(a, m);
            cout << res << endl;
        }
    }
}

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

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

    int n;
    cin>>n;

    vector<long long> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

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

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

    sort(a.begin(),a.end());
    sort(c.begin(),c.end());

    long long ans=0;
    for(int i=0;i<n;i++){
        long long ans1=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        long long ans2=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        ans+=ans1*ans2;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 5552
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k;
ll n,m;
ll c;
ll ans=1;
ll a[300005];

int main(){
	cin>>n>>c>>k;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	ll num;
	i=0;
	while(true){
		num=a[i];
		for(j=i;j<n;j++){
			if(a[j]-num<=k && j-i+1<=c){
				continue;
			}else{
				ans++;
				break;
			}
		}
		if(j>=n-1)break;
		i=j;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6016
/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

using namespace std;

const int maxx=10005;
int n,m,k;
int a[maxx];
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;

int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    scanf("%d%d",&n,&m);
    n %= 500;
    if(n <= m) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (a, b) = readLine()!!.split(" ").map(String::toInt)

    println(method139B(a, b))
}

fun method139B(a: Int, b: Int): Any? {

    val zouka = a - 1

//    return (b - 1 ) / zouka の斬り上げ計算
    return ((b - 1) + zouka - 1) / zouka

//    var unused = 1
//    var count = 0
//    while (true) {
//        if (unused > b) {
//            break
//        }
//
//        count++
//        unused += a - 1
//    }
//
//    return count
}


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

using namespace std;

int main()
{
  int A,B,C,D;
  cin>> A>> B>> C>> D;

  string ret="Balanced";
  if(A+B>C+D)ret="Left";
  else if(A+B<C+D)ret="Right";
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long LL;
int main()
{
	int n, x, t, ans;
	scanf("%d%d%d", &n, &x, &t);
	ans = t * (n / x);
	if(n % x)	ans += t;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#define N 100
using namespace std;
main () {
	long long n, m, l, a[N][N], b[N][N], c[N][N] = {};
	cin >> n >> m >> l;
	for (int i=0; i<n; i++)
		for (int j=0; j<m; j++) cin >> a[i][j];
	for (int i=0; i<m; i++)
		for (int j=0; j<l; j++) cin >> b[i][j];
	
	for (int i=0; i<n; i++)
		for (int j=0; j<l; j++)
			for (int k=0; k<m; k++)
				c[i][j] += a[i][k] * b[k][j];

	for (int i=0; i<n; i++) {
		cout << c[i][0];
		for (int j=1; j<l; j++) cout << " " << c[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 3316
_ = input()
a = list(map(int,input().split()))
mean = sum(a) / len(a)
mean_ = int(mean + 0.5)
mean = int(mean - 0.5)

coust_ = sum([(mean_ - i)** 2 for i in a])
coust = sum([(mean - i) ** 2 for i in a])

print(coust_ if coust_ < coust else coust)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

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

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;

	rep(i, S.size()) {
		if (S[i] != T[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

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

using namespace std;

void solve(){
    int a,b; cin >> a >> b;
    bool vert[a+1][b+1];
    bool horiz[a+1][b+1];
    for(int i=0;i<=a;i++){
        for(int j= 0;j<=b;j++){
            vert[i][j] = true;
            horiz[i][j] = true;
            if(i==0){
                horiz[i][j] = false;
            }
            if(j==0){
                vert[i][j] = false;
            }
        }
    }
    int matatabi; cin >> matatabi;
    for(int i=0;i<matatabi;i++){
        int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
        if(x1 == x2){
            vert[x1][max(y1,y2)] = false;
        }
        else{
            horiz[max(x1,x2)][y2] = false;
        }
    }
    int ans[a+1][b+1];
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            if(i==0 && j==0)
                ans[i][j]=1;
            else if(vert[i][j]==false && horiz[i][j] == false)
                ans[i][j] = 0;
            else if(vert[i][j]==false && horiz[i][j] == true)
                ans[i][j] = ans[i-1][j];
            else if(vert[i][j]==true && horiz[i][j]==false)
                ans[i][j] = ans[i][j-1];
            else
                ans[i][j] = ans[i][j-1] + ans[i-1][j];
        }
    }
    if(ans[a][b]!=0){
        cout << ans[a][b] << endl;
    }
    else{
        cout << "Miserable Hokusai!" << endl;
    }
}



int main(){
    int n; cin >> n;
    for(int i=0;i<n;i++){
        solve();
    }
}

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

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

int main() {
  string S;
  cin >> S;
  string ans;
  if (S == "AAA" || S == "BBB")
    ans = "No";
  else
    ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int K, S, A, B, C;
  cin >> K >> S;
  int sum = 0;
  for(int i = 0; i < K+1; i++){
    for(int j = 0; j < K+1; j++){
      if(K >= S - i - j && S - i - j >= 0){
        sum++;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;
 
int main() {
    ll h,w; cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    ll sum = h*w;
    cout << (sum + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);
    auto w = readln.split.to!(int[]);

    auto s = w.sum();
    int ans = s;
    int t;
    foreach (i ; 0 .. n) {
        t += w[i];
        ans = min(ans, abs(s - 2*t));
    }
    writeln(ans);
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main() {
    long long sum = 0;
    string line;
    while (getline(cin, line)) {
        line.erase(0, line.find_first_of("0123456789"));
        while (line.empty() == false) {
            istringstream ss(line);
            int i;
            ss >> i;
            sum += i;
            line.erase(0, line.find_first_not_of("0123456789"));
            line.erase(0, line.find_first_of("0123456789"));
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 0
#include<iostream>
#define ll long long
using namespace std;

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


Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int K = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());

		if(500 * K >= X) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

// 二項係数
ll MOD = 1000000007;

const ll MAX = 1100000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

    ll n, k;
    cin >> n >> k;

    //COMinit();

    ll ans = 0;

    vector<ll> v(n + 1);
    for(int i = 0; i <= n; i++) v[i] = i;

    ll mini = 0;
    ll maxi = 0;
    for(int i = 0; i < k - 1; i++){
        mini += i;
        maxi += (n - i);
    }

        if(DEBUG){
            cout << "plus:" << maxi << endl;
            cout << "plus:" << mini << endl;
            cout <<  endl;
        }


    for(ll i = k; i <= n + 1; i++){
        mini += i - 1;
        maxi += (n - i + 1);
        ll plus = maxi - mini + 1;
        if(DEBUG){
            cout << "i = :" << i << endl;
            cout << "plus:" << maxi << endl;
            cout << "plus:" << mini << endl;
            cout << "plus:" << plus << endl;
            cout <<  endl;
        }
        
        ans += plus;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
  long long L, R; cin >> L >> R;
  long long minNum = 2019;

  for(int i = L; i <= R; i++) {
    if(i % 2019 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  for(long long i = L; i <= R; i++) {
    for(long long j = i+1; j <=R; j++) {
      minNum = min(minNum, ((i * j) % 2019));
    }
  }
  cout << minNum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;
 
// 辺（方向と重み）
struct edge{ ll to, cost; };
 
// 幅優先探索
void bfs(vector<vector<edge>> &g, ll n, ll node, vi &color, vi &dst, bool &ans, ll cost){
    // 1度訪問済みでコスト計算が済んでいる部分
    if(color[node] == 1){
        // 矛盾があればフラグを建てる
        if(dst[node] != cost) ans = false;
    }
    else{
        // 未訪問なら訪問済みにし、全ての辺を探索
        color[node] = 1;
        dst[node] = cost;
        rep(i, g[node].size()){
            bfs(g, n, g[node][i].to, color, dst, ans, cost + g[node][i].cost);
        }
    }
}
 
int main(){
    Init();
    ll n, m; cin >> n >> m;
    vector<vector<edge>> g(n, vector<edge>(0));
 
    // グラフの生成
    rep(i, m){
        ll l, r, d; cin >> l >> r >> d;
        l--; r--; // 0-based
        // 双方向に辺を張る（逆向きはコストもマイナスにする）
        g[l].push_back((edge){r, d});
        g[r].push_back((edge){l, -d});
    }
 
    // 回答出力用
    bool ans = true;
 
    // グラフ巡回確認
    vi color(n, 0);
    vi dst(n, -INFLL);
 
    // 矛盾がないか確認
    rep(i, n){
        if(color[i] == 0) bfs(g, n, i, color, dst, ans, 0LL);
    }
 
    // 結果出力
    (ans) ? Yes() : No();
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] p = new int[N];
		int a = 0;
		for(int i=0; i<N; i++) {
			p[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(p);
		for(int i=0; i<K; i++) {
			a += p[i];
		}
		System.out.println(a);
	}

}

Measured memory_bytes: 38708
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,cnt,x,i;
	scanf("%d",&n);
	cnt=0;
	for (i=1;i<=n;i++) {
		scanf("%d",&x);
		if (x%2==0) cnt++;
	}
	if (cnt==n) printf("second\n");
	else printf("first\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	
	ios::sync_with_stdio(0);
	int n,a[100005];
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int ans=0,sum=0;
	for(int i=1;i<n;i++){
		if(a[i+1]<=a[i])ans++;
		else{
			if(ans>sum)sum=ans;
			ans=0;
		}
	}
	if(ans>sum)sum=ans;
	cout<<sum<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp fixed << setprecision
#define pb(x) push_back(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, M;
    cin >> N >> M;
    int A[N], sum = 0;
    rep(i, N) cin >> A[i], sum += A[i];
    sort(A, A+N, greater<int>());
    if(A[M-1]*4*M >= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int M=1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  vector<int> cnt(M);
  for(int i=0;i<n;i++){
    if(cnt.at(a.at(i))!=0){
      cnt.at(a.at(i))=2;
      continue;
    }
    for(int j=a.at(i);j<M;j+=a.at(i)){
      cnt.at(j)++;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(cnt.at(a.at(i))==1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long R) {
  if(N>10) N = 10;
  cout << R + 100*(10-N) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long R;
  std::cin >> R;
  solve(N, R);
  return 0;
}


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

int main(){
int k,s,count=0;
cin >> k >> s;

for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
        if((i+j<=s)&&(s-i-j<=k))count++;
    }
}
cout<<count<<endl;

return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    cout << std::min(A * N, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int n;
  cin >> n;
  int a = n%10;
  if(a==3) cout << "bon" << endl;
  else if(a==0||a==1||a==6||a==8) cout << "pon" << endl;
  else cout << "hon" << endl;

  return 0;
}

Measured memory_bytes: 3636
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
//(order) Set.order_of_key(); (pointer) Set.find_by_order();

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff




int main()
{
    long long i,j,k,l,tst=0,ans=0, csno=0;
    cin>>k;
    cout<<precision(10)<<2*k*PI<<endl;

    return 0;
}


Measured memory_bytes: 3784
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	vector<vector<int> > a(3);
	REP(i,3){
		REP(j,3){
			int in;
			cin>>in;
			a[i].push_back(in);
		}
	}
	int n; cin>>n;
	vector<int> b(n);
	REP(i,n) cin>>b[i];
	REP(i,n){
		REP(j,3){
			REP(k,3){
				if(b[i]==a[j][k]) a[j][k]=0;
			}
		}
	}
	bool flag = false;
	REP(i,3) if(a[i][0]+a[i][1]+a[i][2]==0) flag = true;
	REP(i,3) if(a[0][i]+a[1][i]+a[2][i]==0) flag = true;
	if(a[0][0]+a[1][1]+a[2][2]==0) flag = true;
	if(a[0][2]+a[1][1]+a[2][0]==0) flag = true;
	if(flag) cout<<yes<<endl;
	else cout<<no<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<vector<int> > a(n,vector<int>(m));
    vector<int> b(m);
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            cin >> a[i][j];
    for(int i = 0 ; i < m ; i++)
        cin >> b[i];

    vector<int> c(n);
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            c[i] += a[i][j] * b[j];

    for(int i = 0 ; i < n ; i++)
        cout << c[i] << endl;
  
    return 0;
}


Measured memory_bytes: 3200
def examA():
    S, T = LSI()
    A, B = LI()
    U = SI()
    if S==U:
        print(A-1,B)
    else:
        print(A,B-1)
    return

def examB():
    S = SI()
    N = len(S)
    ans = ""
    for i in range(N):
        ans += "x"
    print(ans)
    return

def examC():
    N = I()
    A = LI()
    d = defaultdict(int)
    for a in A:
        d[a] += 1
        if d[a]>=2:
            print("NO")
            return
    print("YES")
    return

def examD():
    N, K = LI()
    P = LI()
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    ans = 0
    for i in range(N-K+1):
        cur = S[i+K]-S[i]
        ans = max(ans,cur)
    print(ans)
    return

def examE():
    def ketadp(a,K):
        n = len(a)
        C = [i for i in range(K+1)]
        dp = defaultdict(int)
        dp[0, 0, 0] = 1
        for i, less, k in itertools.product(range(n), (0, 1), C):
            max_d = 9 if less else int(a[i])
            for d in range(max_d + 1):
                less_ = less or d < max_d
                if d==0:
                    dp[i + 1, less_, k] += dp[i, less, k]
                elif k<K:
                    dp[i + 1, less_, k+1] += dp[i, less, k]

        ans = sum(dp[n, less, K] for less in (0, 1))
        return ans
    N = SI()
    K = I()
    ans = ketadp(N,K)
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examE()

"""

"""

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  vector<vector<pii>>e(N);
  for(int i=0;i<N-1;i++){
    int u,v,w;
    cin>>u>>v>>w;
    u--,v--;
    e[u].push_back({v,w});
    e[v].push_back({u,w});
  }
  queue<pii>q;
  q.push({0,0});
  vector<bool>used(N,false);
  used[0]=true;
  vector<int>ans(N);
  while(q.size()){
    int now=q.front().first;
    int d=q.front().second;
    ans[now]=d;
    q.pop();
    for(auto it:e[now]){
      if(used[it.first])continue;
      used[it.first]=true;
      q.push({it.first,(d+it.second)%2});
    }
  }
  for(auto it:ans)cout<<it<<endl;
  return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)



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

	

	int sum = 0;
	rep(i, N) {
		if (S[i] == S[i + 1]) {
			continue;
		}
		else {
			sum++;
		}
	}

	cout << sum<< endl;
return 0;
} 

Measured memory_bytes: 512
n = gets
w = n.split[0].to_i
h = n.split[1].to_i
x = n.split[2].to_i
y = n.split[3].to_i
r = n.split[4].to_i

unless x>0 && y>0
	puts "No"
	else
		if(x-r >= 0 && y-r >= 0 && x+r <= w && y+r <= h) 
			puts "Yes"
		else
			puts "No"
	end
end

Measured memory_bytes: 6100
fun main(args: Array<String>) {
    val abc = (1..3).map { readLine()!!.map { it - 'a' } }
    val cnt = Array(3) { 0 }
    var turn = 0
    while (abc[turn].getOrNull(cnt[turn]) != null) {
        val nextTurn = abc[turn][cnt[turn]]
        cnt[turn]++
        turn = nextTurn
    }
    println('A' + turn)
}


Measured memory_bytes: 35472
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        char s[] = sc.next().toCharArray();
        sc.close();
        int e[] = new int[n];
        int w[] = new int[n + 1];
        w[0] = 0;
        if (s[0] == 'E') {
            e[0] = 1;
            w[1] = 0;
        } else {
            e[0] = 0;
            w[1] = 1;
        }
        for (int i = 1; i < n; i++) {
            if (s[i] == 'E') {
                e[i] = e[i - 1] + 1;
                w[i + 1] = w[i];
            } else {
                e[i] = e[i - 1];
                w[i + 1] = w[i] + 1;
            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            if (min > e[n - 1] - e[i] + w[i])
                min = e[n - 1] - e[i] + w[i];
        }
        System.out.println(min);
    }
}

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

int main()
{
	string S;
	ll K;
	cin >> S >> K;
	//cout << S2 << endl;
	bool check = false; //先端と終端が同じ文字か
	if (S[0] == S[S.size()-1]) check = true;

	ll ans = 0;

	ll l = 0, m = 0, r = 0;
	ll cnt = 1;
	ll idx = 0;
	for (int i = 0; i < S.size()-1; ++i)
	{
		if (S[i] == S[i+1])
		{
			cnt++;
		}
		else if(cnt > 1)
		{
			//cout << cnt << endl;
			l += cnt/2;
			cnt = 1;
		}
	}

	//cout << "loop end  cnt1 = " << cnt << endl;

	ll cnt1 = cnt;

	if (K == 1)
	{
		l += cnt/2;
		cout << l << endl;
		return 0;
	}
		
	if (check)
	{
		cnt++;
		while(S[idx] == S[idx+1] && idx < S.size()-1)
		{
			cnt++;
			idx++;
		}
	}

	ll cnt2 = cnt;
	//cout << "cnt2 = " << cnt2 << endl;

	if (cnt1 == S.size() && cnt2 == S.size()*2)
	{
		cout << (ll)S.size() * K / 2 << endl;
		return 0;
	}

	ll base = l - (cnt2 - cnt1) / 2;

	l = base + cnt2 / 2 + (cnt2 - cnt1) / 2;
	m = base + cnt2 / 2;
	r = base + cnt1 / 2;

	//cout << base << " " << l << " " << m << " " << r << endl;

	ans = l + r + m * (K-2);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,A[200000],a=0,ans=1;
    cin>>n;
    rep(i,n) cin>>A[i];
    sort(A,A+n);
    rep(i,n-1){
        a+=A[i];
        if(2*a>=A[i+1]) ans++;
        else ans=1;
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (b%a == 0)cout << a + b << endl;
	else cout << b - a << endl;
}

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



int main()
{
    int N, T;
    cin >> N >> T;
    T--;
    vector<pair<int, int>> timeValues(0);
    for(int i = 0; i < N; i++)
    {
        int A, B;
        cin >> A >> B;
        timeValues.emplace_back(A, B);
    }
    sort(timeValues.begin(), timeValues.end());
    vector<vector<ll>> dp(N + 1, vector<ll>(T + 1, 0));
    for(int i = 0; i < N; i++){
        pair<int, int>timeValue = timeValues.at(i);
        int time = timeValue.first;
        int value = timeValue.second;
        for(int j = 0; j <= T; j++){
            if(time > j){
                dp.at(i + 1).at(j) = dp.at(i).at(j);
            } else {
                dp.at(i + 1).at(j) = max(dp.at(i).at(j), dp.at(i).at(j - time) + value);
            }
        }
    }
    ll answer = 0;
    int maxValue = 0;
    for(int i = N - 1; i >= 0; i--){
        maxValue = max(maxValue, timeValues.at(i).second);
        answer = max(answer, dp.at(i).at(T) + maxValue);
    }
    cout << answer << endl;
    return 0;
}



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

using namespace std;

int main(){
	int n; cin >> n;
	int ans=1, tmp_max=0;
	cin >> tmp_max;
	for(int i=1; i<n; i++){
		int h; cin >> h;
		if(tmp_max <= h){
			ans++;
			tmp_max = h;
		}
	}

	cout << ans << endl;

	return 0;
}

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

#define MAX_LEN_S (10)

int main(int argc, char *argv[]) {
  long S[MAX_LEN_S], len = 0;
  for (char c = fgetc(stdin); c >= '0' && c <= '9'; c = fgetc(stdin))
    S[len++] = c - '0';
  long sum = 0;
  for (long i = 0, i_end = 1 << (len - 1); i < i_end; i++) {
    long sum_part = 0, place = 1;
    for (long j = len - 1; j >= 0; j--) {
      sum_part += S[j] * place;
      if (j >= 0 && (i >> (j - 1)) & 1)
        place = 1;
      else
        place *= 10;
    }
    sum += sum_part;
    // printf("i = %#08lx, sum_part = %ld\n", i, sum_part);
  }
  printf("%ld\n", sum);
  
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String c[] = new String [5];
    int count = 0;
    int n = b - a; 
    for(int i = 0;i <= n;i++){
      String s = String.valueOf(a);
      c = s.split("");
      if(c[0].equals(c[4]) && c[1].equals(c[3])){
        count++;
      }
      a++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 62204
#include<iostream>
#include<string>
#include<map>
#include<string.h>
#include<vector>
#include<set>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<cstdio>
using namespace std;
#define pb push_back
typedef long long ll;
typedef long double ld;
int mp[100001];
int main()
{
	int n,k;cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>mp[i];
	}
	int ans=(n-1+k-2)/(k-1);
	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
int main() {
  string s;
  cin>>s;
  ll n=s.size(),count0=0,count1=0;
  loop(i,n){
    if(s[i]=='0')count0++;
    else count1++;
  }
  putout(n-abs(count1-count0));
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        for (int i = 0; i < max; i++) System.out.print(min);
        System.out.println();
    }
}

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

int main(){
    int height, width;
    cin >> height >> width;

    while(height!=0 || width!=0){
        for(int i=1; i<=height; i++){
            for(int j=1; j<=width; j++){
                cout << "#";
                }
                cout << endl;
            }
        cout << endl;
        cin >> height >> width;
    }

    return 0;
}


Measured memory_bytes: 3108
import Data.List as List

main :: IO ()
main = do
  n <- readLn :: IO Int
  ss <- sequence $ replicate n getLine
  putStrLn $ solve ss

solve :: [String] -> String
solve ss =
  List.sort $ foldl1 getDuplicate ss
  where
    getDuplicate xs ys =
      let
        xs' = List.sort xs
        ys' = List.sort ys
        f [] _ = []
        f _ [] = []
        f (x:xs) (y:ys) =
          if x == y
          then
            x : f xs ys
          else
            if x < y then
              f xs (y:ys)
            else
              f (x:xs) ys
      in
        f xs' ys'


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

long long combination(int n, int k) {
    if (k < 0 || n < k) return 0;
    long long res = 1;
    for (long long i = 1; i <= k; ++i) {
        res *= n--;
        res /= i;
    }
    return res;
}

int main() {
    int N, P;
    cin >> N >> P;
    int A, cntOdd = 0, cntEven = 0;
    rep (i, N) cin >> A, A % 2 ? cntOdd++ : cntEven++;

    long long ans = 0;
    for (int i = P; i <= cntOdd; i+= 2) ans += combination(cntOdd, i);
    cout << ans * (1LL << cntEven) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        if(k >= n) {
        	System.out.println(0);
          	return;
        }
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
        	arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        long sum = 0;
      	for(int i = 0; i < (n - k); i++)
          sum += arr[i];
        System.out.println(sum);
    }
}

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

int main(){
	string s;
	cin >> s;
	int n = s.size()+1;
	vector<int> v(n,-1);
	if(s[0] == '<') v[0] = 0;
	if(s[n-2] == '>') v[n-1] = 0;
	ll ans(0);
	int cnt(0);
	rep(i,n-2){
		if(s[i] == '>' && s[i+1] == '<'){
			v[i+1] = 0;
		}
	}
	for(int i(1);i<n;++i){
		if(v[i] != 0 && s[i-1] == '<'){
			cnt++;
			v[i] = max(v[i],cnt);
		}else{
			cnt = 0;
		}
	}
	cnt = 0;
	for(int i(n-2);i>=0;--i){
		if(v[i] != 0 && s[i] == '>'){
			cnt++;
			v[i] = max(v[i],cnt);
		}else{
			cnt = 0;
		}
	}
	rep(i,n)ans += v[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2820
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>s;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		sum = sum + a;
		s.push_back(a);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] * 4 * m >= sum) {
			ans++;
		}
	}
	if (ans >= m) {
		cout << "Yes";
	}
	else {
		cout <<"No";
	}
}

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

int main(void) {
  long long n;
  vector<long long> as(5);
  cin >> n;
  long long bottleneck = 2 * 1'000'000'000'000'000;

  for (long long &a : as) {
    cin >> a;
    bottleneck = min(bottleneck, a);
  }

  long long num = n / bottleneck + (n % bottleneck == 0 ? 0 : 1);
  long long result = num + 4;

  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>

using namespace std;

int main()
{
    int  i,a,c,d,n;
    scanf("%d%d",&d,&n);
    for(i=0,a=1;i<d;i++)
        a=a*100;
    //a=pow(100,d);
    c=n*a;
    if(n==100)
        c+=a;
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
#1_2_D 2015.3.6
w,h,x,y,r = map(int,input().split())
if x - r < 0:
    print('No')
elif y - r < 0:
    print('No')
elif x + r > w:
    print('No')
elif y + r > h:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 6728
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct S {
    int x, cost;
}

void main() {
    int N; scanf("%d\n", &N);
    int[] P = new int[N];
    foreach (i; 0 .. N) {
        scanf("%d\n", &P[i]);
    }

    auto used = new bool[N];
    auto next = new int[N]; next[] = -1; next[0] = 0;
    foreach (i; 0 .. N) {
        if (used[i]) continue;
        int[] stack;
        int k = i;
        while (true) {
            stack ~= k;
            if (P[k] == 0) {
                foreach (e; stack) next[e] = k;
                break;
            } else if (used[k]) {
                foreach (e; stack) next[e] = next[k];
                break;
            }
            used[k] = true;
            k = max(0, min(N, k + P[k]));
        }
    }

    DList!S Q;
    Q.insert(S(0, 0));
    used[] = false;
    used[0] = true;
    while (!Q.empty) {
        S c = Q.front; Q.removeFront;
        //writeln(c);
        if (c.x == N - 1) {
            writeln(c.cost);
            return;
        }
        for (int k = 1; k <= 6; k++) {
            int n = max(0, min(N - 1, c.x + k));
            int m = next[n];
            if (m < 0) continue;
            if (used[m]) continue;
            used[m] = true;
            Q.insert(S(m, c.cost + 1));
        }
    }
    assert(0);
}

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

int main() {
	
	int N,count,result;
	cin >>N;
	result=0;
	
	
	vector<int> hights(N);
	
	for(int i=0; i<N; i++){
		
		cin >> hights.at(i);
		
	}
	
	
	vector<int> diff(N-1);
	
	for(int i=0; i<N-1; i++){
		
		diff.at(i)=hights.at(i)-hights.at(i+1);
		
	}
	
	
	count=0;
	
	for(int i=0; i<N-1; i++){
		
		if(diff.at(i)>-1){
			
			count++;
			
		}
		if(diff.at(i)<0){
			
			if(count>result){
				
				result=count;
				
			}
			count=0;
			
		}
		
	}
	if(count>result){
				
				result=count;
				
			}
	
	cout << result<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,-1,-1,0,0,1,1,1 }, ty[8] = { -1,0,1,-1,1,-1,0,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

struct Fact_combination {
private:
	vector<ll>FACT;
	vector<ll>IFACT;
	ll N;
public:
	ll extgcd(ll a, ll b, ll &x, ll &y) {
		ll g = a;
		x = 1;
		y = 0;
		if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
		return g;
	}
	ll invMod(ll a, ll m) {
		ll x, y;
		if (extgcd(a, m, x, y) == 1) return (x + m) % m;
		else                         return 0;
	}
	ll mod_pow(ll x, ll n) {
		ll res = 1;
		while (n > 0) {
			if (n & 1) res = res * x%MOD;
			x = x * x%MOD;
			n >>= 1;
		}
		return res;
	}
	void inverse(ll n) {
		N = n;
		FACT.resize(N + 1);
		IFACT.resize(N + 1);
		FACT[0] = 1;
		IFACT[0] = 1;
		for (int i = 1;i <= N;i++) {
			FACT[i] = FACT[i - 1] * i % MOD;
			IFACT[i] = invMod(FACT[i], MOD);
		}
	}
	ll combi(ll n, ll r) {
		if (n < 0 || r < 0 || r > n)return 0;
		if (r > n / 2)r = n - r;
		return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD;
	}
};

ll h, w, a, b, ans;

int main() {
	cin >> h >> w >> a >> b;
	Fact_combination fa;
	fa.inverse(h + w + 1);
	for (int i = 0;i < h - a;i++) {
		ans += fa.combi(i + b - 1, i)*fa.combi(h - i + w - b - 2, h - i - 1);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    vector<vector<string>> dp(10);
    vector<ll> lunlun;
    for (int i = 0; i <= 9; i++)dp[i].push_back(to_string(i)), lunlun.push_back(i);

    for (int i = 1; i <= 11; i++) {
        vector<vector<string>> v(10);
        for (int prev = 0; prev <= 9; prev++) {
            for (int now = 0; now <= 9; now++) {
                if (abs(prev - now) <= 1) {
                    for (auto x:dp[prev]) v[now].push_back(x + to_string(now));
                }
            }
        }

        for (int j = 0; j <= 9; j++) {
            for (auto x:v[j]) {
                if (x[0] != '0') lunlun.push_back(stoll(x));
            }
        }
        dp = v;
    }
    sort(lunlun.begin(), lunlun.end());

    int k;
    cin >> k;
    cout << lunlun[k] << endl;
    return 0;
}

Measured memory_bytes: 105188