akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N, a, d, M; cin >> N >> a >> d >> M;
  int x[M], y[M], z[M];
  rep(i, M) {
    cin >> x[i] >> y[i] >> z[i];
    y[i]--, z[i]--;
  }

  int K; cin >> K; K --;

  for(int i=M-1; i>=0; i--) {
    if(x[i] == 0) {
      if(y[i] <= K && K <= z[i]) {
        K = z[i] - (K - y[i]);
      }
    }
  }

  int tar = a + K * d;

  for(int i=0; i<M; i++) {
    if(x[i] == 0) {
      if(y[i] <= K && K <= z[i]) {
        K = z[i] - (K - y[i]);
      }
    }
    if(x[i] == 1) {
      if(y[i] <= K && K <= z[i]) {
        tar ++;
      }
    }
    if(x[i] == 2) {
      if(y[i] <= K && K <= z[i]) {
        tar /= 2;
      }
    }
  }

  cout << tar << endl;

  return 0;
}

Measured memory_bytes: 5248
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] x = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++){
			int num = sc.nextInt();
			x[i] = num;
			sum += num;
		}
		double limit = (double) sum / (double)(m * 4);

		int count = 0;
		for(int i = 0; i < n; i++){
			if(x[i] >= limit)count++;
		}
		System.out.println((count >= m)?"Yes":"No");
	}
}

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

int main(){
	int n,m;
	cin>>n>>m;
	if(n<=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int main()
{
    while(1) {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        vector<int> a(n);
        REP(i, n) cin >> a[i];
        int ans = -1;
        REP(i, n) for(int j = i + 1; j < n; ++j) {
            if (a[i] + a[j] > m) continue;
            ans = max(ans, a[i] + a[j]);
        }
        if (ans == -1) {
            cout << "NONE" << endl;
        } else {
        cout << ans << endl;
        }
    }
}



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

#define ll long long 

int main() {
  int N;
  cin >> N;
  
  ll 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, A+N);
  sort(B, B+N);
  sort(C, C+N);
  
  ll ans = 0;
  
  for (int i = 0; i < N; i++) {
    ll x = lower_bound(A, A + N, B[i]) - A;
    ll y = lower_bound(C, C + N, B[i]+1) - C;
    
    ans += x * (N-y);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n;

void dfs(string s, char mc) {
    if(s.size() == n) {
        printf("%s\n", s.c_str());
        return ;
    }
    for(char c = 'a'; c <= mc; c++) {
        dfs(s+c, c==mc?(char)(mc+1):mc);
    }
}

signed main() {

    cin >> n;

    dfs("", 'a');

    return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  rep(i, M) {
    int A;
    cin >> A;
    N -= A;
    if (N < 0) {
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << N << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int A; double B;
    cin >> A >> B;
    B*=100;
    B+=0.05;
    int C=(int)floor(B);
    cout << (A*C)/100 << endl;
}

Measured memory_bytes: 3868
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

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

int main(int argc, char *argv[]) {
	int n, ans = 0;
	cin >> n;
	vector<int> a(n), fwd(n + 1), rev(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		fwd[i + 1] = gcd(fwd[i], a[i]);
	}
	for (int i = n - 1; i >= 0; --i) {
		rev[i] = gcd(rev[i + 1], a[i]);
	}
	for (int i = 0; i < n; ++i) {
		ans = max(ans, gcd(fwd[i], rev[i + 1]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
use strict;
use warnings;

sub main {
    chomp(my $Y = <STDIN>);
    chomp(my $Z = <STDIN>);
    my ($N,$M,$B) = split(/ /,$Y);
    my @X = split(/ /,$Z);
    print solve($N,$M,$B,\@X);
}
main() unless caller;

sub solve {
    my ($N,$M,$B,$X) = @_;
    my $x = int($B/$M)+1;
    my $ans=0;
    for my $i(0..$N-2) {
        my $kyori = $X->[$i+1] - $X->[$i];
        $ans += $kyori >= $x ? $B : $kyori*$M;
    }
    return $ans;
}


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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n;
  cin >> n;
  vector< bitset<64> > mask(n, bitset<64>(0));
  rep(i,n) {
    int k; cin >> k;
    rep(j,k) {
      int b; cin >> b;
      mask[i].set(b);
    }
  }

  int q;
  cin >> q;
  bitset<64> a(0);

  vector<ull> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int x; cin >> x;
      ans.push_back(a[x]);
    } else if (command == 1) {
      int m; cin >> m;
      a |= mask[m];
    } else if (command == 2) {
      int m; cin >> m;
      a &= ~mask[m];
    } else if (command == 3) {
      int m; cin >> m;
      a ^= mask[m];
    } else if (command == 4) {
      int m; cin >> m;
      ans.push_back((a|~mask[m]).all());
    } else if (command == 5) {
      int m; cin >> m;
      ans.push_back((a&mask[m]).any());
    } else if (command == 6) {
      int m; cin >> m;
      ans.push_back((a&mask[m]).none());
    } else if (command == 7) {
      int m; cin >> m;
      ans.push_back((a&mask[m]).count());
    } else if (command == 8) {
      int m; cin >> m;
      ans.push_back((a&mask[m]).to_ullong());
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 4972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

const int MAX_S = 3010, MAX_T = 3010;
int dp[MAX_S][MAX_T] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string s,t; cin >> s >> t;
    //memset(dp,0,sizeof(dp));
    int slen = s.length();
    int tlen = t.length();
    REP(i,slen+1) dp[0][i] = 0;
    REP(i,tlen+1) dp[i][0] = 0;
    FOR(i,1,slen+1){
        FOR(j,1,tlen+1){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    
    string ans = "";
    int ni = slen, nj = tlen;
    while(ni > 0 && nj > 0){
        //if(dp[ni][nj] == dp[ni-1][nj-1] + 1){
        //    ans += s[ni-1];
        //    ni--;
        //    nj--;
        //}else{
        //    if(dp[ni][nj] == dp[ni-1][nj]){
        //        ni--;
        //    }else{
        //        nj--;
        //    }
        //}
        if(dp[ni][nj] == dp[ni-1][nj]){
            ni--;
        }else if(dp[ni][nj] == dp[ni][nj-1]){
            nj--;
        }else if(dp[ni][nj] == dp[ni-1][nj-1]+1){
            ans += s[ni-1];
            ni--; nj--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;


}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> vect(N);
    vector<long long> inp(N);
    for(int i=0; i< N; i++){
        cin >> vect[i];
        inp[i] = vect[i];
    }

    sort(vect.begin(), vect.end());
    int low = vect[N/2 -1 ];
    int high = vect[N/2];
    for(int i=0 ; i< N ; i++){
        if( inp[i] <= low){
            cout << high << endl;
        }else{
            cout << low << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5376
import math

a, b, x = map(int, input().split())
h = (2 * x) / (a ** 2)
A = a
B = 2*b - h

if B < b:
    print(math.degrees(math.atan2(B, A)))
else:
    print(math.degrees(math.atan2(b, (2 * x)/(a * b))))


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

int main() {
  long long h,n;cin>>h>>n;
  vector<int>vec(n);long long sum=0;
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    sum+=vec.at(i);
  }
  if(h>sum)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3704
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int
var Max, Min int = 0, 1e9

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	H := make([]int, N)
	for i := 0; i < N; i++ {
		H[i], _ = strconv.Atoi(read())
	}
	for i := 0; i < N-1; i++ {
		if H[i] >= H[i+1] {
			cnt++
			ans = max(ans, cnt)
		} else {
			cnt = 0
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

vector<ll> divisors(ll n){
    vector<ll> S, T;
    ll MAX = sqrt(n);
    rep(i, 1, MAX + 1) if(n % i == 0){S.push_back(i); T.push_back(n / i);}
    if(S.back() == T.back()) T.pop_back();
    S.insert(S.cend(), T.crbegin(), T.crend());
    return S;
}

void solve(){
    ll n; cin >> n;
    ll res = INF;
    for(auto d : divisors(n)){
        chmin(res, d + n / d - 2);
    }
    cout << res << endl;
}

Measured memory_bytes: 384
require 'prime'
loop do
  m, a, b = gets.split.map(&:to_i)
  break if m == 0
  ans = [0, 0]
  prod = 0
  Prime.each.lazy.take_while{ |p| p <= Math.sqrt(100000).to_i }.each do |p|
    break if p * p > m
    q = Prime.each.lazy.drop_while{ |q| q < p  }
                       .take_while{ |q| a * q <= b * p }
                       .take_while{ |q| p * q <= m }.to_a.last
    if q && prod < p * q
      ans = [p, q]
      prod = p * q
    end
  end
  puts ans * ' '
end

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

using namespace std;

#define N 320000

const int mod=1000000007;
char s[N];
int n,f[N][7];

void upd(int y,int &x){x=(x+y)%mod;}

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	f[0][0]=1;
	for (int i=1;i<=n;++i){
		if (s[i]=='?'||s[i]=='0'){
			upd(f[i-1][0],f[i][1]);
			upd(f[i-1][1],f[i][2]);
			upd(f[i-1][2],f[i][1]);
			upd(f[i-1][3],f[i][4]);
			upd(f[i-1][4],f[i][5]);
			upd(f[i-1][5],f[i][4]);
			upd(f[i-1][6],f[i][6]);
		}
		if (s[i]=='?'||s[i]=='1'){
			upd(f[i-1][0],f[i][3]);
			upd(f[i-1][1],f[i][0]);
			upd(f[i-1][2],f[i][1]);
			upd(f[i-1][3],f[i][6]);
			upd(f[i-1][4],f[i][3]);
			upd(f[i-1][5],f[i][4]);
			upd(f[i-1][6],f[i][6]);
		}
	}
	printf("%d\n",(f[n][3]+f[n][6])%mod);
	
	return 0;
}
			

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

int main() {
    int n, count = 0, max = 0;

    cin >> n;
    int a[n];

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

    for(int i = 0; i < n; i++) {
        if(a[i] >= max) {
            count++;
            max = a[i];
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
 
COLOR = 8
cnt, ov = [0] * COLOR, 0
for r in a:
    if r < 3200:
        cnt[r // 400] = 1
    else:
        ov += 1

used = 0
for c in cnt:
    if c > 0:
        used += 1

print(max(1, used), used + ov)


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

using namespace std;

const int Maxn = 1e2+7;

int n, x, ans;
int a[Maxn];

int main()
{
    scanf("%d%d", &n, &x);
    for(int i = 0; i < n; ++i)
        scanf("%d", a+i);
    sort(a, a+n);
    for(int i = 0; i < n && x >= a[i]; ++i)
    {
        x -= a[i];
        // fit the last one
        if(i != n-1 || x == 0) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
def exteuc(a, b):
    # ax + by = gcd(a, b)
    if b == 0:
        return 1, 0, a
    y, x, v = exteuc(b, a % b)
    y -= (a//b) * x
    return x, y, v


def modinv(a, mod):
    x, _, _ = exteuc(a, mod)
    return x % mod


def main():
    MOD = 10**9 + 7
    N = int(input())
    A = list(map(int, input().split(' ')))
    # calculate duplicate indices
    # Ex. [1, 4, 2, 1, 3] -> 0, 3
    dup_first_index, dup_second_index = -1, -1
    indices = [-1 for _ in range(N)]
    for i, a in enumerate(A):
        if indices[a - 1] != -1:
            dup_first_index, dup_second_index = indices[a - 1], i
            break
        indices[a - 1] = i
    # Ex. [1, 4, 2, 5, 4, 3, 6] -> [1] + [3, 6] -> 3
    s = dup_first_index + N - dup_second_index
    # calculate answer
    ans = [0 for _ in range(N + 1)]
    comb_n1, comb_s = N + 1, 1  # comb(N + 1, 1), comb(s, 0)
    for i in range(N + 1):
        ans[i] = comb_n1  # comb(N + 1, i + 1)
        comb_n1 *= (N + 1) - (i + 1)
        comb_n1 *= modinv(i + 2, MOD)
        comb_n1 %= MOD
        if s >= i:
            ans[i] -= comb_s  # comb(s, i)
            comb_s *= s - i
            comb_s *= modinv(i + 1, MOD)
            comb_s %= MOD
        ans[i] %= MOD
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 16480
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cstring>
#define INF 1e18
using namespace std;
long long int a,b,c,ans=0,k;

int main(){
  cin >> a >> b >> c >> k;
  if(a==b && b==c){cout << 0 << endl;return 0;}
  if(k%2==0)ans=a-b;
  else ans= b-a;
  

  if(abs(ans) > INF)cout << "Unfair" << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int X = Integer.parseInt(W);

		int[] F = new int[100004];
		int[] L = new int[100001];
		int lIndex=0;

		Arrays.fill(F, -1);

		for(int i=2;i<F.length;i=i+2){
			if(i==4){
				i--;
			}
			if(F[i]!=-1){
				continue;
			}

			boolean flg = true;
			for(int k=0;k<lIndex;k++){
				if(i%(L[k]*1.0)==0){
					flg=false;
					break;
				}
			}
			if(flg){
				//素数
				L[lIndex++]=i;
				F[i]=1;
				for(int k=i+i;k<F.length;k=k+i){
					F[k]=0;
				}
			}
		}
		int ans =-1;
		for(int i=X;i<F.length;i++){
			if(F[i]==1){
				ans=i;
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24020
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    s = input()
    t = input()
    ans = 2*n
    for i in range(n)[::-1]:
        su = s[i:]
        pre = t[:n-i]
        if su == pre:
            ans = n+i
    print(ans)
    return

#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int W[N];
  for(int i=0;i<N;i++){
    cin >> W[i];
  }
  int relef,rerig;
  relef=W[0];
  rerig=W[N-1];
  int le=1;
  int ri=N-2;
  for(int i=0;i<N-2;i++){
    if(relef<=rerig){
      relef+=W[le];
      le++;
    }else{
      rerig+=W[ri];
      ri--;
    }
  }
  //cout << relef << "|" << rerig << endl;
  
  if(relef<=rerig){
    cout << rerig-relef << endl;
  }else{
    cout << relef-rerig << endl;
  }
} 

Measured memory_bytes: 256
import sys
import collections
import itertools
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    S = []
    for _ in range(N):
        x = input()
        if x.startswith(("M", "A", "R", "C", "H")):
            S.append(x[0])

    c = collections.Counter(S)
    ans = 0
    for x, y, z in itertools.combinations(["M", "A", "R", "C", "H"], 3):
        ans += c[x] * c[y] * c[z]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4216
#include <iostream>
#include <math.h>
using namespace std;
int main(){
        long n;
        cin >> n;
        long i, t, s;
        t = long(sqrt((double)n))+1;
        for (i=t;i>0;i--){
                if (n%i==0){
                        s= i + (n/i) - 2;
                        break;
                }
        }
        cout << s;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define puba push_back
#define ff first
#define ss second
#define bend(_x) begin(_x), end(_x)
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);

mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }


int calc(vector<int> v) {
    vector<int> best(szof(v) + 1, INF);
    best[0] = -INF;
    
    int ret = 0;
    for (int i = 0; i < szof(v); ++i) {
        int l = 0, r = szof(v) + 1;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (best[mid] < v[i]) {
                l = mid;
            } else {
                r = mid;
            }
        }
        best[l + 1] = v[i];
        ret = max(ret, l + 1);
    }
    return ret;
}

int main() {
    //freopen(TASK_NAME ".in", "r", stdin);
    //freopen(TASK_NAME ".out", "w", stdout);
    cerr << fixed << setprecision(15);
    cout << fixed << setprecision(15);
    
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
                   
    int n;
    scanf("%d", &n);

    vector<pii> points;
    
    for (int i = 0; i < n; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        if (min(x1, x2) <= x && x <= max(x1, x2) && min(y1, y2) <= y && y <= max(y1, y2)) {
            points.puba({x, y});
        }
    }

    sort(bend(points));
    if (x1 > x2) {
        reverse(bend(points));
    }

    if (y1 > y2) {
        for (auto& p : points) {
            p.ss *= -1;
        }
    }

    long double ans = (fabs(x1 - x2) + fabs(y1 - y2)) * 100;

    vector<int> arr;
    for (auto p : points) {
        arr.puba(p.ss);
    }

    sort(bend(arr));
    arr.resize(unique(bend(arr)) - arr.begin());

    vector<int> v;
    for (auto p : points) {
        v.puba(lower_bound(bend(arr), p.ss) - arr.begin());
    }


    int tmp = calc(v);
    if (tmp < min(abs(x2 - x1) + 1, abs(y2 - y1) + 1)) {
        ans = ans - calc(v) * (20 - 2 * PI * 10 / 4);
    } else {
        ans = ans - calc(v) * (20 - 2 * PI * 10 / 4) + 2 * PI * 10 / 4;
    }
    cout << ans << "\n";
    
    #ifdef LOCAL
        cerr << "time: " << clock() << endl;
    #endif
    return 0;
}                              

Measured memory_bytes: 5232
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 6/20/2018
 
 12:45-
 
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
vector<int> A(MAX_N);
void solve() {
  sort(A.begin(),A.end());
  int n=A.back();
  auto it=lower_bound(A.begin(),A.end(),n/2);
  if(*it==n) --it;
  int k1=*it,k2=0;
  if(it!=A.begin()) k2=*(--it);
  int k=abs(k1-n/2)>abs(k2-n/2)?k2:k1;
  cout<<n<<' '<<k<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  return 0;
}


Measured memory_bytes: 640
"use strict"

const { sign } = require("crypto");

const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)

const Main = () => {
    let n = nextInt()
    let a = new Array(n).fill(0)
    for (let x = 1; x * x < n; x++) {
        for (let y = 1; y * y < n; y++) {
            for (let z = 1; z * z < n; z++) {
                const sum = x * x + y * y + z * z + x * y + y * z + z * x;
                if (sum > n) break;
                a[sum - 1]++;
            }
        }
    }
    console.log(a.join(`\n`))
}
Main()



Measured memory_bytes: 34640
package main

import (
	"fmt"
)

func findMax(nums []int) (max int) {
	max = 0
	for i := 0; i < len(nums); i++ {
		if nums[i] > max {
			max = nums[i]
		}
	}
	return
}

func getSum(nums []int) (sum int) {
	sum = 0
	for i := 0; i < len(nums); i++ {
		sum += nums[i]
	}
	return
}

func main() {
	var N int
	fmt.Scan(&N)
	nums := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&nums[i])
	}
	max := findMax(nums)
	sum := getSum(nums)
	if sum-max > max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> que;
    for (int i = 0; i < n; ++i) {
        double v;
        cin >> v;
        que.push(v);
    }
    for (int i = 0; i < n-1; ++i) {
        double x = que.top();
        que.pop();
        double y = que.top();
        que.pop();
        que.push((x + y) / 2.0);
    }
    cout << fixed << setprecision(10) << que.top() << endl;
}

Measured memory_bytes: 3796
N,K=map(int,input().split())
A=list(map(int,input().split()))
m,p=[],[]
for a in A:
    if a<0:
        m.append(a)
    elif a>0:
        p.append(a)
M,P=len(m),len(p)
Z=N-M-P
m.sort()
p.sort()
if M*P<K<=N*(N-1)//2-M*(M-1)//2-P*(P-1)//2:
    print(0)
elif K<=M*P:
    l,r=-10**18-1,0
    while l+1<r:
        t=(l+r)//2
        x=0
        mi=0
        for pi in range(P):
            while mi<M and m[mi]*p[pi]<=t:
                mi+=1
            x+=mi
        if K<=x:
            r=t
        else:
            l=t
    print(r)
else:
    l,r=0,10**18+1
    K-=M*P+Z*(Z-1)//2+Z*(M+P)
    m.reverse()
    while l+1<r:
        t=(l+r)//2
        x=0
        mi,pi=0,0
        for mj in range(M-1,-1,-1):
            while mi<M and m[mi]*m[mj]<=t:
                mi+=1
            x+=mi-(1 if mj<mi else 0)
        for pj in range(P-1,-1,-1):
            while pi<P and p[pi]*p[pj]<=t:
                pi+=1
            x+=pi-(1 if pj<pi else 0)
        if K<=x//2:
            r=t
        else:
            l=t
    print(r)

Measured memory_bytes: 108888
MOD=10**9+7
from collections import Counter

def facinv(N):
    fac,finv,inv=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    fac[0]=1;fac[1]=1;finv[0]=1;finv[1]=1;inv[1]=1
    for i in range(2,N+1):
        fac[i]=fac[i-1]*i%MOD
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i]=finv[i-1]*inv[i]%MOD
    return fac,finv,inv

def COM(n,r):
    if n<r or r<0:
        return 0
    else:
        return ((fac[n]*finv[r])%MOD*finv[n-r])%MOD

N=int(input())
fac,finv,inv=facinv(N+1)
A=list(map(int,input().split()))
m=Counter(A).most_common()[0][0]
L,R=sorted([i for i in range(N+1) if A[i]==m])
R=N-R
for k in range(1,N+2):
    print((COM(N+1,k)-COM(L+R,k-1)+MOD)%MOD)

Measured memory_bytes: 108648
package main

import (
	"fmt"
)

func main() {
	var A, B, N int
	fmt.Scanf("%d %d %d", &A, &B, &N)

	login := 0
	week := 0
	sum := 0

	for sum < N {
		login++
		week++
		sum += A

		if week%7 == 0 {
			sum += B
			week = 0
		}
	}

	fmt.Println(login)
}



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

int main() {
	int N, K; cin >> N >> K;
	vector<long> a(N), sum;
	for(int i=0; i<N; ++i) cin >> a[i];
	for(int i=0; i<N; ++i){
	    long now=a[i];
	    sum.push_back(now);
	    for(int j=i+1; j<N; ++j){
	        now += a[j];
	        sum.push_back(now);
	    }
	}
	long ans=0;
	for(int d=40; d>=0; --d){
	    vector<long> b;
	    for(int i=0; i<sum.size(); ++i){
	        if(sum[i]&((long) 1<<d)){
	            b.push_back(sum[i]);
	        }
	    }
	    if(b.size()>=K){
	        ans |= ((long) 1<<d);
	        swap(sum, b);
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t l,r; cin>>l>>r;
	int64_t ans=2018;
	for(int64_t i=l, di=0;i+di<=r and di<=2019;di++){
		int64_t x=i+di;
		// cout<<x<<endl;
		for(int64_t j=i+1, dj=0;j+dj<=r and dj<=2019;dj++){
			int64_t y=j+dj;
			if(x>=y) continue;
			// cout<<x<<" "<<y<<endl;
			ans=min(ans,x*y%2019); 
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
// g++ hello.cpp && ./a.out
using namespace std;


int main() {
	int X,Y;
	cin >> X >> Y;
	string ans = "No";
	for (int a = 0; a <= X; a++) {
		int b = X - a;
		//int h = ((2*a) + (4*b));
		if (((2*a) + (4*b)) == Y) {
			ans = "Yes";
			break; 
		}
	}
	cout <<ans << endl;
	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
long long f[3000]={1,0,0,1,1},n,mod=1000000007;
int main()
{
	cin>>n;
	if(n>4)
	{
		for(int i=5;i<=n;++i)
		 f[i]=(f[i-1]+f[i-3])%mod;
	}
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 3640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	long a, b, c, sum, n, flag = 0, m, count = 0, h[100001], g[100001] = {0},e,f,d;

	cin >> a >> b ;

	c = a + b;
	d = a - b;
	e = a * b;

	if (c >= d && c >= e) {

		cout << c << endl;
	} else if(d >= c && d >= e) {

		cout << d << endl;
	}
	else {

		cout << e << endl;
	}

	

	return 0;
}


Measured memory_bytes: 256
input_list = []
while True:
    pair = list(map(int, input().split(' ')))
    if pair[0] == 0 and pair[1] == 0:
        break
    input_list.append(pair)

for pair in input_list:
    h = pair[0]
    w = pair[1]
    for y in range(h):
        if y == 0 or y == h - 1:
            for x in range(w):
                print('#', end='')
        else:
            for x in range(w):
                if x == 0 or x == w - 1:
                    print('#', end='')
                else:
                    print('.', end='')
        print()
    print()


Measured memory_bytes: 7004
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int w = sc.nextInt();
      int i = 0;
      while(i < s.length()){
      	System.out.print(s.substring(i,i+1));
        i+=w;
      }
      System.out.println("");
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    queue<int> q;
    for (int i = 1; i < 10; i++)
    {
        q.push(i);
    }
    int cnt = 0, k;
    cin >> k;
    int current;
    while (cnt < k)
    {
        current = q.front();
        q.pop();
        cnt++;
        if (current % 10 != 0)
            q.push(10 * current + current % 10 - 1);
        q.push(10 * current + current % 10);
        if (current % 10 != 9)
            q.push(10 * current + current % 10 + 1);
    }
    cout << current << endl;
    return 0;
}

Measured memory_bytes: 1792
A, B, C, D = map(int, input().split())

attack = 0
while True:
    if attack == 0:
        C -= B
        attack = 1
        if C <= 0:
            print("Yes")
            break
    elif attack == 1:
        A -= D
        attack = 0
        if A <= 0:
            print("No")
            break
    


Measured memory_bytes: 61848
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;

  int ans = 0;
  FOR(i,1,N) {
    if (i >= N-i) break;
    ans++;
  } 
  
  cout << ans << endl;

  return 0;
}

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

using namespace std;

const int mod = 1e9+7;

typedef long long ll;

string k;
int n, d;
ll f[2][101][10101]; 

int main()
{
	cin>>k>>d;
	n=k.size();
	f[0][0][0]=1;
	f[1][0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			f[1][j][i]%=mod;
			f[0][j][i]%=mod;
			for(int b=0;b<=9;b++)
			{
				if(b==(k[n-i-1]-48))	f[1][(j+b)%d][i+1]+=f[1][j][i];	
				if(b<(k[n-i-1]-48))		f[1][(j+b)%d][i+1]+=f[0][j][i];
				f[0][(j+b)%d][i+1]+=f[0][j][i];
			}		
		}
	}
	cout<<((f[1][0][n]-1)+mod)%mod;
}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;

  cin>>a>>b;
  c=a;
  d=b;

  for(int i=1;i<d;i++){ a*=10; a+=c; }
  for(int i=1;i<c;i++){ b*=10; b+=d; }

  if(c>d) cout<<b<<endl;
  else cout<<a<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;


int main(){
  ll d,n,memo = 1;
  cin >> d >> n;
  rep(i,0,d) memo *= 100;

  if(n == 100) cout << 101*memo << endl;
  else cout << n*memo << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c,d,e,f;
	double x,y;
	while(scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f) != EOF){
		x = ((double)e*(double)c-(double)b*(double)f)/((double)e*(double)a-(double)b*d);
		y = ((double)d*(double)c-(double)a*(double)f)/((double)b*(double)d-(double)a*e);
		if(-0.005 < x && x < 0.005) x = 0;
		if(-0.005 < y && y < 0.005) y = 0;
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	return x*f;
}
int a,b;
int main()
{
	a=read(),b=read();
	if(a>9||b>9||a<1||b<1) { printf("-1\n"); return 0; }
	printf("%d\n",a*b);
	return 0;
}

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

int main(){
  
  int n, fib[50] = {1, 1};
  
  for(int i = 2;i < 45;i++) fib[i] = fib[i - 1] + fib[i - 2];
  
  cin >> n;
  cout << fib[n] << endl;
  
  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(s,t) for (int s = 0; s < t; ++s);
using ll = long long;


int main() {
  ll a,b,n;

  cin >> n >> a >> b;

  ll syou = n / (a + b);
  ll amari = n % (a + b);

  if (a >= amari){
    cout << a * syou + amari << endl;
  }
  if (a < amari){
    cout << a * syou + a << endl;
  }
}

Measured memory_bytes: 256
from collections import deque
 
h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]
visited = [[-1] * w for _ in range(h)]
move = [(1,0), (0,1), (-1,0), (0,-1)]
 
sy, sx= 0, 0
gy, gx = h-1, w-1
 
queue = deque([(sy, sx, 0)])
 
while queue:
    y, x, dist = queue.popleft()
    for dy, dx in move:
        if maze[y+dy:y+dy+1] and maze[y+dy][x+dx:x+dx+1]:
            if maze[y+dy][x+dx] == "." and visited[y+dy][x+dx] == -1:
                visited[y+dy][x+dx] = dist + 1
                queue.append((y+dy, x+dx, dist+1))
shortest_distance = visited[gy][gx]
 
if shortest_distance == -1:
    print("-1")
else:
    white_count = 0
    for row in maze:
        for cell in row:
            if cell == ".":
                white_count += 1
 
    score = white_count - 1 - shortest_distance
    print(score)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n;
  cin >> n;
  vt<int> a(n);
  rep(i, 0, n) cin >> a[i];

  vvt<i64> dp(n + 1, vt<i64>(n + 1));
  rep(i, 0, n) dp[i][i] = 0;

  rep(len, 1, n + 1) {
    rep(i, 0, n - len + 1) {
      int j = i + len;

      if((n - len) % 2 == 0) dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
      else dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
    }
  }

  cout << dp[0][n] << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    int k[m], s[m][10], p[m];
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) cin >> s[i][j];
    }
    for (int i = 0; i < m; i++) cin >> p[i];
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        bool flag = true;
        for (int i = 0; i < m; i++) {
            int cnt = 0;
            for (int j = 0; j < k[i]; j++) {
                if (bit & (1 << (s[i][j] - 1))) cnt++;
            }
            if (cnt % 2 != p[i]) {
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * “My code isn't a mess! It's organised chaos!”
 */

/*
 * short     2^15-1 ~ 3e4
 * int       2^31-1 ~ 2e9
 * long x86  2^31-1 ~ 2e9
 * long long 2^63-1 ~ 9e18
 */

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a,b) for (int a=0; a<b; ++a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000007ll;
const int infty = numeric_limits<int>::max();
struct _{_(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}_;
void err() {cerr << endl;}
template<typename T, typename... Ts>
void err(T a, Ts... as) {cerr << a << ' '; err(as...);}

 /*
  * Всегда прогоняй макс-тест перед 
  * нажатием «Отослать». Всегда.
  */ 

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

    ll p = 1;
    for (ll i = 1ll; i <= n; ++i) {
        p = (p*i) % mod;
    }

    cout << p << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
int q;
cin >> q;
vi result(0);
while(q > 0){
  string s, t;
  cin >> s >> t;
  int ssize = s.size(), tsize = t.size();
  vvi dp(1100, vi(1100, 0));

  for(int i = 0; i < ssize; i++){
    for(int j = 0; j < tsize; j++){
      if(s.at(i) == t.at(j)) dp.at(i+1).at(j+1) = dp.at(i).at(j) + 1;
      else{
        chmax(dp.at(i+1).at(j+1), dp.at(i).at(j+1));
        chmax(dp.at(i+1).at(j+1), dp.at(i+1).at(j));
      }
    }
  }

  result.push_back(dp.at(ssize).at(tsize));

  q--;
}

for(auto x: result) cout << x << endl;
  
}


Measured memory_bytes: 7600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> num(n);
for (int i = 0; i < n; i++)
{
    cin >> num.at(i);
}

int ans = 0;
for (int i = 0; i < n; i++)
{
    for (int j = i+1; j < n; j++)
    {
        ans += num.at(i)*num.at(j);
    }
}
cout << ans << endl;

return 0;
}



Measured memory_bytes: 256
n,k=map(int,input().split())
P=list(map(int,input().split()))
#kこの和
sum_k=sum(P[:k])
ans=[sum_k]
for i in range(n-k):
    temp=ans[-1]
    temp-=P[i]
    temp+=P[k+i]
    ans.append(temp)
print(k/2+max(ans)/2)
    

Measured memory_bytes: 25060