akhauriyash/Code-Regression huggingface dataset:
//37
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main(){
  string a,b;
  int k;
  cin>>a>>b>>k;
  b=string(a.size()-b.size(),'0')+b;
  string r;
  for(int i=0;i<1<<a.size();i++){
    int bt=0,ic=i;
    while(ic){
      bt++;
      ic=ic&ic-1;
    }
    if(bt<=k){
      int c=0;
      string cr(a.size(),' ');
      for(int j=a.size()-1;j>=0;j--){
	c=c&&!(i>>j&1);
	if(a[j]-c>=b[j]){
	  cr[j]=a[j]-c-b[j]+'0';
	  c=0;
	}else{
	  cr[j]=a[j]-c-b[j]+10+'0';
	  c=1;
	}
      }
      if(r<cr){
	r=cr;
      }
    }
  }
  cout<<atoi(r.c_str())<<endl;
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

bool is_success_training(long long K, long long sum_before, long long target_time, vector<long long> A, vector<long long> F) {
    long long sum_after = 0;
    for (long long i = 0; i < A.size(); i++) {
        sum_after += min(A[i], target_time / F[i]);
    }
    return sum_before - sum_after <= K;
}

int main() {
    long long N, K; cin >> N >> K;
    vector<long long> A(N), F(N);
    long long sum_before = 0;
    for (long long i = 0; i < N; i++) {
        cin >> A[i];
        sum_before += A[i];
    }
    for (long long i = 0; i < N; i++) {
        cin >> F[i];
    }
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<long long>());
    long long left = -1, right = pow(10, 12), center;
    while (left + 1 < right) {
        center = (left + right) / 2;
        if (is_success_training(K, sum_before, center, A, F)) {
            right = center;
        } else {
            left = center;
        }
    }
    cout << right << endl;
    return 0;
}


Measured memory_bytes: 6552
#include <bits/stdc++.h>
 
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
 
using namespace std;
 
typedef long long llong;
typedef unsigned long long ullong;
 
const int MXN = (int)2e5 + 7; 
const int MOD = 998244353; 
const llong INF = (llong)1e18 + 7;
 
inline void boost(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int n, a[MXN], ans[MXN], c[MXN], w;
bool dp[MXN];

int main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> w; 
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> c[i];
	}
	for(int j = 1e5; j >= 1; j--){
		ans[j] = MOD;
	}
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1e5; j >= 0; j--){
			if(dp[j] && ans[j] + a[i] <= w){
				dp[j + c[i]] = 1;
				ans[j + c[i]] = min(ans[j] + a[i], ans[j + c[i]]);
			}
		}
	}
	for(int j = 1e5; j >= 0; j--){
		if(dp[j]) return cout << j, 0;
	}
	return 0;	
}

Measured memory_bytes: 768
def main():
    n = int(input())
    D = list(map(int,input().split()))
    D.sort()

    T = [0]
    ans = 24
    for i,d in enumerate(D):
        if i%2 == 0:
            t = d
        else:
            t = 24 - d
        T.append(t)

    T.sort()
    MIN = 24
    for i in range(n):
        diff = T[i+1] - T[i]
        MIN = min(diff,MIN)

    print(MIN)

main()

Measured memory_bytes: 9140
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//19234567892927;
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar){sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int k;cin>>k;
	vector<int>ans(k,9999999);
	deque<pair<int,int>>que;//tourist
	que.puf(mp(1,1));
	while(-1){
		int di=que.front().fir;
		int now=que.front().sec;
		que.pof();
		if(ans[now]<=di){continue;}
		ans[now]=di;
		if(now==0){cout<<di<<endl;return 0;}
		que.puf(mp(di,(now*10)%k));
		que.pub(mp(di+1,(now+1)%k));
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int n;
	cin>>n;
	int a=0,x=0;
	range(i,1,1000000){
	    a+=i;
	    if(a>=n){
	        x=i;
	        break;
	    }
	}
	range(i,1,x+1){
	    if(i!=a-n)cout<<i<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;

int memo[110000];
int rec(int N){
  if (N == 0) return 0;
  if (memo[N] != -1) return memo[N];

  int res = N;
  for(int i=1; i <= N;i*=6){
    res = min(res, rec(N - i)+1);
  }
  for(int i=1; i <= N;i*=9){
    res = min(res, rec(N - i)+1);
  }

  return memo[N] = res;
}
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  for(int i=0;i < 110000;i++){
    memo[i] = -1;
  }
  cout << rec(n) << endl;
}

Measured memory_bytes: 3840
#include"bits/stdc++.h"
using namespace std;

void seiri(int a[], int n);

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

void seiri(int a[], int n) {
	int  v, j;
	for (int i = 0; i < n; i++) {
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int k = 0; k < n-1; k++) {
			cout << a[k] << ' ';
		}
		cout <<a[n-1]<< endl;
	}
}


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

int unhappy_num(int n, char *head)
{
    char *temp=head;
    if (++temp==NULL) return 0;
    int MAX=0,i,j;
    for(i=0,j=1;j<n;i++,j++)
    {
        if(head[i]==head[j]) MAX++;
    }
    return n-MAX;
}

int main()
{
    int N;  //队列长度
    int K;  //可操作的次数介于[0,K]之间
    int i,MAX=0;
    cin>>N>>K;
    char *s=new char[N];
    for(i=0;i<N;i++)
        cin>>s[i];
    MAX=N-unhappy_num(N,s); //当前happy人数
    if(unhappy_num(N,s)<=K*2) //每次都能是happy人数+2
        MAX=N-1;   //最后只有一个人unhappy
    else
        MAX+=K*2;
    cout<<MAX;
    return 0;
}

Measured memory_bytes: 384
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int ac=0, wa=0, tle=0, re= 0;
            for(int i=0; i < n; i++)
            {
                string s = Console.ReadLine();
                switch (s)
                {
                    case "AC":
                        ac++;
                        break;
                    case "WA":
                        wa++;
                        break;
                    case "TLE":
                        tle++;
                        break;
                    case "RE":
                        re++;
                        break;
                }
            }
            Console.WriteLine("AC x " + ac);
            Console.WriteLine("WA x " + wa);
            Console.WriteLine("TLE x " + tle);
            Console.WriteLine("RE x " + re);
        }
    }
}


Measured memory_bytes: 30692
N, K = map(int, input().split())
mod = 10**9 + 7
cnt = [0]*(K+1)
ans = 0
for g in range(K, 0, -1):
    sub = sum(cnt[2*g:K+1:g])
    q = pow(K//g, N, mod) - sub
    ans = (ans + g * q) % mod
    cnt[g] = q
print(ans)


Measured memory_bytes: 11988
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
const int MaxN = 1000;
const int xx[] = {0, 0, 0, -1, 1};  //15-16行：15与16行定义坐标。作用：在第36与37行,将nxt的x和y坐标向前后左右移动。
const int yy[] = {0, 1, -1, 0, 0};  //理解：当读入这2个数组时，i都相同，所以就相当于对x和y执行了(x+0,y+0),(x+0,y+1),(x+0,y-1),(x-1,y+0),(x+1,y+0)

struct Point{                       //定义结构体， 该结构体含有3个变量，x和y可以理解为坐标,t是原点到该位置所移动的步数。
	int x, y, v;
};

Point que[MaxN * MaxN + 5];     //定义Point型变量结构que,该变量为 队列（重点重点重点）定义的长度为题目中矩阵的元素个数MaxN行MaxN列(+5防止溢出)。
Point S, T;                     //定义Point型变量结构S,T。 S：起点。T：终点。
char a[MaxN +5][MaxN + 5];      //定义二维数组 ，用来表示地图。
bool vis[MaxN + 5][MaxN + 5];   //定义二维数组，用来标记地图中每个元素是否被访问过。
int n, m, ans,tnt;                  //地图n行，m列。ans：统计最短路径的步数。

void Bfs(){
	int head = 1, tail = 0;     //定义队列的头指针(head)和尾指针(tail).用来标记当前队列元素状况，以及判定队列是否为空，应不应该结束运行。
	que[++tail] = S;            //接上-tail小于head 并且++tail：读入起点坐标，并将尾指针后移一位。当tail=head时，标识当前队列只存在一个元素。
	vis[S.x][S.y] = true;       //将起点标记，以免后面重新搜索到改点。
	Point now, nxt;             //定义2个Point型变量结构。now:表示当前所在位置及步数。nxt:表示下一次移动的位置及步数。
	while(head <= tail){        //如果队列不为空，则执行while循环。  head=tail:只有一个元素。head<tail:队列有tail-head+1个元素。
		now = que[head]; head++;     //读入队列当前第一个坐标。并且head后移：将当前now表示的坐标移出队列，因为该坐标不等于答案并且已经完成作用。
		for(int i = 1; i <= 4; i++){ //35-37行：将当前位置的前后左右搜索一遍。进行38-45行的处理。
			nxt.x = now.x + xx[i];
			nxt.y = now.y + yy[i];
			if(nxt.x < 1 || nxt.x > n || nxt.y < 1 || nxt.y > m) continue;  //判断当前位置的前后左右是否超出地图边界。超出就跳过，进行下一次循环
			if(vis[nxt.x][nxt.y] || a[nxt.x][nxt.y] == '#') continue;       //判断当前位置是否被搜索过(vis标记)，已及当前位置是不是墙，能不能走。
			nxt.v = now.v + 1;                    //如果前面条件均满足，则将该位置的步数记录(到达该位置的步数等于上一个点的步数加一)
			que[++tail] = nxt;                    //尾指针后移，并将该位置进入队列。准备之后对该位置的周围进行搜索。
			vis[nxt.x][nxt.y] = true;             //标记该位置，表示已经搜索过，之后不再进行搜索。
			if(nxt.x == T.x && nxt.y == T.y){     //判断该位置是否为终点。
				ans = nxt.v;                      //由于该题只要最少步数，故只统计到终点所需要的步数。
				return;							  //因为找到了答案了，故结束当前函数。
			}
		}
	}
}

int main()
{
	scanf("%d %d", &n, &m);                              //读入地图长宽
//	for(int i = 1; i <= n; i++) scanf("%s", a[i] + 1);	 //读入地图元素
/*	for(int i = 1; i <= n; i++){                         //55-59行：遍历地图，找到起点和终点。用S和T标记。
		for(int j = 1; j <= m; j++){                     
			if(a[i][j] == 'S') S.x = i, S.y = j;
			else if(a[i][j] == 'T') T.x = i, T.y = j;
		}
	}
*/
	for(int i = 1 ; i<= n ; i++){
		for(int j = 1 ; j<= m;j++){
			cin >> a[i][j];
			if(a[i][j] == '#'){
				tnt++;
			}
		}
	}
	S.x = 1;
	S.y = 1;
	T.x = n;
	T.y = m;

	Bfs();                                               //执行bfs搜索
	if(ans == 0 ){cout << -1 << endl;return 0;}
	ans++;
	cout << (n * m - ans - tnt) << endl;
    return 0;                                            //程序终于结束啦。。。。。。。。。。。。。哈哈哈哈哈哈哈
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int mod=1e9+7;
inline long long modMul(long long a,long long b) {
    return((a%mod)*(b%mod))%mod;
}
inline long long modAdd(long a,long b) {
    return((a%mod)+(b%mod))%mod;
}
int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long n;
    long long ans=0;
    cin>>n;
    vector<long long>v(n);
    for(long long i=0;i<n;i++) cin>>v[i];
    for(long long i=0;i<60LL;i++) {
        long long cnt1=0,cnt0=0;
        for(auto &mask:v) {
            if(mask>>i&1)
                cnt1++;
            else
                cnt0++;
        }
        long long total=1LL*cnt0*cnt1;
        long long temp=modMul(total,(1LL<<i));
        ans=modAdd(ans,temp);     
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
def cf(A,B):
    l=[]
    for i in range(1,min(A,B)+1):
        if A % i == 0 and B % i == 0:
            l.append(i)
    return l

def main():
    A, B, K = map(int,input().split())
    koyaku = cf(A,B)
    #print(koyaku)
    print(koyaku[-K])
    
if __name__ == '__main__':
    main()

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

int main() {
int n;
cin >> n;
int a[n];

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

bool loop = true;
int count = 0;
while(loop){
  for(int i = 0; i < n;i++){
    if(a[i]%2 != 0){
      loop = false;
      cout << count <<endl;
      return 0;
    }
    a[i] /= 2;
   // count++;

  }
count++;
}

cout << count <<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

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

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	K := sc.nextInt()

	fmt.Fprintln(wtr, N[K-1])
}


Measured memory_bytes: 640
while true   
    h,w=gets.split.map{|a| a.to_i}  
    break if h==0 && w==0   
    a="#"*w    
    b="#"+"."*(w-2)+"#" 
    puts a    
    (h-2).times{         puts b     } 
    puts a
    puts
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    string s;
    cin>>s;
    int c=-1,f=-1;
    rep(i,s.size()){
        if(s[i]=='C'){
            c=i;
        }else if(s[i]=='F'){
            f=i;
        }

        if(c<f&&c>=0&&f>=0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    V = list(map(float, INPUT().split()))
    V.sort(reverse=True)

    for i in range(N-1):
        a = V.pop()
        b = V.pop()
        V.append((a + b)/2)

    print(V[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        int count = 0;
        for (int i = 0;i < 3;i++){
            if (s.charAt(i) == t.charAt(i)){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22740
N = int(input())
t = [0] * N
x = [0] * N
y = [0] * N
 
for i in range(N):
    t[i], x[i] ,y[i]=map (int, input().split(' '))
 
 
 
ox = 0 
oy = 0
ot =0
 
for i in range(N):
    dt=t[i] - ot 
 
    d = abs(ox - x[i]) + abs(oy - y[i])
    if dt - d < 0:
        print('No')
        exit()
 
    if (dt-d)%2 > 0:
        print('No')
        exit()
 
    ox=x[i]
    oy=y[i]
    ot=t[i]
 
print('Yes')

Measured memory_bytes: 11636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
const long mod=998244353;
const long N=1e5+5;
int size[N];
int Arr[N];
int power[N];




int main()
{
 
       

      set<string> s;
      int n;
      cin >>n;
      rep(i,0,n)
      {
        string s1;
        cin >> s1;
        s.insert(s1);
      }
      cout <<s.size();
    

     return 0;
}
 

Measured memory_bytes: 19116
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, K = map(int, input().split())
A = list(map(int, input().split()))

acc = [0] * (N + 1)
for i in range(1, N + 1):
    acc[i] = acc[i - 1] + A[i - 1]
    acc[i] %= K
for i in range(0, N + 1):
    acc[i] -= i
    acc[i] %= K

mp = defaultdict(int)
ans = 0
for j in range(N + 1):
    if j >= K:
        mp[acc[j - K]] -= 1
    ans += mp[acc[j]]
    mp[acc[j]] += 1
print(ans)

Measured memory_bytes: 130564
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
ll n, a, b;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> n >> a >> b;

	if (abs(a - b) % 2 == 0) {
		cout << abs(a - b) / 2 << endl;
	}
	else {
		ll ans = 1e18;
		chmin(ans, n - b + 1 + (n - (a + n - b + 1)) / 2);
		chmin(ans, a+(b-a-1)/2);
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
function main(input) {
    var nums = input.split('\n')[1].split(' ').map( (n) => parseInt(n,10) );

    var count = 0;
    while(nums.every((n) =>(n % 2) === 0)){
	count++;
	nums = nums.map((n) => n /2);
    }
    console.log(count);
}
    
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
  using namespace std;
  #define rep(i, n) for (int i = 0; i < (int)(n); i++)
  #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
  typedef long long ll;
  #define all(x) (x).begin(),(x).end()
  int INF = 1000000000;

  int main() {
    int N, M; cin >> N >> M;
    vector<vector<char>> A(N, vector<char>(N));
    vector<vector<char>> B(M, vector<char>(M));
    rep(i, N) {
      rep(j, N) {
        cin >> A[i][j];
      }
    }
    rep(i, M) {
      rep(j, M) {
        cin >> B[i][j];
      }
    }
    bool flag = false;
    rep(i, N-M+1) {
      rep(j, N-M+1) {
        int cnt = 0;
        rep(k, M) {
          rep(l, M) {
            if (A[i+k][j+l] == B[k][l]) {
              cnt++;
            }
          }
        }
        if (cnt == pow(M, 2)) {
          flag = true;
        }
      }
    }
    if (flag) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

Measured memory_bytes: 256
program main
	implicit none
    character(11)::s,t
    integer::i,lenn
    read(*,*)s
    read(*,*)t
    lenn=len_trim(s)
    do i=1,lenn
    	if(s(i:i)==t(i:i))then
        	cycle
        else
        	write(*,*)'No'
            stop
        end if
    end do
    write(*,*)'Yes'
    stop
end program main
    


Measured memory_bytes: 2808
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>

using  namespace std;
#define ll long long 
int n;
ll h;
struct node{
	ll x,y;
}a[100005];
bool cmp(node p1,node p2){
	return p1.y > p2.y;
}
int main(){
	ll maxx = 0;
	scanf("%d %lld",&n,&h);
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&a[i].x,&a[i].y);
		if(a[i].x > maxx){
			maxx = a[i].x;
		} 
	}
	sort(a+1,a+1+n,cmp);
	ll cnt = 0;
	int sum = 0;
	for(int i=1;i<=n;i++){
		if(a[i].y > maxx){
			cnt += a[i].y;
			sum++;
		}
		else{
			break ;
		}
	} 
	if(cnt < h){
		ll now = h - cnt;
		if(now%maxx == 0){
			cout<<sum + now/maxx<<endl;
		}else{
			cout<<sum + 1 + now/maxx<<endl;
		}
		return 0;
	}
	if(cnt == h){
		cout<<sum<<endl;
		return 0;
	} 
	if(cnt > h){
		sum = 0;
		cnt = 0;
		for(int i=1;i<=n;i++){
			cnt += a[i].y;
			sum++;
			if(cnt >= h){
				break ;
			}
		}
		cout<<sum<<endl;
		return 0;
	}
	
	
	
	
	
	return 0;
} 

Measured memory_bytes: 1792
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// disk[i] = (id, width)
vector<PII> disk;

void Write(){
  int id, sz; cin >> id >> sz;
  for(auto it=disk.begin();sz>0;++it){
	if(it->first != -1) continue;
	if(sz < it->second){
	  it->second -= sz;
	  disk.insert(it, MP(id,sz));
	  return;
	}
	else{
	  it->first = id;
	  sz -= it->second;
	}
  }
}

void Del(){
  int id; cin >> id;
  for(auto& pii: disk)
	if(pii.first == id)
	  pii.first = -1;
}

void Read(){
  int a; cin >> a;
  int p = 0;
  for(auto& pii: disk){
	if(a < p + pii.second){
	  cout << pii.first << endl;
	  return;
	}
	p += pii.second;
  }
  cout << -1 << endl;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int N;
  while(cin >> N, N){
	disk.assign(1, MP(-1, 1000000000+100));
	REP(i,N){
	  char q;
	  cin >> q;
	  switch(q){
	  case 'W':
		Write();
		break;
	  case 'D':
		Del();
		break;
	  case 'R':
		Read();
		break;		
	  }
	}
	cout << endl;
  }
  
  return 0;
}

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

int main() {
  int a, b; cin >> a >> b;
  int n = 0;
  while (1) {
    if ((a-1) * n + 1 >= b) break;
    n++;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3604
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll n,W;cin>>n>>W;
	ll w[n+1],p[n+1];
	for(ll i=1;i<=n;i++)cin>>w[i]>>p[i];
	ll dp[n+1][W+1];
	memset(dp,0,sizeof(dp));
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=W;j++){
			if(j<w[i])dp[i][j]=dp[i-1][j];
			else{
				dp[i][j]=dp[i-1][j];
				dp[i][j]=max(dp[i-1][j-w[i]]+p[i],dp[i][j]);
			}
		}
	}
	cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 79104
#include <iostream> 
#include <cstring>
#include <algorithm>
#define INF 500050
double a[INF];
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	long double sum = a[1]+a[2];
	long double k = 2;
	for(int i=3; i<=n; i++) {
		sum += 1.0*k*a[i];
		k *= 2;
	}
	sum/=k*1.0;
	cout<<sum<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

vector<long long> make_divisors(long long n){
    vector<long long> divisors;
    for(long long i=1; i*i<=n; i++){
        if(n%i == 0){
            divisors.push_back(i);
            if(i*i != n) divisors.push_back(n/i);
        }
    }
    // sort(divisors.begin(), divisors.end());
    return divisors;
}

vector<int> sieve_eratosthenes(int n){
    vector<int> ret(n+1); for(int i=0; i<=n; ++i) ret[i] = i;
    for(int i=2; i*i<=n; i++){
        if(ret[i] < i) continue;
        for(int j=i*i; j<=n; j+=i) ret[j] = min(ret[j], i);
    }
    return ret;
}

void Main(){
    int N; cin >> N;
    int mx=0;
    VI A(N); REP(i,N){cin >> A[i]; chmax(mx,A[i]);}

    VI sieve = sieve_eratosthenes(mx);

    vector<bool> exist(mx+1,false);
    bool flag = false;
    REP(i,N){
        VI v{1};
        int d = A[i];
        while(d>1){
            if(v.back() != sieve[d]) v.push_back(sieve[d]);
            d /= sieve[d];
        }
        for(int p : v){
            if(p == 1) continue;
            if(exist[p]){
                flag = true;
                break;
            }
            exist[p] = true;
        }
        if(flag) break;
    }

    if(!flag){
        cout << "pairwise coprime" << en;
        return;
    }

    int g = A[0]; REP(i,N-1) g = gcd(g,A[i+1]);
    string ans = g==1 ? "setwise coprime" : "not coprime";
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 11056
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    int n; cin >> n;
    int p[n];
    int mx = 0;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        mx = max(mx, p[i]);
        sum += p[i];
    }
    cout << sum - mx/2 << endl;
}

Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRECTIONS = {{1, 1}, {0, 1}, {-1, 1}, {1, 0}, {-1, 0}, {0, -1}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        String s = sc.next();
        String res = "";

        for (int i = 0; i <s.length(); i++) {
            res += "x";
        }

        System.out.println(res);
        System.exit(0);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
import math

n = int(raw_input())

th = math.pi * 60.0 / 180.0

def split(x,y):
    s = ((2*x[0]+y[0])/3, (2*x[1]+y[1])/3)
    t = ((x[0]+2*y[0])/3, (x[1]+2*y[1])/3)
    u = ((t[0]-s[0])*math.cos(th) - (t[1]-s[1])*math.sin(th) + s[0], (t[0]-s[0])*math.sin(th) + (t[1]-s[1])*math.cos(th) + s[1])
    return (s,u,t)


s = (0.,0.)
t = (100.,0.)
points = []
points.append(s)
points.append(t)
for i in range(n):
    new_points = []
    j = 0
    while True:
        s,u,t = split(points[j],points[j+1])
        new_points.extend((points[j],s,u,t))
        j += 1
        if j+1 >= len(points): break
    new_points.append(points[j])
    points = new_points
for p in points:
    print p[0],p[1]

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

using namespace std;

int main(){
        string s;
        cin>>s;
        bool flag[4]={0};
        for(int i=0;i<(int)s.length();i++){
                if(s[i]=='N'){
                        flag[0]=true;
                }
                else if(s[i]=='S'){
                        flag[1]=true;
                }
                else if(s[i]=='W'){
                        flag[2]=true;
                }
                else{
                        flag[3]=true;
                }
        }
        if((flag[0]&&flag[1]&&!flag[2]&&!flag[3])||(!flag[0]&&!flag[1]&&flag[2]&&flag[3])||(flag[0]&&flag[1]&&flag[2]&&flag[3])){
                cout<<"Yes"<<endl;
        }
        else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    stringstream ss;
    ss<<a<<b;
    int c;
    ss>>c;
    int d=sqrt(c);
    if(d*d==c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

#define ALPHABET 26

void zero(int *);

int main(){
  char moji[1201];
  int ans[ALPHABET];
  int i;
  

  zero(ans);

  scanf("%[^*]", moji);
  for(i=0; moji[i] != '\0'; ++i){
    if(moji[i] >= 65 && moji[i] <= 90)
      moji[i] += 32;
    ++ans[moji[i] - 'a'];
  }

  for(i = 0;i < ALPHABET; i++)
    printf("%c : %d\n",'a' + i ,ans[i]);
}

void zero(int *x){
  int *p = x;
  for(;p < x + ALPHABET;p++){
    *p = 0;
  }
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int n,m,x;
  cin >> n >> m >> x;
  vint C(n);
  vvint A(n,vint(m));
  rep(i,0,n){
    cin >> C[i];
    rep(j,0,m){
      cin >> A[i][j];
    }
  }
  int ans = INF;
  rep(i,1,(2<<n)){
    bool injudge = true;
    int SUM = 0;
    vbool judge(n);
    rep(j,0,n){
      if(i>>j&1) judge[j] = true;
    }
    vint sum(m);
    rep(j,0,n){
      if(judge[j]){
        SUM += C[j];
        rep(s,0,m){
          sum[s] += A[j][s];
        } 
      }
    }
    rep(j,0,m){
      if(sum[j] < x){
        injudge = false;
      }
    }
    if(injudge){
      ans = min(ans,SUM);
    }
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

ll n, a, b, c;
ll l = -1, r = 1e9;
vl h;

bool isOk(ll x) {
  ll rest = x;
  vl p = h;
  rep(i,n) {
    p[i] -= b * x;
  }
  rep(i,n) {
    if (p[i] > 0) {
      rest -= (p[i] + c - 1) / c;
    }
  }
  return rest >= 0;
}

int main() {
  cin >> n >> a >> b;
  c = a - b;
  h.resize(n); ina(h,n);
  while(l + 1 < r) {
    ll mid = (l + r) / 2;
    if (isOk(mid)) r = mid;
    else l = mid;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1792
num_list = [int(input()) for i in range(5)]

remains = []
divs = []

for num in num_list:
    remains.append(num % 10)
    divs.append(num // 10)

zeros = remains.count(0)

for i in range(remains.count(0)):
    remains.remove(0)

if len(remains) == 0:
    print(sum(divs) * 10)
else:
    print(sum(divs) * 10 + 40 - zeros * 10 + min(remains))

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

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

    cout << n - (k - 1) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  char x,y;
  cin >> x >> y;

  if(x < y){
    cout << '<' << endl;
  } else if(x == y){
    cout << '=' << endl;
  } else {
    cout << '>' << endl;
  }

  return 0;
}

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


int main()
{
 string s;
 cin>>s;
 int rem = 0;
 for(int i=0; i<s.size(); i++)
    rem = (rem*10 + s[i]-'0')%9;
 if(rem == 0)
    cout<<"Yes";
 else
    cout<<"No";
 return 0;
}



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

int main (){
  int n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  int sum = 0;
  rep(i, n){
    cin >> a[i];
    sum += a[i];
  }
  int count = 0;
  rep(i, n){
    if (a[i]*(4*m) >= sum){
      count++;
    }
  }
  if (count >= m){
      cout << "Yes" << endl;
    }
  else {
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 5000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

int n,k,a[N];
bitset<N> sum;
bool judge(int x) {
    if(a[x]>=k)
        return 1;
    sum.reset();

    sum[0]=1;
    for(int i=1;i<=n;i++)
        if(i!=x)
            sum|=sum<<a[i];

    for(int i=k-1;i>=k-a[x];i--)
        if(sum[i])
            return true;
    return false;
}
int main() {
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);

    int left=0,right=n+1;
    while(left<right) {
        int mid=(left+right)>>1;
        if(judge(mid))
            right=mid;
        else
            left=mid+1;
    }
    printf("%d\n",left-1);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

/* 挿入ソート (0オリジン) */
void insertionSort(int A[], int N) {
  int j, i, v;
  for (i = 1; i < N; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}



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

int main() {
  string S; cin >> S;
  if (S.size() < 26) {
    vector<int> cnt(26, 0);
    for (int i = 0; i < S.size(); i++) cnt.at(S.at(i) - 'a')++;
    string alp = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < 26; i++) {
      if (cnt.at(i) == 0) {
        cout << S + alp.at(i) << endl;
        return 0;
      }
    }
  }
  else {
    if (S == "zyxwvutsrqponmlkjihgfedcba") {
      cout << -1 << endl;
      return 0;
    }
    string T = S;
    next_permutation(T.begin(), T.end());
    string ans = "";
    for (int i = 0; i < T.size(); i++) {
      ans += T.at(i);
      if (T.at(i) > S.at(i)) break;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

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

	vi nums(n);
	int result;

	nums[0] = 0;
	FOR(i, 1, n) {
		cin >> nums[i];
	}
	cin >> result;

	vector<vector<ll> > dp(101, vector<ll>(21, 0));

	dp[1][nums[1]] = 1;

	FOR(i, 2, n) {
		REP(j, 21) {
			if(dp[i-1][j]) {
				if(j+nums[i] <= 20) {
					dp[i][j+nums[i]] += dp[i-1][j];
				}
				if(j-nums[i] >= 0) {
					dp[i][j-nums[i]] += dp[i-1][j];
				}
			}
		}
	}

	cout << dp[n-1][result] << endl;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
const int N=23333;
vector<ll> a[N];
int main(){
    ll n,m,i,j,k,l,x,y,ss,ans=0,s1,s2,s3,s4;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        cin>>x>>y;
        if(i==1) ss=x;
        a[x-ss].push_back(y);
    }
    for(i=0;i<=3;i++) sort(a[i].begin(),a[i].end(),greater<ll>());
    for(i=0,s1=0;i<=a[0].size();i++){
    for(j=0,s2=0;j<=a[1].size();j++){
    for(k=0,s3=0;k<=a[2].size();k++){
    for(l=0,s4=0;l<=a[3].size();l++){
        if(i*ss+j*(ss+1)+k*(ss+2)+l*(ss+3)<=m) ans=max(ans,s1+s2+s3+s4);
        if(l<a[3].size()) s4+=a[3][l];
    }
    if(k<a[2].size()) s3+=a[2][k];
    }
    if(j<a[1].size()) s2+=a[1][j];
    }
    if(i<a[0].size()) s1+=a[0][i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if ((a[i] == b[i] && a[i] != c[i]) || (b[i] == c[i] && c[i] != a[i])
        || (a[i] == c[i] && a[i] != b[i]))
      ans++;
    if (a[i] != b[i] && a[i] != c[i] && b[i] != c[i])
      ans += 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
main(){
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    for(size_t i = 0;i < H;i++){
            cin >> a[i];
    }
    for(size_t j = 0;j < W+2;j++){
        cout << "#";
    }
    cout << "\n";
    for(size_t i = 0;i < H;i++){
        cout << "#";
        for(size_t j = 0;j < W;j++){
            cout << a[i][j];
        }
        cout << "#\n";
    }
    for(size_t j = 0;j < W+2;j++){
        cout << "#";
    }
}

Measured memory_bytes: 256
def root(r):
    if par[r] == r:
        return r
    par[r] = root(par[r])
    return par[r]
 
def same(x, y):
    return root(x) == root(y)
 
def unite(x, y):
    x = root(x)
    y = root(y)
    par[x] = y
 
 
 
v,e = map(int, input().split())
adj = [list(map(int, input().split())) for i in range(e)]
adj.sort(key = lambda x:x[2])
par = [i for i in range(v)]
sum = 0
 
for i,j,k in adj:
    if not same(i, j):
        sum += k
        unite(i, j)
print(sum)


Measured memory_bytes: 28192
#include <stdio.h>
int n,A[20],M[200];

int result(int i,int m)
{
  if(m<0) return 0;
  if(A[i]==m) return 1;
  if(i==n) return 0;
  else
    {
      if(result(i+1,m)||result(i+1,m-A[i]))
	return 1;
    }
  return 0;
}

main(){
  int i,q;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&M[i]);
    }

  for(i=0;i<q;i++)
    {
      if(result(0,M[i])==1)
	printf("yes\n");
      
      else 
	printf("no\n");
    }
  return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

int main(void)
{
	int S;
	int h, m, s;
		
	scanf("%d",&S);
	h = S / 3600;
	m = (S - (3600 * h)) / 60;
	s = S - 3600 * h - 60 * m;
	
	printf("%d:%d:%d\n",h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
int main(){
    int n,k,x,y;
    scanf("%d %d %d %d",&n,&k,&x,&y);
    if(n<=k){
        printf("%d",x*n);
    }
    else{
        printf("%d",x*k+y*(n-k));
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,tmp,i;
	long long ans=0;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&k);
	if(k==0)
	{
		printf("%lld\n",(long long)n*n);
		return 0;
	}
	for(i=k+1;i<=n;i++)
	{
		//k~i-1
		tmp=n%i;
		if(tmp>=k&&tmp<i-1)
		{
			ans+=(long long)(tmp-k+1)*((n-k)/i+1)+(long long)(i-1-tmp)*((n-(i-1))/i+1);
		}
		else
			ans+=(long long)(i-k)*((n-k)/i+1);
	//	printf("%d %d\n",i,ans);
	}
	printf("%lld",ans);
	return 0;
}


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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            int X = int.Parse(lines[0]);
            int N = int.Parse(lines[1]);

            lines = Console.ReadLine().Split(' ');
            int[] p = new int[N];
            for (int i=0; i<N; i++)
            {
                p[i] = int.Parse(lines[i]);
            }

            List<int> list = new List<int>(p);

            for (int i = 0; i <= 100; i++)
            {
                if (!list.Contains(X - i))
                {
                    Console.WriteLine(X - i);
                    return;
                }
                else if (!list.Contains(X+i))
                {
                    Console.WriteLine(X + i);
                    return;
                }

            }


        }


    }
}


Measured memory_bytes: 27752