akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        x=x+y;
        y=x-y;
        x=x-y;

        x=x+z;
        z=x-z;
        x=x-z;

        System.out.println(x + " " + y + " " + z);
        
        sc.close();
    }

    // public static int[] swap(int a, int b){
    //     int[] arr = new int[2];
    //     a=a+b;
    //     b=a-b;
    //     a=a-b;
    //     arr[0]=a;
    //     arr[1]=b;
    //     return arr;
    // }

}





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

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

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

// x^y%p
long long modpow(long long x, long long y, long long p=1) {
    long long res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0) {
        if (y & 1) res = res * x % p;
        y = y>>1;
        x = x * x % p;
    }
    return res;
}

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

  string S;
  cin >> S;
  if(S[S.size()-1] == 's') {
    cout << S << "es" << endl;
  }
  else {
    cout << S << "s" << endl;
  }

    return 0;
}


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

int main() {
  int H, W; cin >> H >> W;
  vector<string> pxl(H);

  for (int i = 0; i < H; i++) {
    cin >> pxl.at(i);
  }

  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;

  for (int i = 0; i < H; i++) {
    cout << "#" << pxl.at(i) << "#" << endl;
  }

  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;

}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k;
  cin >> n >> k;
  vll a(n);
  rep(i, n){
    cin >> a[i];
  }
  auto cond = [&](ll mid) -> bool{
    ll ret = 0;
    rep(i, n){
      ret += (a[i]-1)/mid;
    }
    return ret > k;
  };
  auto BS = [&](ll true_max, ll false_min){
    while(false_min - true_max > 1){
      ll mid = true_max + ((false_min - true_max) / 2);
      (cond(mid) ? true_max : false_min) = mid;
    }
    return false_min;
  };
  ll res = BS(0, MOD);
  print(res);
}


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

using namespace std;

int n;
long long c[505], s[505], f[505], ta;

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
		scanf("%lld%lld%lld", c + i, s + i, f + i);
	for (int i = 1; i <= n; i++) {
		ta = 0;
		for (int j = i; j < n; j++) {
			ta = max(ta, s[j]);
			ta += (s[j] % f[j] - ta % f[j] + f[j]) % f[j];
			ta += c[j];
		}
		printf("%lld\n", ta);
	}
	return 0;
}


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

using namespace std;

int main(){
    int n, num, order;
    vector<int> a, out;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> order;
        switch (order){
        case 0:
            cin >> num;
            a.push_back(num);
            break;
        case 1:
            cin >> num;
            out.push_back(a[num]);
            break;
        case 2:
            a.pop_back();
            break;
        default:
            break;
        }
    }
    vector<int>::iterator it = out.begin();
    while(it!=out.end()) {
        cout << *it << endl;
        it++;
    }    
}


Measured memory_bytes: 3964
#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, k;
  cin >> n >> k;
  
  int ans = k;
  REP(i,n-1) {
    ans *= (k-1);
  }
  
  cout << ans << endl;
 
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  bool res =true;
  bool res2 =true;
  // std::cout << S.size() << std::endl;
  for (ll i = 0; i < S.size(); i++)
  {
    if ((i+1)%2)
    {
      if(S[i]=='L'){
        res = false;
      }
    } else {
      if(S[i]=='R'){
        res2 = false;
      }
    }
  }
  if (res && res2)
  {
    std::cout << YES << std::endl;
  } else {
    std::cout << NO << std::endl;
  }
    
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;

int main()
{
	int x;
	cin>>x;
	if(x>=30) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}	

Measured memory_bytes: 3636
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	(n:as) :: [Integer] <- replicateM 6 readLn
	let
		m = minimum as
	print $ 5 + ( n + m - 1 ) `div` m - 1

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define MOD (long long)(1e9+7)
using namespace std;
string s;
int main()
{
	cin >> s;
	int cnt=0,ans=0;
	for(int i=0; i<3; ans=max(ans,cnt),i++)
		if(s[i] == 'R') cnt++;
		else cnt=0;
	cout << ans;	
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const int INF = 1001001001;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<vi> ca(n, vi(m+1));
  rep(i, n) rep(j, m+1) cin >> ca[i][j];

  int patern = pow(2, n);
  int mcost = INF;
  rep(i, patern){
    int cost = 0;
    vi s(m);
    rep(j, n){
      if (i>>j & 1) {
        cost += ca[j][0];
        rep(k, m) s[k] += ca[j][k+1];
      }
    }
    bool flag = true;
    rep(i, m){
      if (s[i] < x) flag = false;
    }
    if (flag){
      mcost = min(mcost, cost);
    }
  }
  if (mcost != INF){
    cout << mcost << endl;
  }else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 4112
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;

int main(){
ll L,R;
ll ans =10000;
cin>>L>>R;
for(ll i=L;i<=min(R,L+3000);i++){
  ll a = i * i %2019;
  if(i + 2019 > R) break;
  ans = min(a,ans);
}
L = L % 2019;
R = R % 2019;

ll r = max(L,R);
ll l = min(L,R);



for(int i = l; i<=r;i++){
  for(int j=i + 1;j<=r;j++){
    ll seki = i * j;
    //cout<<i<<" "<<j<<endl;
    seki = seki % 2019;
    ans = min(seki,ans);
  }
}
cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  bool flag = false;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 15; j++) {
      if (i * 4 + j * 7 == a) flag = true;
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

typedef pair<long,long> P;

int main(){
    int N;
    const int Nmax = 100000;
    P data[Nmax];
    long X,L;

    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> X >> L;
        data[i] = P(X + L,X - L);
    }
    sort(data,data + N);

    long m = -LONG_MAX;
    int ans = 0;
    for(int i = 0;i < N;i++){
        if(data[i].second >= m){
            ans++;
            m = data[i].first;
        }
    }

    cout << ans << endl;

    return 0;
 }

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

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

    unsigned long rS;
    unsigned long b;

    unsigned long kyu = 999999999;

    if (S > kyu * kyu) {
        rS = 1000000000;
        b = rS * rS - S;
    }
    else {
        rS = sqrt(S);
        b = (rS + 1) * (rS + 1) - S;
        rS++;
    }

    cout << 0 << " " << 0 << " " << rS << " " << b << " " << 1 << " " << rS << endl;

    return 0;
}

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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int i,j;
    int tmp;
    string S,T;
    cin >> S >> T;
    for(i=0;i<S.size();i++){
        tmp = 0;
        for(j=0;j<S.size();j++){
            if(S[(j+i) % S.size()] != T[j]) {tmp =1;}
        }
        if(tmp == 0){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

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

int main(int argc, char *argv[])
{
  int n, q;
  std::cin >> n >> q;
  std::multimap<int, int> tree;
  std::vector<int> c;
  for (int i = 0; i < n + 1; i++)
  {
    c.push_back(0);
  }

  for (int i = 0; i < n - 1; i++)
  {
    int a_i, b_i;
    std::cin >> a_i >> b_i;
    tree.emplace(a_i, b_i);
  }

  for (int i = 0; i < q; i++)
  {
    int p_i, x_i;
    std::cin >> p_i >> x_i;
    c[p_i] += x_i;
  }
  for (const auto &x : tree)
  {
    c[x.second] += c[x.first];
  }

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


Measured memory_bytes: 12532
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

class tsort {
public:
	int V;
	vector<vector<int> > G;
	vector<int> deg,res;
	tsort(int node_size) : V(node_size), G(V), deg(V, 0){}
	void add_edge(int from,int to){
		G[from].push_back(to);
		deg[to]++;
	}
	bool solve() {
		queue<int> que;
		for(int i = 0; i < V; i++){
			if(deg[i] == 0){
				que.push(i);
			}
		}
		while(!que.empty()){
			int p = que.front();
			que.pop();
			res.push_back(p);
			for(int v : G[p]){
				if(--deg[v] == 0){
					que.push(v);
				}
			}
		}
		return (*max_element(deg.begin(),deg.end()) != 0);
	}
};

int dp[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    tsort ts(n);
    rep(i,m){
        int u,v;
        cin >> u >> v;
        ts.add_edge(u-1, v-1);
    }
    ts.solve();
    auto& res = ts.res;
    rrep(i,n){
        each(v,ts.G[res[i]]){
            cmx(dp[res[i]], dp[v]+1);
        }
    }
    cout << *max_element(dp, dp+n) << "\n";
    return 0;
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    ll ans = max({A,B,C});
    rep(i,K) ans *= 2;
    
    cout << A+B+C+ans - max({A,B,C})<< endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main() {
  // vector<int> X(5);
  // int x1, x2, x3, x4, x5;
  int X;
  cin >> X;

  cout << ((X >= 30) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3056
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

def main():
    A,B = map(int, input().split())
    print(lcm(A,B))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;    
    
int main ()
{
   int N,M,k=0;
   cin>>N>>M;
   int even[N+1],odd[M+1];
   	for(int i=1;i<=N;i++)
   {
   		even[i]= 2 + (i-1)*2;
   }	
   for(int i=1;i<=M;i++)
   {
   		odd[i]= 1 + (i-1)*2;
 
   }
   	for(int i=1;i<=N;i++)
   {
   		for(int j=1;j<=N;j++)	
   		{
   			if(j>i)
   			{
   			if( (even[i]+even[j]) % 2==0 )
   			k++;
   			}

   		}	
   }	
   for(int i=1;i<=M;i++)
   {
   		for(int j=1;j<=M;j++)	
   		{
   			if(j>i)
   			{
   			if( (odd[i]+odd[j]) % 2==0 )
   			k++;
   			}

   		}
   }
 	
 	
   cout<<k;
   return 0;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, x) = readLine()?.split(" ")?.map { it.toLong() } ?: return

    if (a == b) {
        println(if (a % x == 0L) 1 else 0)
        return
    }

    val toA = if (a == 0L) -1 else (a - 1) / x
    val toB = b / x

    println(toB - toA)
}

Measured memory_bytes: 37944
n = int(input())
s = list(input())
t = []
ans = 0
for i in range(1000):
    t.append(str(i//100))
    t.append(str(i//10%10))
    t.append(str(i%10))
    k = 0
    p = 0
    for j in range(3):
        if t[j] in s[k:]:
            p = s[k:].index(t[j]) + 1
            k += p
        else:
            p = -1
            break
    if p != -1:
        ans += 1
    t.clear()
print(ans)

Measured memory_bytes: 9364
N_str = input().strip()
N = int(N_str)
Ns = int(N_str[0])
Ne = int(N_str[-1])
w = len(str(N)) - 2
if w > 0:
	Nm = int(N_str[1:-1])
else:
	Nm = 0

count = 0
for A in range(1, N + 1):
	A_str = str(A)
	As = int(A_str[0])
	Ae = int(A_str[-1])
	if Ae == 0:
		continue

	if w > 0:
		for i in range(w - 1):
			count += 10 ** (i + 1)
		
		if Ae < Ns:
			count += 10 ** w
		elif Ae == Ns:
			if As > Ne:
				count += Nm
			else:
				count += Nm + 1

	if Ae == As:
		count += 1
	
	if Ae * 10 + As <= N:
		count += 1
	
print(count)



Measured memory_bytes: 3064
class Calc:
    def __init__(self, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def nCr(self, n, r):
        r = min(n - r, r)
        if r < 0:
            return 0
        if r == 0:
            return 1
        if r == 1:
            return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod


def main():
    MOD = 10 ** 9 + 7

    S = int(input())

    calc = Calc(max_value=S * 2, mod=MOD)

    ans = 0
    for k in range(1, S + 1):
        if S - k * 3 < 0:
            break
        ans = (ans + calc.nCr(S - k * 3 + k - 1, k - 1)) % MOD

    print(ans)


if __name__ == '__main__':
    main()


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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

ll N;
ll ans = 0;

void dfs(ll x, ll c3, ll c5, ll c7)
{
	if(x > N) return;

	if(c3 && c5 && c7) ans++;

	dfs(x * 10 + 3, c3 + 1, c5,     c7    );
	dfs(x * 10 + 5, c3,     c5 + 1, c7    );
	dfs(x * 10 + 7, c3,     c5,     c7 + 1);
}

int main()
{
	cin >> N;

	dfs(0, 0, 0, 0);

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    private static char[] map;
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        int length = S.length();
        char[] data = S.toCharArray();
        int[][] right = new int[length][3];
        for (int i = 0; i < length; i++) {
            Arrays.fill(right[i],Integer.MAX_VALUE);
        }
        for (int i = length-1; 0<=i; i--) {
            if (data[i]=='L') {
                right[i][0] = 0;
                right[i][1] = i;
                right[i][2] = -1;
                continue;
            }
            right[i][0] = right[i+1][0] + 1;
            right[i][1] = right[i+1][1];
            right[i][2] = right[i+1][2];
        }
        int[][] left = new int[length][3];
        for (int i = 0; i < length; i++) {
            Arrays.fill(left[i],Integer.MAX_VALUE);
        }
        for (int i = 0; i < length; i++) {
            if (data[i]=='R') {
                left[i][0] = 0;
                left[i][1] = i;
                left[i][2] = 1;
                continue;
            }
            left[i][0] = left[i-1][0] + 1;
            left[i][1] = left[i-1][1];
            left[i][2] = left[i-1][2];
        }
        int[] answer = new int[length];
        BigInteger total = BigInteger.TEN.pow(100);
        BigInteger two = new BigInteger("2");
        for (int i = 0; i < length; i++) {
            if (right[i][0] < left[i][0]) {
                BigInteger remain = total.subtract(new BigInteger(Long.toString(left[i][0])));
                if (remain.mod(two).longValue() == 0) {
                    answer[left[i][1]] += 1;
                } else {
                    answer[left[i][1] + left[i][2]] += 1;
                }
            } else {
                BigInteger remain = total.subtract(new BigInteger(Long.toString(right[i][0])));
                if (remain.mod(two).longValue() == 0) {
                    answer[right[i][1]] += 1;
                } else {
                    answer[right[i][1] + right[i][2]] += 1;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (long i : answer) {
            sb.append(i);
            sb.append(" ");
        }
        System.out.println(sb.substring(0, sb.length()-1));
    }
}


Measured memory_bytes: 61968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
 
ll n, a, b, c, d;
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b >> c >> d >> n;
	ll c2 = min(d, min(2*c, min(4*b, 8*a)));
	ll c1 = min(c, min(2*b, 4*a));
	cout << (n/2)*c2 + (n%2)*c1 << endl;
	return 0;
}

Measured memory_bytes: 256
r, c = map(int, input().split())

row_lists = []
column = []

for i in range(r):
    rows = list(map(int, input().split()))
    row_sum = sum(rows)
    rows.append(row_sum)
    row_lists.append(rows)

for j in range(c+1):
    tmp_list = []
    for i in range(r):
        tmp = row_lists[i][j]
        tmp_list.append(tmp)
    sum_tmp_list = sum(tmp_list)
    column.append(sum_tmp_list)

# output
for i in range(r):
    print(' '.join(map(str, row_lists[i])))

print(" ".join(map(str, column)))


Measured memory_bytes: 5696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,t,e,x,ab,a[200005],dp[200005];
int main(){
	n=read(),e=read(),t=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	a[n+1]=e;
	for(int i=1;i<=n;i++){
		while((a[i]-a[ab+1])*2>t)
			x=min(x,dp[ab]-2*a[ab+1]),ab++;
		dp[i]=min((ll)(1e18),dp[ab]+t);
		if(ab)dp[i]=min(dp[i],2*a[i]+x);
	}
	printf("%lld",dp[n]+e);
	return 0;
}  


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

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int count=0;
  for(int i=0;i<N-2;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C') count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
/* ex5_3 melo */
#include <stdio.h>
#include <string.h>//文字列関数を読み取れるようにする
#include <stdlib.h>
int main(void){
    int row_N,col_N,i,j;//整数の箱を４つ用意する
    char arrayc[100][100];//100*100の文字配列を用意
    int row_TorF[100], col_TorF[100];//黒があるかないか判定する文字列を列と行分用意
    scanf("%d %d",&row_N,&col_N);//行と列を代入
    for(i=0;i<row_N;i++){//二次元の文字配列を代入
        for(j=0;j<col_N;j++){
            scanf(" %c",&arrayc[i][j]);
        }
    }
    for(i=0;i<row_N;i++){//初期化
        row_TorF[i]=0;
    }
    for(j=0;j<col_N;j++){//初期化
        col_TorF[j]=0;
    }
    for(i=0;i<row_N;i++){//黒がある行と列を探す
        for(j=0;j<col_N;j++){
            if(arrayc[i][j]=='#'){
                row_TorF[i]=1;//i列には黒がある
                col_TorF[j]=1;//i行には黒がある
            }
        }
    }
    for(i=0;i<row_N;i++){//白いマスのみからなる列または行以外（黒があった列または行）を表示する
        for(j=0;j<col_N;j++){
            if(row_TorF[i]==1&&col_TorF[j]==1){
                printf("%c",arrayc[i][j]);
            }
        }
        if(row_TorF[i]==1){
                printf("\n");//1列分表示されたら改行する
        }
    }
    return 0;//正常終了
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N,A;
	cin >> N >> A;
	int L=A;
	int R=A+N-1;
	int eat;
	if(R<=0)eat=R;
	else if(L>=0)eat=L;
	else if(L<=0&&R>=0)eat = 0;
	int ans=(R+L)*(R-L+1)/2 -eat;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,L;
  	cin >> N >> L;
  	
  	int sum = 0;
  	int min = L;
  	for(int i = 0; i < N; i++){
    	sum += L+i;
      	if(abs(L+i) < abs(min))
          min = L + i;
    }
  	cout << (sum - min) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b;
  cin>>k;
  cin>>a>>b;
  int t=(b/k)*k;
  if(a<=t)
  cout<<"OK\n";
  else
  cout<<"NG\n";
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
 


#define M 110

ll n;
ll dp[M][5][5][5][5];
// ACGT
// AGC 132 123 312
// 
ll f(ll i,ll p1,ll p2,ll p3,ll p4){
	if(p1==1 and p2==3 and p3==2)return 0;
	if(p1==1 and p2==2 and p3==3)return 0;
	if(p1==3 and p2==1 and p3==2)return 0;
	if(p2==1 and p3==3 and p4==2)return 0;
	if(p2==1 and p3==2 and p4==3)return 0;
	if(p2==3 and p3==1 and p4==2)return 0;
	if(p1==1 and p2==3 and p4==2)return 0;
	if(p1==1 and p3==3 and p4==2)return 0;
	if(i>=n)return 1;
	if(dp[i][p1][p2][p3][p4]!=-1)return dp[i][p1][p2][p3][p4];
	ll ans=0;
	rep(j,1,5)(ans += f(i+1,p2,p3,p4,j)) %= md;
	return dp[i][p1][p2][p3][p4]=ans;
}
int main(){
	IOS;
	tihs;

	cin>>n;
	memset(dp,-1,sizeof(dp));
	cout<<f(0,0,0,0,0);



	return 0;
}

Measured memory_bytes: 768
n, m = map(int, input().split())
s = input()

l = []
cur = n

while cur > 0:
  position = cur
  cur = max(0, cur - m)
  while s[cur] == "1":
    cur += 1
  if cur == position:
    print(-1)
    exit(0)
  l.append(str(position - cur))
l.reverse()
print(" ".join(l))

Measured memory_bytes: 10144
d = int(input())
c = list(map(int, input().split()))
s = []
for _ in range(d):
    s.append(list(map(int, input().split())))
t = []
v = 0
last = [-1]*26
for i in range(d):
    bst = -10**10
    for j in range(26):
        tmp = s[i][j]
        for k in range(26):
            if j!=k:
                tmp -= c[k]*(i-last[k])
        if tmp>bst:
            bst = tmp
            bst_idx = j
    last[bst_idx] = i
    t.append(bst_idx+1)
for i in t:
    print(i)

Measured memory_bytes: 74028
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
int N, K, s[100010];
int l, r;
void solve()
{
    if (N == 1) {
        cout << 0 << endl;
        return;
    }
    int t = 0;
    int d = 0;
    FOR(i, 0, N - 1)
    {
        if (s[i] == s[i + 1])
            t++;
        else
            d++;
    }
    itn ans = 0;
    if (l <= K || r <= K) {
        ans = N - 1;
    } else {
        ans = t + min(K * 2, d);
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    FOR(i, 0, N)
    {
        char c;
        cin >> c;
        if (c == 'R') {
            s[i] = 1;
            r++;
        } else {
            l++;
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 1024
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pll             pair<ll,ll>
#define vll              vector<int>
#define mll             map<ll,ll>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define md             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
void hi()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void bye()
{
    #ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    #endif
}

void solve()
{
    ll n,ans=0; cin>>n;
    n=n%1000;
    if(n==0)    cout<<"0";
    else cout<<1000-n;
}

int main()
{
    hi();
    ll test_cases=1; //cin>>test_cases;
    for(ll t=1;t<=test_cases;t++)
    {
        solve();
    }
    bye();
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
cnt = 0
m = float("inf")
S = 0
for a in map(int, input().split()):
    m = min(m, abs(a))
    if a < 0:
        cnt += 1
        S -= a
    else:
        S += a
if cnt%2:
    print(S-2*m)
else:
    print(S)

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 1e9
#define INF_LL 1LL<<60
#define ll long long

bool used[100][100];
bool visited[100];
int pre[100];
int d[100];
int cost[100][100];
int V;
typedef pair<int, int> P;
map<P, bool> mp;
P hen[1000];


/* 始点sから各頂点への最短距離を求める */
void dijkstra(int s) {
    REP(i, 100) {
        d[i] = INF;
        visited[i] = false;
        pre[i] = -1;
    }
    d[s] = 0;
    while(true) {
        int v = -1;
        REP(u, V) if(!visited[u] && (v==-1 || d[u] < d[v])) v = u;

        if(v == -1) break;
        visited[v] = true;

        REP(u, V) if(d[u] > d[v] + cost[v][u]) {
            d[u] = d[v] + cost[v][u];
            pre[u] = v;
        }
    }
}

/* 頂点tへの最短路 */
vector<int> get_path(int t) {
    vector<int> path;
    for(; t != -1; t = pre[t]) {
        path.push_back(t);
    }
    reverse(path.begin(), path.end());
    REP(i, path.size()-1) {
        int a = path[i];
        int b = path[i+1];
        if(a > b) swap(a, b);
        used[a][b] = true;
    }
    return path;
}

int main() {
    int m, ans = 0; 
    cin >> V >> m;

    REP(i, 100) REP(j, 100) {
        cost[i][j] = INF;
        if(i == j) cost[i][j] = 0;
    }

    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        if(a > b) swap(a, b);
        hen[i].first = a;
        hen[i].second = b;
        cost[a][b] = c, cost[b][a] = c;
    }

    REP(idx, V) {
        dijkstra(idx);
        REP(idx2, V) {
            if(idx2 == idx) continue;
            get_path(idx2);
        }
    }

    REP(i, m) {
        if(!used[hen[i].first][hen[i].second]) ans++; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
fn main() {
    let nums: Vec<i32> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned().split(' ').map(|s| s.parse::<i32>().unwrap()).collect()
    };
    let mut check1: i32 = nums[2] % (7 * nums[0] + nums[1]);
    let mut check2: i32 = check1 / nums[0];
    let mut ans: i32 = 7 * (nums[2] / (7 * nums[0] + nums[1]));
    if check1 != 0 {
        if check2 >= 7 {
            ans = ans + 7;
        } else {
            if check1 % nums[0] == 0 {
                ans = ans + check2;
            } else {
                ans = ans + check2 + 1;
            }
        }
    }

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


Measured memory_bytes: 5028
import java.util.*

fun main(vararg args: String) {
    val scanner = Scanner(System.`in`)
    val sideList = mutableListOf<Int>()
    sideList.add(scanner.nextInt())
    sideList.add(scanner.nextInt())
    sideList.add(scanner.nextInt())
    val triangle = Triangle(sideList.sortedBy { it })
    println(triangle.calculateArea())
}

class Triangle constructor(private val sides: List<Int>) {
    fun calculateArea(): Int {
        return sides[0] * sides[1] / 2
    }
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

ll MAX_X = 1000000000;

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

    ll rt = min(static_cast<ll>(ceil(sqrt(S))), MAX_X);

    ll rem = rt*rt - S;
    assert(rem >= 0);

    if (rem <= MAX_X) {
        cout << 0 << " " << 0 << " " << rt << " " << 1 << " " << rem << " " << rt << endl;
    } else {
        rem = rt*(rt-1) - S;
        cout << 0 << " " << 0 << " " << rt << " " << 1 << " " << rem << " " << rt - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rapido ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

void solve()
{
  int n;cin>>n;
  vector<int>arr(n);
  for(int i=0;i<n;i++)
  cin>>arr[i];
  
  vector<int>dec(n,1);
  for(int i=1;i<n;i++)
  {
      if(arr[i]<=arr[i-1])
      dec[i]=dec[i-1]+1;
      else
      dec[i]=1;
  }
  int ans=*max_element(dec.begin(),dec.end()) -1;
  cout<<ans<<endl;
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    solve();
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a<=9&&b<=9)cout << a*b << endl;
  else cout << -1 << endl;
}


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

using namespace std;

const int z = 1e9+7;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    k--;

    int dp[h+1][w];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int i = 1; i <= h; i++) {
        for (int j = 0; j < (1 << (w - 1)); j++) {
            if (j & (j << 1)) {
                continue;
            }
            for (int k = 0; k < w; k++) {
                if (j & (1 << k)) {
                    dp[i][k+1] = (dp[i][k+1] + dp[i-1][k]) % z;
                } else if (k > 0 && j & (1 << (k - 1))) {
                    dp[i][k-1] = (dp[i][k-1] + dp[i-1][k]) % z;
                } else {
                    dp[i][k] = (dp[i][k] + dp[i-1][k]) % z;
                }
            }
        }
    }

    cout << dp[h][k] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include "Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 1000011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	ll n, k, a[N], f[N];
	
	inline int Check ( ll x ) {
		ll s = k;
		For ( i, 1, n ) 
			if (a[i] * f[i] > x) {
				ll cc = x / f[i];
				if (a[i] - cc > s) return 0;
				s -= a[i] - cc;
			}
		return s >= 0;
	}
	
	ll Ans;
	
	int main() {
		n = read(), k = read();
		For ( i, 1, n ) a[i] = read();
		For ( i, 1, n ) f[i] = read();
		sort(a + 1, a + n + 1);
		sort(f + 1, f + n + 1, greater <ll> ());
		
		ll l = 0, r = 1e12;
		while (l <= r) {
			ll Mid = (l + r) >> 1;
			Check(Mid)? Ans = Mid, r = Mid - 1: l = Mid + 1;
		} return wln(Ans), 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  struct NODE {
    int turn, pos;
    NODE(int a, int b) : turn(a), pos(b) {}
    bool operator<(const NODE &p) const {
      if (turn == p.turn)
        return pos > p.pos;
      return turn > p.turn;
    }
  };
  int nxt[maxn];
  void solve() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    priority_queue<NODE> que;
    que.emplace(0, n);
    for (int i = n - 1; i >= 0; --i) {
      if (s[i] == '1')
        continue;
      while (que.size() && que.top().pos - i > m) {
        que.pop();
      }
      if (!que.size()) {
        cout << -1;
        return;
      }
      nxt[i] = que.top().pos;
      que.emplace(que.top().turn + 1, i);
    }
    int b = 0;
    while (b != n) {
      cout << nxt[b] - b << ' ';
      b = nxt[b];
    }
    cout << endl;
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 1912
n,m=map(int,input().split(" "))
l=[]

o=1
while o<=m*2:
    if o%2!=0:
        l.append(o)

    o+=2


e=2
while e<=n*2:
    if e%2==0:
        l.append(e)

    e+=2


re=0


for i in range(0,len(l)):
    j=i+1
    while j<len(l):
        s=l[i]+l[j]
        if s%2==0:
            re+=1
            

        j+=1

print(re) 

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
//Node T_root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  y=NIL;
  x=root;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true) {
			String str=in.next();
			if(str.charAt(0)=='#')break;
			int y=in.nextInt(),m=in.nextInt(),d=in.nextInt();
			
			if(y>31 || (y>=31 && m>=5)) {
				str="?";y-=30;
			}
			System.out.println(str+" "+y+" "+m+" "+d);
		}
	}

}



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

using namespace std;


ll solve(ll a, ll b, ll sum){
    if(a%b == 0)    return sum + 2*a - b;
    return solve(b, a%b, sum + 2*b*(a/b));
}

int main(){
    ll n, x;
    cin >> n >> x;
    ll a = max(n-x, x);
    ll b = min(n-x, x);
    if(a == b)  cout << 3*x << endl;
    else        cout << n + solve(a, b, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

void solve() {
    int n;
    cin >> n;
    VLL a(n+1);
    REP(i,0,n+1) cin >> a[i];
    if (n == 0) {
        cout << (a[0] == 1 ? 1 : -1) << endl;
        return;
    }
    if (a[0] != 0) {
        cout << -1 << endl;
        return;
    }
    // REP(i,0,30) if (a[i] > pow(2,i)) {
    //     cout << -1 << endl;
    //     return;
    // }

    VLL fs(n+1,1LL<<60);
    fs[0] = 1;
    REP(i,1,n+1) {
        fs[i] = fs[i-1] * 2 - a[i];
        if (fs[i] > (1LL<<60)) break;
    }
    REP(i,0,n+1) if (fs[i] < 0LL) {
        cout << -1 << endl;
        return;
    }

    VLL cnt(n+1);
    cnt[n] = a[n];
    RREP(i,0,n) {
        if (cnt[i+1] > fs[i] * 2) {
            cout << -1 << endl;
            return;
        }
        cnt[i] = min(fs[i], cnt[i+1]) + a[i];
    }
    LL ans = 0;
    REP(i,0,n+1) ans += cnt[i];
    cout << ans << endl;
}

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

Measured memory_bytes: 5580
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vint = vector<int>;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	bool hw[h], ww[w];
	char a[h][w];
	REP(i, h){
		hw[i] = true;
		REP(j, w){
			cin >> a[i][j];
			if (a[i][j] == '#'){
				hw[i] = false;
			}
		}
	}
	REP(i, w){
		ww[i] = true;
		REP(j, h){
			if (a[j][i] == '#'){
				ww[i] = false;
			}
		}
	}
	REP(i, h){
		if (hw[i]){
			continue;
		}
		REP(j, w){
			if (ww[j]){
				continue;
			}
			cout << a[i][j];
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 256