akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200005
char a[MAXN];
int main()
{
	long long ans = 0;
	scanf("%s", a);
	for(int i = 0; i < strlen(a); i++)
		ans += a[i] - '0';
	if(ans % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3816
s=int(input())

def f(n):
  if n%2==0:
    return n/2
  else:
    return 3*n+1

l=[s]
m=0
before=s
while True:
  new=f(before)
  m+=1
  if new in l:
    break
  l.append(new)
  before=new

print(m+1)


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n,h;
  cin >> n >> h;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];
  sort(a.rbegin(),a.rend());
  sort(b.begin(),b.end());
  int ans = 0;
  while(b.back()>a[0] && !b.empty() && h>0){
    ans++;
    h -= b.back();
    b.pop_back();
  }
  if(h<=0) { cout << ans << endl; return 0;}
  ans += (h+a[0]-1)/a[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int favNum = 753;
		String s = sc.next();
		
		
		int minDif = 1000;
		for (int i = 0; i < s.length() - 2; i++) {
			int num = Integer.valueOf(s.substring(i, i + 3));
			minDif = Math.min(minDif, Math.abs(favNum - num));
		}
		
		System.out.println(minDif);
		
		sc.close();
	}
}




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

int main(){
	int i, j, n, sum, result;
	int a[5000];
	while(cin >> n){
		if(n == 0){
			break;
		}
		for (i = 0; i < n; i++) {
			cin >> a[i];
		}
		result = a[0];
		for (i = 0; i < n; i++) {
			sum = 0;
			for (j = i; j < n; j++) {
				sum += a[j];
				result = max(result, sum);
			}
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 0
# copy
h, w = map(int, input().split())
a = [list(map(int, input().split()))for _ in range(h)]
ans = []
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2:
            a[i][j+1] += 1
            ans.append([i+1, j+1, i+1, j+2])
    if i < h-1 and a[i][w-1] % 2:
        a[i+1][w-1] += 1
        ans.append([i+1, w, i+2, w])
        
print(len(ans))
for t in ans:
    print(*t)

Measured memory_bytes: 30272
from math import factorial
def combi(n,k):
    return factorial(n) // factorial(k) // factorial(n-k)

n,p = map(int,input().split())
a = list(map(int,input().split()))
even = 0
odd  = 0
for i in a:
    if i&1:
        odd  += 1
    else:
        even += 1
picke = 0
for i in range(even + 1):
    picke += combi(even,i)
picko = 0
for i in range(p,odd + 1,2):
    picko += combi(odd,i)
print(picke*picko)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using Double = long double;
signed main(){
  Int h,w;
  cin>>w>>h;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];
  vector<vector<Int> > dg(h,vector<Int>(w,-1)),ds=dg;
  using T = pair<Int,int>;
  queue<T> qg,qs;
  
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(s[i][j]=='g'){
	qg.push(T(i,j));
	dg[i][j]=0;
      }
      if(s[i][j]=='*'){
	qs.push(T(i,j));
	ds[i][j]=0;
      }
    }
  }

  Int dy[]={0,0,1,-1};
  Int dx[]={1,-1,0,0};
  auto bfs=[&](queue<T> &q,vector<vector<Int> > &d){
    while(!q.empty()){
      T t=q.front();q.pop();
      Int y=t.first,x=t.second;
      for(Int k=0;k<4;k++){
	Int ny=y+dy[k],nx=x+dx[k];
	if(s[ny][nx]=='#'||s[ny][nx]=='*') continue;
	if(~d[ny][nx]&&d[ny][nx]<=d[y][x]+1) continue;
	d[ny][nx]=d[y][x]+1;
	q.push(T(ny,nx));
      }
    }
    if(0){
      cout<<endl;
      for(Int i=0;i<h;i++){
	for(Int j=0;j<w;j++){
	  if(d[i][j]<0) cout<<"x";
	  else cout<<hex<<d[i][j];
	}
	cout<<endl;
      }
    }
  };

  bfs(qg,dg);
  bfs(qs,ds);

  auto get=[&](Int i,Int j,Double p){
    if(~dg[i][j]&&~ds[i][j])
      return min((Double)dg[i][j],ds[i][j]+p);
    if(~ds[i][j]) return ds[i][j]+p;
    if(~dg[i][j]) return (Double)dg[i][j];
    return Double(0);
  };
  
  auto calc=[&](Double p){
    Double q=0,c=0;
    for(Int i=0;i<h;i++){
      for(Int j=0;j<w;j++){
	if(s[i][j]=='#'||s[i][j]=='g'||s[i][j]=='*') continue;
	c+=1.0;
	q+=get(i,j,p);
      }
    }
    q/=c;
    //printf("%.12Lf %.12Lf\n",p, p-q);
    return p-q;
  };

  Double l=0,r=1e15;

  for(int k=0;k<1000;k++){
  //while(abs(calc(l))>1e-10){
    Double m=(l+r)/2;
    if(calc(m)<=Double(0)) l=m;
    else r=m;
  }
  
  //printf("%.12f\n",calc(l));
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      if(s[i][j]=='s')
	printf("%.12Lf\n",get(i,j,l));
  
  return 0;
}

Measured memory_bytes: 7448
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;

    map<int,int> mp;


    FOR(x,1,101) FOR(y,1,101) FOR(z,1,101) {
        mp[x*x+y*y+z*z+x*y+y*z+z*x]++;
    }

    REP(i,N) {
        print(mp[i+1]);
    }
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/aising2020/aising2020_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/aising2020/aising2020_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/aising2020/aising2020_c && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 6036
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

struct City {
    int x, y;
    ll p;
    City(int x=0, int y=0, ll p=0): x(x), y(y), p(p) {}
    bool operator< (const City &c) const { return (x != c.x ? x < c.x : y < c.y); }
};

int n;
vector<City> cities;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n;
    for(int i=0;i<n;++i) {
        City city;
        cin >> city.x >> city.y >> city.p;
        cities.push_back(city);
    }

    // 前計算
    ll x_pre[1<<n][n], y_pre[1<<n][n];
    fill_n(x_pre[0], (1<<n) * n, LINF);
    fill_n(y_pre[0], (1<<n) * n, LINF);
    // x 軸に垂直な地下鉄だけがある場合
    for(int i=0;i<(1<<n);++i) {
        set<ll> lines;
        lines.insert(0);
        for(int j=0;j<n;++j) {
            if(i & (1<<j)) {
                lines.insert(cities[j].x);
            }
        }
        for(int j=0;j<n;++j) {
            auto itr = lines.lower_bound(cities[j].x);
            if(itr != lines.end()) x_pre[i][j] = abs(cities[j].x - *itr);
            if(itr != lines.begin()) {
                --itr;
                x_pre[i][j] = min(x_pre[i][j], abs(cities[j].x - *itr));
            }
        }
    }
    // y 軸に垂直な地下鉄だけがある場合
    for(int i=0;i<(1<<n);++i) {
        set<ll> lines;
        lines.insert(0);
        for(int j=0;j<n;++j) {
            if(i & (1<<j)) {
                lines.insert(cities[j].y);
            }
        }
        for(int j=0;j<n;++j) {
            auto itr = lines.lower_bound(cities[j].y);
            if(itr != lines.end()) y_pre[i][j] = abs(cities[j].y - *itr);
            if(itr != lines.begin()) {
                --itr;
                y_pre[i][j] = min(y_pre[i][j], abs(cities[j].y - *itr));
            }
        }
    }

    // i: 地下鉄が通る街
    // j: x 軸に垂直な地下鉄が通る街
    ll ans[n+1];
    fill_n(ans, n+1, LINF);
    for(int i=0;i<(1<<n);++i) {
        int bitcnt = 0;
        for(int j=0;j<n;++j) bitcnt += ((i >> j) & 1);
        for(int j=i;j>0;j=(j-1)&i) {
            ll tmp = 0LL;
            for(int k=0;k<n;++k) {
                tmp += min(x_pre[j][k], y_pre[i&~j][k]) * cities[k].p;
            }
            ans[bitcnt] = min(ans[bitcnt], tmp);
        }
        {
            ll tmp = 0LL;
            for(int k=0;k<n;++k) {
                tmp += min(x_pre[0][k], y_pre[i][k]) * cities[k].p;
            }
            ans[bitcnt] = min(ans[bitcnt], tmp);
        }
    } 

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


Measured memory_bytes: 11340
#include<bits/stdc++.h>
            #include<ext/pb_ds/assoc_container.hpp>
            #include<ext/pb_ds/tree_policy.hpp>
            using namespace __gnu_pbds;
            using namespace std;
            # define ll long long
            # define int long long  //comment it out when MLE
           // # define endl "\n"
            template <typename T>
            using ordered_set = tree<T, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

            #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
            //# define m 163577857
            # define mo 1000000007
            # define pi acos(-1)
            # define fi first
            # define se second
            #define REP(i,n) for (int i = 1; i <= n; i++)
            const ll mod =  1e9+7;
            //const int K = 2;
            //typedef vector<vector<int> > matrix;
/*
          int add(int a, int b,int mod) {
                a%=mod;
                b%=mod;
                a += b;
                if (a >= mod) a -= mod;
                if(a<0)
                {
                    a += mod;
                    a %= mod;
                }
                return a;
            }

            int mul(ll a, int b,int mod) {
                a%=mod;
                b%=mod;
                a *= b;
                a += mod;
                return a % mod;
            }
            int po(int a,int b,int mod)
            {
                if(b==0)
                    return 1;
                if(b%2==0)
                    return po(mul(a,a,mod),b/2,mod);
                return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
            }


            ll fact[200003];
            ll inv[200003];

            void fact0()
            {
                int i,j;
                fact[0]=1;
                for(i=1;i<=200000;i++)
                {
                    fact[i]=i*fact[i-1]%mod;
                }
                inv[0]=1;
                inv[1]=1;
                ll p=mod;
                for (i=2; i<=200000; i++)
                    inv[i] = (p - (p/i) * inv[p%i] % p) % p;

                for(i=2;i<=200000;i++)
                {
                    inv[i]*=inv[i-1];
                    inv[i]%=mod;
                }
            }
            int help(int a,int b)
            {
               // cout<<a<<" "<<b<<endl;
                int an = fact[a];
                //cout<<an<<endl;
                an *= inv[b];
                an %= mod;
                an *= inv[a-b];
                an %= mod;
                return an;
            }
/*
          void random()
            {
              srand(time(0));
            for (int i = 0; i < n; i ++)
                perm[i] = i + 1;
            random_shuffle(perm, perm + n);
            }
int ncr(int a,int b)
{
    int tt = fact[a];
    tt %= mod;
    tt *= inv[a-b];
    tt %= mod;
    tt *= inv[b];
    tt %= mod;
    return tt;
}
*/

signed main() {
	gok

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

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





















  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
    int a,b;    cin >> a >> b ;
    if(a>=13)cout << b << endl;
    else if(a>=6)cout << b/2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sInp = Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sInp[0]);
            List<int> lstInp = new List<int>();
            sInp = Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < iN; i++) { lstInp.Add(int.Parse(sInp[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "";
            int iMax = lstInp.Max();
            int iMin = lstInp.Min();
            List<int> lstRet = new List<int>();
            for (int i = iMin; i <= iMax; i++)
            {
                int iCst = 0;
                for (int j = 0; j < lstInp.Count; j++)
                {
                    iCst += (int)Math.Pow(Math.Abs(i - lstInp[j]), 2);
                }
                lstRet.Add(iCst);
            }
            lstRet.Sort();

            // 出力
            Console.WriteLine("{0}", lstRet[0].ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

#define INF 1e9
using namespace std;

int main() {

    int N; cin >> N;

    vector<long long> A(N+1);
    for (int i = 0; i <= N; ++i) {
        cin >> A[i];
    }

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

    long long ans = 0;

    for (int i = 0; i < N; ++i) {
        long long t = min(A[i], B[i]);
        A[i] -= t;
        B[i] -= t;
        ans += t;

        t = min(A[i+1], B[i]);
        A[i+1] -= t;
        B[i] -= t;
        ans += t;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
viewlist = [-1, 0, 1]
H, W = map(int, input().split())
gametable = []
for i in range(0, H):
	lst = []
	s = input()
	for j in range(0, W):
		lst.append(s[j])
	gametable.append(lst)
for i in range(0, H):
	for j in range(0, W):
		if gametable[i][j] == '.':
			cnt = 0
			for p in range(0, 3):
				lookh = i+viewlist[p]
				if 0 <= lookh and lookh < H:
					for q in range(0, 3):
						lookw = j+viewlist[q]
						if 0 <= lookw and lookw < W:
							if p != 1 or q != 1:
								if gametable[lookh][lookw] == '#':
									cnt += 1
			gametable[i][j] = str(cnt)
for i in range(0, H):
	ans = ''
	for j in range(0, W):
		ans = ans + gametable[i][j]
	print(ans)

Measured memory_bytes: 41712
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
template<class T> using vv=vector< vector<T> >;
typedef deque<int> di;
typedef deque< deque<int> > ddi;

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


int main() {
    int w,h;  
    while(cin >> w >> h, w) {
        int m[35][35][4] = {}; // right, left, up, down
        int g[35][35] = {};
        FOR(i,1,h*2){
            if(i % 2 == 1) {
                FOR(j,1, w) {
                    int tmp;
                    cin >> tmp;
                    if(tmp == 0) { 
                        m[(i+1)/2][j][0] = 1;
                        m[(i+1)/2][j+1][1] = 1;
                    }
                }
            } else {
                FOR(j,1,w+1) {
                    int tmp;
                    cin >> tmp;
                    if(tmp == 0) {
                        m[i/2][j][3] = 1;
                        m[(i/2)+1][j][2] = 1;
                    }
                }
            }
        }

/*
        rep(i,h+1) {
            rep(j,w+1) {
                cout << "\"";
                rep(k,4) {
                    cout << m[i][j][k] << " ";
                }
                cout << "\"";
            }
            cout << endl; 
        }
*/

        queue<i_i> Q;
        Q.push(make_pair(1,1));
        g[1][1] = 1;
        while(!Q.empty()) {
            i_i tmp = Q.front();
            Q.pop();
            if(tmp.first == h && tmp.second == w) {
                break;
            }
            rep(i,4) {
                if(m[tmp.first][tmp.second][i] == 1 && g[tmp.first+dy[i]][tmp.second+dx[i]] == 0) {
                    //debug2(tmp.first+dy[i],tmp.second+dx[i]);
                    Q.push(make_pair(tmp.first+dy[i],tmp.second+dx[i]));
                    g[tmp.first+dy[i]][tmp.second+dx[i]] = g[tmp.first][tmp.second] + 1; 
                }
            }
        }
        cout << g[h][w] << endl;
    }
    return 0;
}

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

const ll MAXX = 1e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("INP.txt", "r", stdin);
    //freopen("OUT.txt", "w", stdout);
	ll n, k;
	cin >> n >> k;
	ll cnt = 0;
	for (ll i = 0; i < n; i++) {
		ll x;
		cin >> x;
		cnt += (x >= k);
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    int n,a;
     
    int main(){
      cin>>n;
      vector<int>v1(n,0);
      vector<int>v2(n,0);
      for (int i=0; i<n; i++){
        cin>>v1[i];
        v2[i]=i+1;
      }
      for (int i=0; i<n; i++){
        if (v1[i]!=v2[i]){
          a++;
        }
      }
      if (a<3){
        cout<<"YES";
      }
      else{
        cout<<"NO";
      }
    }

Measured memory_bytes: 256
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3436
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double T = sc.nextDouble();
	    double X= sc.nextDouble();
		double x = 0;
		if((1<=T&&T<=100)&&(1<=X&&X<=100)) {
	 x = T / X;
	}
	System.out.println(x);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
string s, t;
int ls, lt, sum, ans, i, j;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> s >> t;
	ls = s.size(); lt = t.size();
	for (i = 0, ans = 0x3f3f3f3f; i <= ls - lt; i++) {
		for (j = 0, sum = 0; j < lt; j++) if (s[i + j] != t[j]) sum++;
		ans = min (ans, sum);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3644
import sys
  
#0123456789
#01234567
#01235789

def convert(dec):
    s = ""
    d = dec
    while True:
        div = d//8
        rem = d % 8
        d = div
        if rem == 4:
            rem = 5
        elif rem == 5:
            rem = 7
        elif rem == 6:
            rem = 8
        elif rem == 7:
            rem = 9

        s = str(rem)+ s
        if div <= 0:
            break
    return s

for s in sys.stdin:
    if int(s) == 0:
        break
    print(convert(int(s)))


Measured memory_bytes: 5888
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> p(n), q(n);
	for (int i=0; i<n; i++)
		cin>>p[i];
	for (int i=0; i<n; i++)
		cin>>q[i];
	vector<int> x(n);
	for (int i=0; i<n; i++)
		x[i]=i+1;
	bool eq=true;
	for (int i=0; i<n; i++)
		if(p[i]!=q[i])
			eq=false;
	if(eq) {
		cout<<0<<"\n";
		return 0;
	}

	vector<int> cur;
	int iter=0;
	do {
		bool eq=true;
		for (int i=0; i<n; i++)
			if(p[i]!=x[i])
				eq=false;
		if(eq)
			cur.push_back(iter);
		eq=true;
		for (int i=0; i<n; i++)
			if(q[i]!=x[i])
				eq=false;
		if(eq)
			cur.push_back(iter);
		iter++;
	} while(next_permutation(x.begin(),x.end()));
	cout<<abs(cur.front()-cur.back())<<"\n";
	return 0;
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e5 + 5;

typedef long long ll;

int n, a[N], q, L, up[19][N];

int main()
{
      cin >> n;

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

      cin >> L;

      for(int i = n; i >= 1; i --)
      {
            int l = i, r = n, d = a[i] + L;
            while(r - l > 1)
            {
                  int md = (l + r) >> 1;
                  if(a[md] > d)
                        r = md;
                  else
                        l = md;
            }
            if(a[r] <= d)
                  l = r;

            up[0][i] = l;
      }

      for(int i = 1; i <= 17; i ++)
            for(int j = 1; j <= n; j ++)
                  up[i][j] = up[i - 1][up[i - 1][j]];

      cin >> q;

      while(q --)
      {
            int l, r;
            cin >> l >> r;
            if(l > r) swap(l, r);
            int ans = 1;
            for(int i = 17; i >= 0; i --)
                  if(up[i][l] && up[i][l] < r)
                  {
                        ans += (1 << i);
                        l = up[i][l];
                  }

            cout << ans << endl;
      }
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int after[200005];
int ar[200005];
int32_t main(){
	string s;cin>>s;
	for(int i=0;i<s.length();i++){
		ar[i+1]=(s[i]=='B');
	}
	int n = s.length();
	after[n]=0;
	for(int i=n-1;i>=1;i--){
		after[i]=(!ar[i+1])+after[i+1];
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=(ar[i]*after[i]);
	}
	/*for(int i=1;i<=n;i++){
		cout<<ar[i]<<" ";
	}
	cout<<"\n";
	for(int i=1;i<=n;i++){
		cout<<after[i]<<" ";
	}
	cout<<"\n";*/
	cout<<ans;
}


Measured memory_bytes: 3716
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,h;cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc  = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println(a + b >= c ? "Yes" : "No");
	}
}


Measured memory_bytes: 35708
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;


int k;

int ans[50];

signed main(){

    cin >> k;

    int times = k/50;
    int room = k%50;

    for(int i = 0;i < 50;i++){
        ans[i] = 49+times;
    }
    for(int i = 0;i < room;i++){
        ans[i]+=50-room+1;
    }
    for(int i = room;i < 50;i++){
        ans[i]-=room;
    }

    cout<< 50<< endl;
    for(int i = 0;i < 50;i++){
        cout<< ans[i]<< " ";
    }
    cout<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

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

    int k;
    cin >> k;
    ll ans = 0;
    FOR(i, 1, k + 1)
    FOR(j, 1, k + 1) FOR(l, 1, k + 1) ans += __gcd(i, __gcd(j, l));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;


int main(int argc, char** argv) {
	string S;

	cin >> S;


	long long len = S.length();
	long long ans = len;

	for (long long i = 0; i < len - 1; i++) {
		if (S[i] != S[i + 1]) {
			ans = min(ans, max(i + 1, len - i - 1));
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 512
W, H, N = map(int, input().split())

x = [0]*N
y = [0]*N
a = [0]*N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())

left_x = [0]
right_x = [W]
down_y = [0]
up_y = [H]

for i in range(N):
    if a[i] == 1:
        left_x.append(x[i])
    elif a[i] == 2:
        right_x.append(x[i])
    elif a[i] == 3:
        down_y.append(y[i])
    elif a[i] == 4:
        up_y.append(y[i])

w = min(right_x) - max(left_x)
h = min(up_y) - max(down_y)

if w <= 0 or h <= 0:
    print(0)
else:
    print(w*h)

Measured memory_bytes: 3064
const log = console.log;

const createScanFunctions = (input: string) => {
  const str = input.trim();
  const len = str.length;
  let index = 0;

  const scan = () => {
    const startIndex = index;

    while (index < len) {
      const char = str[index];

      if (char === " " || char === "\n")
        return str.substring(startIndex, index++);

      index++;
    }

    return str.substr(startIndex);
  };

  const scanInt = () => parseInt(scan());

  return { scan, scanInt };
};

// ----

function addMappedValue<T>(map: Map<T, number>, key: T, v: number) {
  map.set(key, (map.get(key) || 0) + v);
}

// ----

function Main(input: string): void {
  const { scan, scanInt } = createScanFunctions(input);

  const wordPointMap = new Map<string, number>();

  const n = scanInt();

  for (let i = 0; i < n; i++) addMappedValue(wordPointMap, scan(), 1);

  const m = scanInt();

  for (let i = 0; i < m; i++) addMappedValue(wordPointMap, scan(), -1);

  log(Math.max(0, ...Array.from(wordPointMap.values())));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <stdio.h>

int sum(int a, int b, int t){
  int sum;
  sum = (int)(t / a) * b;
  return sum;
}

int main(void){
  int A, B, T;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &T);
  printf("%d", sum(A, B, T));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}

signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9 + 7;
	int h,a;
	cin>>h>>a;
	cout<<(h-1)/a+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
    ll a,b,c;
    cin>>a>>b>>c;
    ll res;

    if(b<c){
        res = b-1;
    }else if(b==c){
        res = c-1;
    }else{
        res = c;
    }


    ll temp = floor( ((a*res)/b) ) - (a * floor(res/b));
    cout<<temp;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

vector<int> g[200000];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int flag = 0;
    rep(i, g[0].size())
    {
        int v = g[0][i];
        if (find(ALL(g[v]), n - 1) != g[v].end())
            flag = 1;
    }
    flag == 1 ? OP("POSSIBLE") : OP("IMPOSSIBLE");

    return 0;
}

Measured memory_bytes: 12016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main()
{
    std::vector<int> A;
    for(int i=0; i<4; i++){
        int temp;
        std::cin >> temp;
        A.push_back(temp);
    }
    if(A[1]<A[2] || A[3] <A[0]){
        std::cout << 0 << std::endl;
    }else{
        std::sort(A.begin(),A.end());
        std::cout << A[2]-A[1] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=510;
ll n;
vec idx={1,-1,0,0};
vec idy={0,0,1,-1};
mat dis(N,vec(N)),v(N,vec(N));


void dfs(ll x,ll y) {
  for(ll i=0;i<4;i++) {
    ll nx=idx[i]+x;
    ll ny=idy[i]+y;
    if(dis[x][y]+v[x][y]<dis[nx][ny]) {
      dis[nx][ny]=dis[x][y]+v[x][y];
      dfs(nx,ny);
    }
  }
}

int main() {
  cin >> n;
  vec p(n*n);
  for(ll i=0;i<n*n;i++) {
    cin >> p[i];
  }
  for(ll i=1;i<=n;i++) {
    for(ll j=1;j<=n;j++) {
      v[i][j]=1;
      dis[i][j]=min({i-1,j-1,n-i,n-j});
    }
  }
  ll ans=0;
  for(ll i=0;i<n*n;i++) {
    ll x=(p[i]-1)/n+1;
    ll y=(p[i]-1)%n+1;
    v[x][y]=0;
    ans+=dis[x][y];
    dfs(x,y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 24620
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

main(){
    int n, max=0;
    cin >> n;
    int v[21],  c[21];
    FOR(i,0,n){
        int vi;
        cin >> vi ;
        v[i] = vi;
    }
    FOR(j,0,n){
        int ci;
        cin >> ci ;
        c[j] = ci;
    }

    FOR(k,0,n){
        if(v[k] > c[k]){max += v[k]-c[k];}
    }
    if(v > c){max += v-c;}
    cout << max << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct edge
{
	int to;
	long long cost;
};

typedef pair<long long, int> P;
vector<edge> G[100000];
long long d[100000];

void dijkstra(int s)
{
	priority_queue<P, vector<P>, greater<P> > que;
	for (int i = 0; i < 100000; i++)
		d[i] = 100000000000000000;
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)
			continue;
		for (int i = 0; i < G[v].size(); i++)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main()
{
	/*
	 * n : nodes
	 * m : edges
	 * s : start
	 * t : goal
	 */
	int n, m, s;
	s = 1;
	scanf("%d %d", &n, &m);

	int x1[m],x2[m];

	for (int i = 0; i < m; i++)
	{
		/*
		 * u,v : nodes
		 * a : cost
		 */
		int u, v;
		long long a = 1;
		scanf("%d %d", &u, &v);
		// 1<=u,v<=n -> 0<=u,v<=n-1
		u--;
		v--;
		x1[i] = u;
		x2[i] = v;
	}

	int ans = 0;

	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			G[j].erase(G[j].begin(), G[j].end());
		}
		for (int j = 0; j < m; j++){
			if(j!=i){
				struct edge e;
				//insert edge u->v, v->u into G
				e.to = x1[j];
				e.cost = 1;
				G[x2[j]].push_back(e);
				e.to = x2[j];
				e.cost = 1;
				G[x1[j]].push_back(e);
			}
		}
		dijkstra(s - 1);
		for(int j=0;j<n;j++){
			if(d[j]>10000000){
				ans++;
				break;
			}
		}
	}

	printf("%d\n",ans);


	return 0;
}

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

int main(){
	int n,a,b;cin>>n>>a>>b;
	int cnt=0;
	for(int i=1;i<=n;i++){
		int sum=0,d=i;
		while(d){sum+=d%10;d/=10;}
		if(a<=sum&&sum<=b)cnt+=i;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
#define pprint(a,m,n) rep(j,0,m){ print(a[j],n); }
const int mod = 1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int N,K;cin>>N>>K;
	int sum=1;int i=1;
	int temp;
	while(sum<N){
		temp=(sum+K-1)/K;//cout<<temp<<endl;
		if(N-sum>=temp){ sum+=temp; i++; }
		else break;
	}cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 3076
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		String ans = "Yes";
		char r = 'R';
		char l = 'L';
		for (int i = 0; i < S.length(); i++) {
			char now = S.charAt(i);
			if (i%2==0) {
				if (now == l) {
					ans = "No";
					break;
				}
			} else if (now == r) {
				ans = "No";
				break;
			}
		}
		System.out.println(ans);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22612
import sys
S = input()
N = len(S)
s = S[::-1]

if S != s:
    print('No')
    exit()

if (S[:(N-1)//2]) != (S[:((N-1)//2)][::-1]):
    print('No')
    exit()

if S[((N+3)//2)-1:] != S[((N+3)//2)-1:][::-1]:
    print('No')
    exit()

print('Yes')

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

using namespace std;

const int MAXN = 1e5 + 5;
const int MAXK = 1e2 + 5;

int tab[MAXN];
int dp[MAXN];

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

    int n, k;
    cin >> n >> k;

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

    dp[0] = 0;
    dp[1] = abs(tab[1] - tab[0]);

    for (int i = 2; i < min(n, k); i++) {
        dp[i] = abs(tab[i] - tab[i - 2]);
    }


    for (int i = 2; i < n; i++) {
        dp[i] = dp[i - 1] + abs(tab[i] - tab[i - 1]);
        for (int j = i - 2; j >= max(0, i - k); j--) {
            dp[i] = min(dp[j] + abs(tab[i] - tab[j]), dp[i]);
        }
    }

    cout << dp[n - 1] << "\n";
}


Measured memory_bytes: 1024
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
F = gets.split.map(&:to_i).sort.reverse
AF = A.zip(F).sort_by{|a,b| a * b }
M = AF[-1][0] * AF[-1][1]

ans = (0 .. M).bsearch do |t|
  i = AF.bsearch_index {|ab| ab[0] * ab[1] > t } || N
  k_ = (i ... N).inject(0){|sum, j| sum + AF[j][0] - t / AF[j][1] }
  k_ <= K
end
puts ans

Measured memory_bytes: 45404
#include <iostream>
using namespace std;
char a[52][234];
int main(int argc, char** argv) {
	int n,m,i,j,t;
	cin >> n >> m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cin >> a[i][j];
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			t=0;
			if(a[i][j]=='.')
			{
				if(a[i-1][j]=='#')
				  t++;
				if(a[i-1][j-1]=='#')
				  t++;
				if(a[i-1][j+1]=='#')
				  t++;
				if(a[i][j+1]=='#')
				  t++;
				if(a[i][j-1]=='#')
				  t++;
				if(a[i+1][j-1]=='#')
				  t++;
				if(a[i+1][j]=='#')
				  t++;
				if(a[i+1][j+1]=='#')
				  t++;
				a[i][j]=t+'0';
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define pb push_back
int main()
{
ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;cin>>n;int vis[n+1]={0};
int a[n];
for(int i=1;i<n;i++)
{
	cin>>a[i];vis[a[i]]++;
}
for(int i=1;i<=n;i++)
{
	cout<<vis[i]<<"\n";
}
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define prin(a) cout<<a<<"\n"
#define kaigyo cout<<"\n"
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)
#define mem(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,-1,sizeof(x))
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<string> vst;
typedef vector<char> vc;
typedef vector<long double> vd;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
typedef vector<vector<int>> vint2;
ll mod=1e9+7;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;
#define int3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define int4(x,y,z,w) int x,y,z,w;cin>>x>>y>>z>>w;
#define ll1(x) ll x;cin>>x;
#define ll2(x,y) ll x,y;cin>>x>>y;
#define vint1(a,n) vint a(n);rep(i,n)cin>>a[i];
#define vint2(a,b,n) vint a(n),b(n);rep(i,n)cin>>a[i]>>b[i];
#define vll1(a,n) vll a(n);rep(i,n)cin>>a[i];
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

const double pi=acos(-1.0);
const ll inf=1LL<<60;


bool isPrime(ll n){if(n<2)return false;for(ll x = 2;
x*x <=n;x++){if(n%x == 0)return false;}return true;}
ll kaizyo(ll k){ll sum=1;rep1(i,k){sum*=i;sum%=mod;}return sum;}
ll ncr(ll n,ll r){return kaizyo(n)/(kaizyo(r)*kaizyo(n-r));}
unsigned keta(unsigned num){
    return log10(num)+1;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){

int1(n);
int cnt=0;
rep1(i,n-1){
    int cn=0;
for(int j=1;j*j<i;j++){
    if(i%j==0)cn++;
}
cnt+=2*cn;
double p=sqrt(i);
if(ceil(p)==floor(p))cnt++;

}
prin(cnt);

}


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

int main(){
	int N,K;
	cin >> N >> K;

	vector<int> A(N);
	for(int i=0;i<N;i++) cin >> A[i];

	int ans;
	for (int i=1;i<N;i++){
		if(N <= K + (i-1)*(K-1)){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> cost(n - 1), start(n - 1), width(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> cost[i] >> start[i] >> width[i];
    }
    for (int i = 0; i < n; ++i) {
        int time = 0;
        for (int j = i; j < n - 1; ++j) {
            if (time <= start[j]) {
                time = start[j] + cost[j];
            } else {
                int t = (time - start[j]) / width[j];
                if ((time - start[j]) % width[j] != 0) ++t;
                time = start[j] + width[j] * t;
                time += cost[j];
            }
        }
        cout << time << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    bool a=false, b=false, c=false;
    std::string s;
    std::cin >> s;
    for(int i=0; i<3; ++i){
        if(s.at(i)=='a') a=true;
        if(s.at(i)=='b') b=true;
        if(s.at(i)=='c') c=true;
    }
    if(a*b*c) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	ll ans = 1;
	char ch = '\n';
	for(int i = 0; i<n; i++)
	{
		if(i+1<n)
		{
			if(s[i]==s[i+1])
			{
				if(i==0)
					ans = 6;
				else if(ch=='X')
					ans = ans*2%mod;
				else
					ans = ans*3%mod;
				ch = 'Y';
				i++;
			}
			else
			{
				if(i==0)
					ans = 3;
				if(ch=='X')
					ans = ans*2 %mod;
				ch = 'X';
			}
		}
		else
		{
			if(i==0)
				ans = 3;
			if(ch=='X')
				ans = ans*2 %mod;
			ch = 'X';
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256