akhauriyash/Code-Regression huggingface dataset:
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val l, r = sc.nextLong

  def loop(): Unit = {

  }

  def remainderMinimization2019(min: Long, max: Long): Long = {
    val divisor = 2019
    val startBlock = min / divisor
    val endBlock = max / divisor

    if (startBlock == endBlock) {
      if ((max - 1) * max / divisor == endBlock)
        ((min % divisor) * ((min + 1) % divisor)) % divisor
      else
        (for {
          i <- (min % divisor) to (max % divisor)
          j <- i + 1 to (max % divisor)
        } yield (i * j) % divisor).min
    }
    else //startBlock < endBlock
      ((min % divisor) * ((endBlock * divisor) % divisor)) % divisor
  }

  println(remainderMinimization2019(l, r))
}

Measured memory_bytes: 114740
#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
 
#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
LL N, K;
int bb[4010][4010];
int ww[4010][4010];
 
int bacc[4010][4010];
int wacc[4010][4010];
int bsum(int x1, int y1, int x2, int y2){
  return bacc[y2][x2] - bacc[y2][x1] - bacc[y1][x2] + bacc[y1][x1];
}
int wsum(int x1, int y1, int x2, int y2){
  return wacc[y2][x2] - wacc[y2][x1] - wacc[y1][x2] + wacc[y1][x1];
}
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  cin >> N >> K;
 
  int K2 = K * 2;
  REP(i,N){
	int x, y;
	char c;
	cin >> x >> y >> c;
	x %= K2;
	y %= K2;
	if(c == 'B'){
	  bb[y][x]++;
	  bb[y+K2][x]++;
	  bb[y][x+K2]++;
	  bb[y+K2][x+K2]++;
	}
	else{
	  ww[y][x]++;
	  ww[y+K2][x]++;
	  ww[y][x+K2]++;
	  ww[y+K2][x+K2]++;
	}
  }
 
  REP(y,K2*2) REP(x,K2*2){
	bacc[y+1][x+1] += bb[y][x] + bacc[y+1][x] + bacc[y][x+1] - bacc[y][x];
	wacc[y+1][x+1] += ww[y][x] + wacc[y+1][x] + wacc[y][x+1] - wacc[y][x];
  }
 
  int ans = 0;
  REP(y1,K2) REP(x1,K2){
	int x2 = x1 + K, y2 = y1 + K;
	int sum = bsum(x1, y1, x2, y2) + bsum(x2, y2, x2+K, y2+K);
	sum += wsum(x2, y1, x2+K, y2) + wsum(x1, y2, x2, y2+K);
 
	//cout<<x1<<","<<y1<<":"<<sum<<endl;
	maxi(ans, sum);
  }
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 251392
import kotlin.math.*

//private val inp = java.io.File("in")
private val inp = System.`in`
private val reader = inp.bufferedReader()
private val wr = java.io.PrintWriter(System.out.bufferedWriter())

private fun readLn(): String = reader.readLine()
private fun readInt(): Int = readLn().toInt()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()

fun main() {
    val n = readInt()
    val s = HashSet<String>()
    repeat(n) {
        s.add(readLn())
    }
    println(s.size)
}

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

int main(){
  int i,x,y;
  for(i=0;i<10000;i++){
    cin>>x>>y;
    if(x==0 && y==0)break;
    if(x<y){
      cout<< x <<" "<< y <<endl;
    }else{
      cout<< y <<" "<< x <<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define br cout << "\n";
#define pb push_back
#define ll long long 
#define ff first 
#define ss second
#define all(x) x.begin(),x.end()
#define in(a , idx , n ) for (int i = idx ; i < n ; ++i)cin >>a[i];
using namespace std;
const int MOD = 1000*1000*1000 + 7 ; 
const int MAXN = 1000*100 +10 ;
void solve(){
	int n ;
	cin >> n ;
	vector<int>h(n+1); 
	for(int i =  1 ; i <= n ; ++i  )
		cin >> h[i] ;
	int dp[n + 1 ];
	for (int i = 0 ; i <= n ; ++i )
		dp[i] = INT_MAX;
	dp[1] = 0 ;
	for(int i = 1 ; i <= n ; ++i )
	{
		for(int j : {1 ,2 })
		{
			if( i+j > n )continue ;
			
			dp[i+j] = min( dp[ i + j ], dp[i] + abs( h[i+j] - h[i]));  
			 
		}
	}
	cout << dp[n];
	
}
int main (){ 
	int t = 1  ;
	// cin >> t ;
	while (t--){
		solve() ; 
	}
    
return 0 ; 
}


Measured memory_bytes: 3980
package main

import "fmt"

// 5 2
// 2 3 4 5 6

// 3 0
// 0 1 2
// 3 -1
// -1 0 1
// 3 -2
// -2 -1 0
// 3 -3
// -3 -2 -1

// 3 -5
func main() {
	var N, L int
	fmt.Scan(&N, &L)
	x := 0
	if L >= 0 {
		for i := 1; i < N; i++ {
			x += L + i
		}
	} else {
		if N+L > 0 {
			for i := 0; i < N; i++ {
				x += L + i
			}
		} else {
			for i := 0; i < N-1; i++ {
				x += L + i
			}
		}
	}
	fmt.Println(x)
}


Measured memory_bytes: 512
if __name__ == '__main__':
	a,b,c = map(int, input().split())
	l = [b,c]
	if a in l:
		if b == c:
			print('No')
		else:
			print('Yes')
	else:
		if b == c:
			print('Yes')
		else:
			print('No')

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

vector<pair<ll, ll> > prime_factorize(ll N) {
  vector<pair<ll, ll> > res;
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    ll ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res.push_back(pair<ll, ll>(a, ex));
  }
  if (N != 1) res.push_back(pair<ll, ll>(N, 1));
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll max = 10000000;
  vector<ll> a(max);
  for (ll i = 0; i < max; i++) {
    a[i] = 0;
  }
  for (ll i = 1; i <= max; i++) {
    ll point = i;
    for (ll j = 1; j * point <= max; j++) {
      a[j * point]++;
    }
  }

  ll ans = 0;

  for (ll i = 1; i <= n; i++) {
    ans += i * a[i];
  }
  cout << ans << endl;
}

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

int main(){
	string s;
	cin >> s;
	
	int one = 0;
	int zero = 0;
	
	rep(i,s.size()){
		if(s[i] == '0') zero++;
		if(s[i] == '1') one++;
	}
	
	int ans = 2*min(zero, one);
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
// #include <atcoder/all>
// using namespace atcoder;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline void dump(T &v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
template <class T, class U>
inline void dump(map<T, U> &v) {
    irep(i, v) { cout << i->first << " " << i->second << '\n'; }
}
inline string getline() {
    string s;
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 61;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */


int main() {
    // int n;
    // cin>>n;
    // vvi v(n,vi(2));
    // rep(i,n)rep(j,2)cin>>v[i][j];
    // bool ch=0;
    // rep(i,n-2){
    //     if(v[i][0]!=v[i][1])continue;
    //     if(v[i+1][0]!=v[i+1][1])continue;
    //     if(v[i+2][0]!=v[i+2][1])continue;
    //     ch=1;
    // }
    // Yn(ch);
    string s;
    cin>>s;
    if(s[s.size()-1]=='s'){
        cout<<s<<"es"<<endl;
    } else {
        cout<<s<<'s'<<endl;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include<string>
using namespace std;   
int main()  
{ 
    int N,a=1;
    long long Y;
    cin>>N>>Y;
    Y=Y/1000;
    for(int i=0;i<=Y/10;i++){
        for(int j=0;j<=Y/5;j++){
        int z=N-i-j;
        if(Y==10*i+5*j+z&&z>=0){cout<<i<<" "<<j<<" "<<z<<endl;return 0;}
        }}
    if(a)cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define MOD7 1000000007LL
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}
ll llpow(ll a, ll n){ll res=1;REP(_,n){res*=a;}return res;}

int main(){
    string s;
    cin >> s;
    bool flag = false;
    REP(i, 3){
        if(s[i] == '7'){
            flag = true;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll h,w,x,y;
  cin >> h >> w;
  string s[h];
  ll a[60][60]={};
  for(int i=0;i<h;i++){
    cin >> s[i];
    for(int j=0;j<w;j++){
      if(s[i][j]=='.') continue;
      for(int nx=-1;nx<=1;nx++){
        for(int ny=-1;ny<=1;ny++){
          x = i+nx;
          y = j+ny;
          if(x>=0&&y>=0&&nx<h&&ny<w){
            a[x][y]++;
          }
        }
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#') cout <<s[i][j];
      else cout << a[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            long X = long.Parse(Console.ReadLine());

            int A = 0;
            int B = 0;
            if (X == 0)
            {
                Console.WriteLine("0 0");
                return;
            }
            var list = new List<long>();
            var listB = new List<long>();
            for(long i = -6208; i <= 6208; i++)
            {
                listB.Add(X - Power5(i));
                list.Add(Power5(i));
            }

            for(int j = 0; j <= 6208; j++ )
            {
                for(int i = -6208; i < 6208; i++)
                {
                    if(listB[j + 6208] == -list[i + 6208])
                    {
                        A = j;
                        B = i;
                        goto LOOPEND;
                    }
                }
            }
        LOOPEND:;

            Console.WriteLine("{0} {1}", A, B);
        }

        static long Power5(long n)
        {
            return n * n * n * n * n;
        }
    }

    
}


Measured memory_bytes: 28284
#include <iostream>

using namespace std;

int main(){
	int pay=0,coin=0;
	while(cin>>pay,pay){
		coin=0;
	pay=1000-pay;
	if(pay/500>=1){
		pay-=500;
		coin++;
	}
	if(pay>=100){
		coin+=pay/100;
		pay-=100*(pay/100);
	}
	if(pay>=50){
		coin+=pay/50;
		pay-=50*(pay/50);
	}
	if(pay>=10){
		coin+=pay/10;
		pay-=10*(pay/10);
	}
	if(pay>=5){
		coin+=pay/5;
		pay-=5*(pay/5);
	}
	if(pay>=1){
		coin+=pay;
	}
	cout<<coin<<endl;
}
}

Measured memory_bytes: 1160
import numpy as np

h, w = list(map(int, input().split()))
d = {".":1, "#":0}
ss = np.array([list(input()) for _ in range(h)]) == "."
ss_t = ss.transpose()

ls, rs, us, ds = [np.zeros((h, w), dtype=int) for _ in range(4)]

ls, rs = ls.transpose(), rs.transpose()

ls[0] = ss_t[0]
rs[w-1] = ss_t[w-1]
us[0] = ss[0]
ds[h-1] = ss[h-1]

for i in range(1, w):
	ls[i] = ss_t[i] * (ls[i - 1] + 1)

for i in reversed(range(w - 1)):
	rs[i] = ss_t[i] * (rs[i + 1] + 1)

for i in range(1, h):
	us[i] = ss[i] * (us[i - 1] + 1)

for i in reversed(range(h - 1)):
	ds[i] = ss[i] * (ds[i + 1] + 1)

# print(ss)
# print(ls)
# print(rs)
# print(us)
# print(ds)
print(max(np.amax((ls.transpose() + rs.transpose() + us + ds) - 3), 0))


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

using namespace std;

const int al[] = {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
                  1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0};

int main() {
  while (true) {
    string s;
    cin >> s;
    if (s == "#") break;

    bool f = al[s[0] - 'a'];
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
      if (f != al[s[i] - 'a']) {
        f = al[s[i] - 'a'];
        ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	int p[4];
	int t[4];
	for(int i=0;i<4;i++){
		cin >> p[i];
	}
	for(int i=0;i<4;i++){
		cin >> t[i];
	}
	int ans=1e9;
	for(int i=0;i<=(n+t[0]-1)/t[0];i++){
		for(int j=0;j<=max(0,(n-t[0]*i+t[1]-1)/t[1]);j++){
			for(int k=0;k<=max(0,(n-t[0]*i-t[1]*j+t[2]-1)/t[2]);k++){
				for(int l=0;l<=max(0,(n-t[0]*i-t[1]*j-t[2]*k+t[3]-1)/t[3]);l++){
					
					if(t[0]*i+t[1]*j+t[2]*k+t[3]*l<n)continue;
					ans=min(ans,p[0]*i+p[1]*j+p[2]*k+p[3]*l);
				}
			}
		}
	}
	cout << ans << endl;
}


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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int maxn=(int)(2e5+5),inf=(int)(1e9+9);

int a[maxn],dp[maxn];

struct node
{
    public:

    int idx,val;

    node(int idx,int val) : idx(idx),val(val) {}
};

struct sf
{
    bool operator()(const node& a,const node& b)
    {
        if(a.val==b.val)
        {
            return a.idx<b.idx;
        }

        return a.val<b.val;
    }
};


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

    int n,m;cin>>n>>m;

    string s1;cin>>s1;

    dp[n]=0;

    set<node,sf> s;

    s.insert(node(n,0));

    for(int i=n-1;i>=0;i--)
    {
        if(i+m+1<=n)
        {
            node nn=node(i+m+1,dp[i+m+1]);

           s.erase(s.find(nn));
        }

        if(s1[i]=='1')
        {
            dp[i]=inf;
        }

        else
        {
            node x=*(s.begin());

            dp[i]=min(inf,x.val+1);
        }

        node new_node=node(i,dp[i]);

        s.insert(new_node);
    }

    if(dp[0]<inf)
    {
        vector<int> v,first(dp[0]+1,inf);

        for(int i=0;i<=n;i++)
        {
            if(dp[i]<inf)
            {
                first[dp[i]]=min(first[dp[i]],i);
            }
        }

        int prev=0;

        for(int i=dp[0]-1;i>=0;i--)
        {
            v.pb(first[i]-prev);

            prev=first[i];
        }

        for(int i=0;i<v.size();i++)
        {
            cout<<v[i]<<" ";
        }

        cout<<endl;
    }

    else
    {
        cout<<(-1)<<endl;
    }

    return 0;

}

Measured memory_bytes: 5248
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    ls = [1, 2, 3, 5]
    X, N = input_number_list()
    P = input_number_list()
    if P.count(X) == 0:
        print(X)
        return
    d = 1
    while True:
        if P.count(X - d) == 0:
            print(X - d)
            break
        elif P.count(X + d) == 0:
            print(X + d)
            break
        d += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for(int i = a; i <= b; i++){
    if(i%k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  print("NG");

}


Measured memory_bytes: 3620
fn read<T: std::str::FromStr>() -> Vec<T>
where
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).unwrap();
    b.split_whitespace()
        .map(|x| x.trim().parse::<T>().unwrap())
        .collect()
}

fn main() {
    let _ = read::<i64>()[0];
    let ai = read::<i64>();

    let mut ans = (ai[0], -ai[0]);

    for x in 1..ai.len() {
        let a = ai[x];
        ans = (
            std::cmp::max(ans.0 + a, ans.1 - a),
            std::cmp::max(ans.0 - a, ans.1 + a),
        )
    }

    println!("{}", ans.0)
}


Measured memory_bytes: 8444
#include <stdio.h>
#include <stdlib.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
if(abs(b-a)>=1&&a>b) printf("%d",a+(a-1));
else if(abs(b-a)>=1&&b>a) printf("%d",b+(b-1));
else if(abs(b-a)==0) printf("%d",a+b);

return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int a, b;
  cin >>a >> b;

  if (a <= 5) {
    cout << 0 << endl;
  }
  else if (6 <= a && a <= 12) {
    cout << b / 2 << endl;
  } else {
    cout << b << endl;
  }
  return 0;
}



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

int main(void){
    int X,A,B;
    cin>>X>>A>>B;
    if (B<=A) {
        cout<<"delicious"<<endl;
    }
    else if (B-A<=X) {
        cout<<"safe"<<endl;
    }
    else {
        cout<<"dangerous"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	static int n, m;
	static int[][] memo;
	static char[][] a;
	static boolean[][] visited;

	static int solve(int i, int j) {

		if (i >= n || j >= m || a[i][j] == '#')
			return 0;

		if (i == n - 1 && j == m - 1)
			return 1;

		if (visited[i][j])
			return memo[i][j];

		visited[i][j] = true;

		int x = solve(i + 1, j);
		int y = solve(i, j + 1);

		return memo[i][j] = ((x + y) % ((int) 1e9 + 7));
	}

	public static void main(String[] args) throws NumberFormatException, IOException {

		n = input.nextInt();
		m = input.nextInt();

		a = new char[n][m];

		memo = new int[n + 10][m + 10];
		visited = new boolean[n + 10][m + 10];

		for (int i = 0; i < n; i++) {
			a[i] = input.nextLine().toCharArray();
		}

		System.out.println(solve(0, 0));

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}
}


Measured memory_bytes: 35724
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t n;
	int answer = 0;
	if (scanf("%"SCNu64, &n) != 1) return 1;
	while (n > 0) {
		answer++;
		n >>= 1;
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
      ll l1,l2;
      string s1,s2;
      cin>>s1>>s2;
      l1=s1.length();
      l2=s2.length();
      int dp[l1+1][l2+1];
      for(int i=0;i<=l1;i++)
         dp[i][0]=0;
      for(int i=0;i<=l2;i++)
         dp[0][i]=0; 
         
        for(int i=1;i<=l1;i++){
          for(int j=1;j<=l2;j++){
              if(s1[i-1]==s2[j-1])dp[i][j]=1+dp[i-1][j-1];
              else{
                  int a= dp[i-1][j-1];
                  int b= dp[i-1][j];
                  int c= dp[i][j-1];
                  dp[i][j]=max(a,max(b,c));
                }
            }
        } 
        //  cout<<dp[l1][l2]<<endl;
        //  for(int i=1;i<=l1;i++){
        //   for(int j=1;j<=l2;j++)
        //   cout<<dp[i][j]<<" ";
        //   cout<<endl;
        //  }
         
         
        if(dp[l1][l2]==0)cout<<"";
        else{
        	vector<char>vv;
            ll a=l1,b=l2;
	        while(a>=0 && b>=0){
	        	if(dp[a][b]==dp[a-1][b])a--;
	        	else if(dp[a][b]==dp[a][b-1])b--;
	        	else{
	        	  vv.push_back(s2[b-1]);
	        	  a--,b--;
	        	} 
	        }

	        for(auto it=vv.rbegin();it!=vv.rend();it++)
	        	cout<<*it;
        }
        
  return 0;
  }      

Measured memory_bytes: 35456
#include<stdio.h>

int main(void) {
	int N, K, Q,  i, flg;
	scanf("%d %d %d", &N, &K, &Q);
	int a[Q];

	int member[N];
	for (i = 0; i < N; i++) {
		member[i] = 0;
	}

	for (i = 0; i < Q; i++) {
		scanf("%d", &a[i]);
		member[a[i] - 1]+=1;
	}

	for (i = 0; i < N; i++) {
		if ((K - Q + member[i]) > 0)printf("Yes\n");
		else printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5) ? "Yes" : "No");
        sc.close();

    }

}


Measured memory_bytes: 21844
n = int(input())
H = list(map(int, input().split()))
H[0] -= 1
ans = 0

for i in range(n-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    if H[i] > H[i+1]:
        ans = 1
        break

if ans == 0:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

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

using namespace std;

int w,h;
int F[505][505];

bool can(int y,int x) {
    if(0 <= y && y < h && 0 <= x && x < w) return true;
    return false;
}

int func(int y,int t,int x,int s) {
    int ret = 0;
    REP(i,y,y+t) {
        REP(j,x,x+s) {
            if(can(i,j)) {
                if(F[i][j]) ret++;
            }
            else return 0;
        }
    }

    return ret;
}

int main()
{
    int n;
    while(cin >> n && n)
    {
        cin >> w >> h;
        memset(F,0,sizeof(F));

        rep(i,n) {
            int x,y;
            cin >> x >> y;
            
            x--;
            y--;

            F[y][x]++;
        }

        int s,t;
        cin >> s >> t;

        int ans = 0;
        rep(i,h) {
            rep(j,w) {
                ans = max(ans,func(i,t,j,s));
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
lld arr[222];
lld base[61];
int main(void){
	int t;
	scanf("%d",&t);
	while(t--){
		memset(base,0,sizeof(base));
		int n;
		scanf("%d",&n);
		for(int e=0;e<n;e++) scanf("%lld",&arr[e]);
		string s;
		cin >> s;
		int err = 0;
		for(int e=n-1;e>=0;e--){
			if(s[e]=='1'){
				for(int p=60;p>=0;p--){
					if(arr[e]&(1ll<<p)){
						arr[e] ^= base[p];
					}
				}
				if(arr[e]) err = 1;
			}else{
				for(int p=60;p>=0;p--){
					if(arr[e]&(1ll<<p)){
						if(base[p]==0) base[p] = arr[e];
						arr[e] ^= base[p]; 
					}
				}
			}
		}
		printf("%d\n",err);
	}
	return 0;
}


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

int main(){
	int N, Q, M, date;
	while( cin >> N >> Q , N || Q ){
		int d[100] = {0};

		for(int i=0 ; i < N ; i++ ){
			cin >> M;
			for(int j=0 ; j < M ; j++ ){
				cin >> date;
				d[date]++;
			}
		}
		int max_num = 0;
		int ans_d;
		for(int i=0 ; i < 100 ; i++ ){
			max_num = max( max_num , d[i] );
		}
		for(int i=100 ; i >= 0 ; i-- ){
			if( d[i] == max_num )
				ans_d = i;
		}
		if( max_num >= Q )
			cout << ans_d << endl;
		else
			cout << 0 << endl;
	}
}

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

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

	int a,b,c;
	cin>>a>>b>>c;
	if( a + b + c >= 22 ){ cout<<"bust\n"; }
	else{ cout<<"win\n"; } 

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  bool b=true;
  char c=a.at(2),d=a.at(3),e=a[4],f=a[5];
  if((c!=d)||(e!=f))b=false;
  if(b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int sum = 0;
		int sumB = 0;
		for(int i = 0; i < N; i++){
			char c = S[i];
			if(c == 'a'){
				if(sum < A + B){
					System.out.println("Yes");
					sum++;
				}else{
					System.out.println("No");
				}
			}
			
			if(c == 'b'){
				sumB++;
				if(sum < A + B && sumB <= B){
					System.out.println("Yes");
					sum++;
				}else{
					System.out.println("No");
				}
			}
			
			if(c == 'c'){
				System.out.println("No");
			}
		}
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    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: 33924
#include <bits/stdc++.h>

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

using namespace std;
using lint=long long;

int main(){
	lint x0,k,d; cin>>x0>>k>>d;
	x0=abs(x0);

	if(x0/d>=k){
		cout<<x0-k*d<<'\n';
	}
	else if(x0/d%2==k%2){
		cout<<x0%d<<'\n';
	}
	else{
		cout<<d-x0%d<<'\n';
	}

	return 0;
}


Measured memory_bytes: 3636
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,a+r+r*(.5+3**.5*.5j),b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5916
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

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

using namespace std;

const long long MOD = 998244353;

template<typename T>
constexpr T gcd(T m, T n) noexcept {
	T g = 1;

	while (m != 0) {
		if (m < n) swap(m, n);

		if (m & 1) {
			if (n & 1) m = (m - n) >> 1;
			else n = n >> 1;
		}
		else {
			if (n & 1) {
				m = m >> 1;
			}
			else {
				n = n >> 1;
				m = m >> 1;
				g = g << 1;
			}
		}
	}

	return g * n;
}

template<typename T>
constexpr std::vector<std::pair<T, T>> primeFactorization(T number) noexcept {
	std::vector<std::pair<T, T>> primeFactors;
	T quotient = number;
	for (T i = 2; i * i <= quotient; ++i) {
		if (quotient % i == 0) {
			T prime = i, power = 1;

			quotient /= i;
			while (quotient % i == 0) {
				++power;
				quotient /= i;
			}

			primeFactors.push_back(std::pair<T, T>(prime, power));
		}
	}
	if (quotient != 1) primeFactors.push_back(std::pair<T, T>(quotient, 1));

	return primeFactors;
}

template<typename T>
constexpr int countDivisor(std::vector<std::pair<T, T>> primeFactors) noexcept {
	int counter = 1;
	for (int i = 0; i < primeFactors.size(); ++i) {
		counter *= (primeFactors[i].second + 1);
	}

	return counter;
}

template<typename T>
constexpr std::vector<T> findDivisor(T number) noexcept {
	std::vector<std::pair<T, T>> primeFactors = primeFactorization(number);

	std::vector<T> divisor(countDivisor(primeFactors));
	divisor[0] = 1;

	int counter = 1;
	for (int i = 0; i < primeFactors.size(); ++i) {
		int currentSize = counter;
		for (int j = 1; j <= primeFactors[i].second; ++j) {
			T x = 1;
			for (int k = 0; k < j; ++k) {
				x *= primeFactors[i].first;
			}

			for (int k = 0; k < currentSize; ++k) {
				divisor[counter + k] = divisor[k] * x;
			}
			counter += currentSize;
		}
	}
	sort(divisor.begin(), divisor.end());

	return divisor;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, k;
	cin >> a >> b >> k;

	vector<int> divisor = findDivisor(gcd(a, b));
	cout << divisor[divisor.size() - k];

	return 0;
}


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

int a[101];

int main(){
	int n,s=0,i;
	cin>>n;
	
	for(i=1;i<=n;i++){
		int x;
		cin>>x;
		
		a[x]=1;
	}
	
	for(i=1;i<=100;i++){
		s+=a[i];
	}
	cout<<s<<endl;
	
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if ((b - 1) % (a - 1) == 0) {
		cout << (b - 1) / (a - 1) << endl;
		return 0;
	}
	cout << (b - 1) / (a - 1) + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	UL p = 1;

	deque<UL> ans;
	deque<UL> ans2;

	void Solve2(ULL N) {
		if (N == 1) { ans = ans2 = {}; return; }
		Solve2(N / 2);
		ans.push_back(p); ans2.push_back(p); p++;
		if (N % 2) { ans.push_front(p); ans2.push_back(p); p++; }
	}

	void Solve() {
		ULL N; cin >> N;
		Solve2(N + 1);

		cout << ans.size() + ans2.size() << endl;
		rep(i, ans.size()) {
			if (i) cout << " ";
			cout << ans[i];
		}
		rep(i, ans2.size()) {
			cout << " ";
			cout << ans2[i];
		} cout << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
a[2],b[2],c[2],d[2];
main()
{
  int l,r,i;
  float e[2];
  while(~scanf("%f%f",&e[0],&e[1]))
    {
      for(i=0;i<2;i++)
	{
	if(e[i]>=1.1)
	  a[i]++;
	else if(e[i]>=0.6)
	  b[i]++;
	else if(e[i]>=0.2)
	  c[i]++;
	else
	  d[i]++;
	}
    }
  printf("%d %d\n%d %d\n%d %d\n%d %d\n",a[0],a[1],b[0],b[1],c[0],c[1],d[0],d[1]);
	  exit(0);
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  string s, t;
  int a, b;
  string u;
  cin >> s >> t >> a >> b >> u;
  if(u == s) cout << a-1 << " " << b << endl;
  else cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 3596
def main():

    n = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    start = 1
    for i in range(len(A)):
        if A[i] != start:
            cnt += 1
        else:
            start += 1

    if len(A) != cnt:
        print(cnt)
    else:
        print("-1")

if __name__ == "__main__":
    main()

Measured memory_bytes: 24744
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int gcd(int a, int b)
{
  if (b == 0)
    return a;

  return gcd(b, a % b);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A[111111], a[111111], b[111111];

  std::cin >> N;

  a[0] = b[N] = 0;

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

    a[i + 1] = gcd(A[i], a[i]);
  }

  for (int i = N - 1; i >= 0; i --)
    b[i] = gcd(A[i], b[i + 1]);

  int xp = 0;

  for (int i = 0; i < N; i ++)
    xp = std::max(gcd(a[i], b[i + 1]), xp);

  std::cout << xp << std::endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
	int N,K;
	const int MAX_N = 5000;
	int a[MAX_N];
	bool dp[MAX_N];

bool C(int k){
	if(k<0) return false;
	if(k>=N) return false;
	if(a[k]>=K) return true;
	fill(dp,dp+K,false);
	dp[0]=true;
	for(int i=0;i<N;i++){
		if(i==k) continue;
		for(int j=K-1;j>=a[i];j--){
			dp[j] |= dp[j-a[i]];
		}
	}
	for(int i=K-a[k];i<K;i++){
		if(dp[i]) return true;
	}
	return false;
}

void solve(){
	sort(a,a+N);
	int lo = -1;
	int hi = N;
	while(hi-lo>1){
		int mi = (hi+lo)/2;
		if(C(mi)) hi = mi;
		else lo = mi;
	}
	printf("%d\n",hi);
}

int main(){
	cin>>N>>K;
	for(int i=0; i<N; i++){
		cin>>a[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int k,x;
    cin>>k>>x;
    REP(i,x-k+1,x)cout<<i<<endl;
    cout<<x<<endl;
    REP(i,x+1,x+k)cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define rep(i,n)Rep(i,0,n)
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
typedef long long ll;
typedef long double ld;

int cmp(const void* a, const void* b){
    return (*(char*)b - *(char*)a);
}

int main(){
    int n;
    ll ans = 0, c = 0;
    char s[100001][11];
    scanf("%d", &n);
    rep(i,n){
        scanf("%s", s[i]);
        qsort(s[i], 10, sizeof(char), cmp);
    }
    qsort(s, n, sizeof(char) * 11, strcmp);
    Rep(i,1,n)
        if (strcmp(s[i], s[i - 1]) == 0){ c++; ans += c;}
        else { c = 0; }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2300
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n, k = map(int, input().split())
s = input()
for i in range(n):
    print(chr(ord(s[i]) - ord('A') + ord('a')), end='') \
        if i == k - 1 else print(s[i], end='')
print('')

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
//#define TEST

struct uuu{
    string s;
    int i;
    int p;
    bool operator < (const uuu& o) const {
        if (s == o.s)
            return p > o.p;
        return s < o.s;
    }
};


int main(int argc, char** argv) {
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    int N;
    cin >> N;
    vector<uuu> v(N);
    FOR(i, N){
        cin >> v[i].s >> v[i].p;
        v[i].i = i+1;
    }
    sort(v.begin(), v.end());
    FOR(i, N){
        cout << v[i].i << '\n';
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)
        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	ll mx = -INF ;
	ll mn = INF ;
	ll px,pn ;
	for(int i=0;i<n;i++){
		cin >> a.at(i) ;
		if(mx<a.at(i)) mx=a.at(i),px=i+1 ;
		if(mn>a.at(i)) mn=a.at(i),pn=i+1 ;
	}
	if(mn>=0){
		cout << n-1 << endl ;
		for(int i=2;i<=n;i++) cout << i-1 << " " << i << endl ;
		return 0 ;
	}
	if(mx<=0){
		cout << n-1 << endl ;
		for(int i=n-1;i>=1;i--)	cout << i+1 << " " << i << endl ;
		return 0 ;
	}
	if(mx>=abs(mn)){
		ll cnt = 0 ;
		for(int i=0;i<n;i++) if(a.at(i)<0) cnt++ ;
		cout << cnt+n-1 << endl ;
		for(int i=0;i<n;i++) if(a.at(i)<0) cout << px << " " << i+1 << endl ;
		for(int i=2;i<=n;i++) cout << i-1 << " " << i << endl ;
		return 0 ;
	}
	if(mx<=abs(mn)){
		ll cnt = 0 ;
		for(int i=0;i<n;i++) if(a.at(i)>0) cnt++ ;
		cout << cnt+n-1 << endl ;
		for(int i=0;i<n;i++) if(a.at(i)>0) cout << pn << " " << i+1 << endl ;
		for(int i=n-1;i>=1;i--) cout << i+1 << " " << i << endl ;
		return 0 ;
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

a = []
f = []
n = 0

def rec(l, r, k):
    if l+1 < r:
        mid = (l + r) // 2
        s = 0
        for i in range(n):
            s += max(a[i] - mid // f[i], 0)
        if s <= k:
            return rec(l, mid, k)
        else:
            return rec(mid, r, k)
    else:
        return r

def main():
    global a, f, n
    n, k = map(int, input().strip().split())
    a = list(map(int, input().strip().split()))
    f = list(map(int, input().strip().split()))
    a = sorted(a)
    f = sorted(f, reverse=True)
    print(rec(-1, 10**12, k))

if __name__ == '__main__':
    main()


Measured memory_bytes: 113152