akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3500;
int n;
int a,b,c;
int main(){
	scanf("%d",&n);
	ll x,y;
	for(int i=1;i<=N;i++)
		for(int j=i;j<=N;j++){
			x=1LL*n*i*j,y=1LL*4*i*j-1LL*n*j-1LL*n*i;
			if(y<=0) continue;
			if((x%y)==0){
				cout<<i<<" "<<j<<" "<<x/y<<endl;
				return 0;
			}
		}
}

Measured memory_bytes: 256
package main

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

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	var S string
	words := [4]string{"dream", "dreamer", "erase", "eraser"}
	fmt.Scan(&S)
	lenS := len(S)
	index := lenS
	isCon := true
	for isCon {
		isCon = false
		for _, w := range words {
			n := len(w)
			if index-n <0 {
				continue
			} else if S[index-n:index] != w {
				continue
			} else {
				index -= n
				isCon = true
				break
			}
		}
	}
	if index == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
	
}

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


int main() {
	long long N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] -= i+1;
		//cout << A[i] << " ";
	}
	//cout << endl;
	sort(A.begin(), A.end());
	long long b;

	if (N % 2 == 0) {
		long long med = (A[N / 2] + A[N / 2 - 1]) / 2;
		//cout << med << endl;
		b = med;
	}
	else {
		b = A[N / 2];
	}
	//cout << b << endl;

	long long sum = 0;
	for (int i=0; i<N; i++){
		sum += abs(A[i] - b);
	}

	cout << sum << endl;
}

Measured memory_bytes: 1792
let () =
  Scanf.scanf "%1d%1d%1d\n"
    (fun a b c ->
       if a = 1 then if b = 1 then if c = 1 then 999 else 991
         else if c = 1 then 919 else 911
       else if b = 1 then if c = 1 then 199 else 191
       else if c = 1 then 119 else 111
    )
  |> print_int


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long a,b,n;
long long c,d;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out1.txt","w",stdout);
	cin>>a>>b>>n;
	if(n>=b){
		n=b-1;
	}
	c=floor(a*n/b);
	d=a*floor(n/b);
	cout<<c-d;
//fclose(stdout);
//fclose(stdin);
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 int a,N;
 long long int cnt=0;
 vector<int>A;
 cin>>N;

 for(int i=0; i<N;i++){
  cin>>a;
  A.push_back(a);
 }
 
 for(int i=0; i<N; i++){
  if(A[i]%2==0)for(int j=A[i]; A[i]%2==0; A[i]/=2)cnt++;
 }
 std::cout<<cnt<<std::endl;
 return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
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; }
using namespace std;

//竸プロは楽しい！！！！！！！！
//AtCoderさんいつもありがとうございます！！！！！！！！
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int n,d; cin>>n>>d;
    d=d*2+1;
    cout<<(n+d-1)/d<<endl;

}

Measured memory_bytes: 256
/* long long or int */
/* inline & usighed & sighned main */
/* xx 396 */

#include<bits/stdc++.h>
using namespace std;

const int MAX_N=1e5+10;

int dist[MAX_N],Q[MAX_N],deg[MAX_N],N,M,head=0,tail=0,ans=0;
vector <int> G[MAX_N];

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int X,Y; cin>>X>>Y; X--; Y--;
		G[X].push_back(Y); deg[Y]++;
	}
	for(int i=0;i<N;i++) if(!deg[i]) Q[tail++]=i;
	while(head<tail){
		int fr=Q[head++]; ans=max(ans,dist[fr]);
		for(int i=0;i<G[fr].size();i++){
			int to=G[fr][i]; deg[to]--;
			dist[to]=max(dist[to],dist[fr]+1);
			if(!deg[to]) Q[tail++]=to;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6912
#include <stdio.h>

int main() {
  char str[5];
  int i, a = 0, b = 0;
  char ca = 0, cb = 0;
  scanf("%s", str);
  for (i = 0; i < 4; i++) {
    if (str[i] == ca) {
      a++;
    } else if (str[i] == cb) {
      b++;
    } else if (ca == 0) {
      ca = str[i];
      a++;
    } else if (cb == 0) {
      cb = str[i];
      b++;
    } else {
      printf("No\n");
      return 0;
    }
  }
  if (a == 2 && b == 2) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
N = int(input())
h = list(map(int,input().split()))

def dfs(L):
    for i,l in enumerate(L):
        if l != 0:
            break
    L = L[i:N]
    s = 0
    res = 0
    for i,l in enumerate(L):
        if l == 0:
            L_ = [l_-1 for l_ in L[s:i]]
            s = i+1
            if len(L_) != 0:
                res += 1
                res += dfs(L_)
        elif i == len(L)-1:
            L_ = [l_-1 for l_ in L[s:len(L)]]
            s = i+1
            if len(L_) != 0:
                res += 1
                res += dfs(L_)
    return res

if sum(h) == 0:
    print(0)
else:
    print(dfs(h))

Measured memory_bytes: 3188
#include<iostream>
    using namespace std;
    int main(){
    	long long a,b;
    	std::cin>>a>>b;
    	if(a>=(b/2)){
    		std::cout<<(b/2);
    	}else{
    		std::cout<<(a+((b-(a+a))/4));
    	}
    	}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
  
  vector<char> vec(W);
  
  for(int i=0;i<H;i++){
    cout << "#";
    for(int j=0;j<W;j++){
      cin >> vec.at(j);
      cout << vec.at(j);
    }
    cout << "#" << endl;
  }
  
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
# Aizu Problem 0088: The Code A Doctor Loved
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def bin5(k):
    b = bin(k)[2:]
    while len(b) < 5:
        b = '0' + b
    return b


CODE1 = {' ': '101', "'": '000000', ",": '000011', '-': '10010001',
         '.': '010001', '?': '000001',
         'A': '100101', 'B': '10011010', 'C': '0101', 'D': '0001',
         'E': '110', 'F': '01001', 'G': '10011011', 'H': '010000',
         'I': '0111', 'J': '10011000', 'K': '0110', 'L': '00100',
         'M': '10011001', 'N': '10011110', 'O': '00101', 'P': '111',
         'Q': '10011111', 'R': '1000', 'S': '00110', 'T': '00111',
         'U': '10011100', 'V': '10011101', 'W': '000010',
         'X': '10010010', 'Y': '10010011', 'Z': '10010000'}

CODE2 = {bin5(k): chr(65+k) for k in range(26)}
symbols = [' ', '.', ',', '-', "'", '?']
for k in range(len(symbols)):
    CODE2[bin5(26+k)] = symbols[k]


def encode(string):
    enc = ''.join([CODE1[char] for char in string])
    while len(enc) % 5 != 0:
        enc += '0'
    return ''.join([CODE2[enc[5*k:5*k+5]] for k in range(len(enc) // 5)])


for line in sys.stdin:
    print(encode(line.replace('\n', '')))

Measured memory_bytes: 7584
N = int(input())
S= input()
s_list= list(S)

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            x= S[:-2].find(str(i))
            if x!=-1:
                y=S[x+1:-1].find(str(j))
                if y!=-1:
                    z=S[x+1+y+1:].find(str(k))
                    if z!=-1:
                        ans+=1

print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	char[] S = sc.next().toCharArray();
    	sc.close();
    	boolean ans = true;
    	int len = S.length;
    	int t1 = len-1;
    	for(int i = 0; i < len/2; i++){
    		if(S[i] != S[t1]){
    			ans = false;
    		}
    		t1--;
    	}
    	t1 = (len-1)/2-1;
    	for(int i = 0; i < t1/2; i++){
    		if(S[i] != S[t1]){
    			ans = false;
    		}
    		t1--;
    	}
    	t1 = (len+3)/2-1;
    	int t2 = len-(t1-1)/2;
    	int t3 = len-1;
    	for(int i = t1; i < t2; i++){
    		if(S[i] != S[t3]){
    			ans = false;
    		}
    		t3--;
    	}
    	System.out.println(ans?"Yes":"No");
    }

}

Measured memory_bytes: 21844
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		int a = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();
		
		if(a>=3200){
			Console.WriteLine(s);
		}else{
			Console.WriteLine("red");
		}
		
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, K);
  VEC(int, A, N);
  map<int, int> m;
  each(x, A) {
    m[x]++;
  }
  vi v;
  each(x, m) {
    v.push_back(x.second);
  }
  sort(all(v), greater<>());
  int ans = 0;
  rep(i, K, (int)v.size()) {
    ans += v[i];
  }
  print(ans);
}


Measured memory_bytes: 11640
import Data.List
import Control.Monad.State

main = do
    [n, m] <- map read . words <$> getLine
    xss <- map (map read . tail . words) <$> sequence (replicate n getLine)
    print . fst $ runState (acnt n m xss) (replicate m 0)

fresh :: Int -> Int -> [Int] -> State [Int] Int
fresh n m xs = state $ \s ->
    let xs' = map (\x -> if x `elem` xs then 1 else 0) [1..m]
        s' = zipWith (+) xs' s
        in (length . filter (==n) $ s', s')

acnt :: Int -> Int -> [[Int]] -> State [Int] Int
acnt n m [] = fresh n m (replicate m 0)
acnt n m [xs] = fresh n m xs
acnt n m (xs:xss) = do
    acnt n m [xs]
    acnt n m xss


Measured memory_bytes: 1148
k,a,b=map(int,input().split())
total=1
if b-a<=2:
    print(k+1)
else:
    if (a-total)+1>=k:
        print(k+1)
        exit()
    else:
        total=a
        k-=(a-1)
        if k%2==1:
            total+=1
            k-=1
        cnt=k//2
        total+=(b-a)*cnt
        print(total)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int s;
  cin >> s;
  
  int t, u;
  t = s / 100; // tは上2桁
  u = s % 100; // uは下2桁
  
  if((0 < u) && (u < 13)){
    if((0 < t) && (t < 13))
      cout << "AMBIGUOUS" << endl;
    else
      cout << "YYMM" << endl;
  }
  
  if((u < 1) || (12 < u)){
    if((0 < t) && (t < 13))
      cout << "MMYY" << endl;
    else
      cout << "NA" << endl;
  }
}
    

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

int INF = 1e9;
int d[10][10] = {};

//nは頂点数
//重みはd[i][j]でi→jへのコスト
//自分自身へはINF
void warshall_floyd(int n) {
	for (int i = 0;i < n;i++) {// 経由する頂点
		for (int j = 0;j < n;j++) {// 開始頂点
			for (int k = 0;k < n;k++) {// 終端
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}
}

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0;i < 10;i++) {
		for (int j = 0;j < 10;j++) {
			cin >> d[i][j];
		}
	}
	warshall_floyd(10);
	int ans = 0;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			int c;
			cin >> c;
          	if(c==-1)continue;
			ans += d[c][1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int n;
	cin>>n;
	string a;
	cin>>a;
	if(n%2==1){
		cout<<"No";
		return 0;
	}
	string t1,t2;
	t1=a.substr(0,n/2);
	t2=a.substr(n/2,n/2);
	if(t1==t2){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = (double)w * h / 2;
  printf("%.10f ", ans);
  if((double)w/2 == (double)x && (double)h/2 == (double)y) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long hp = sc.nextLong();
		long attackCount = 0;
		long monsterCount = 1;
		while(true) {
			if(hp == 1) {
				attackCount += monsterCount;
				break;
			}
			attackCount += monsterCount;
			hp /= 2;
			monsterCount *=2;
		}
		System.out.println(attackCount);
	}
}

Measured memory_bytes: 23252
N,K,Q = map(int,input().split())
if K > Q:
    ans1 = ["Yes" for _ in range(N)]
    x = "\n".join(ans1)
    print(x)
else:
    a = Q-K+1
    h = {}
    for i in range(Q):
        res = int(input())
        if h.get(res):
            h[res] += 1
        else:
            h[res] = 1
    ans2 = ["Yes" if h.get(i+1) and h[i+1] >= a else "No" for i in range(N)]
    y = "\n".join(ans2)
    print(y)

Measured memory_bytes: 9544
n = gets.chomp.to_i

pos_y = 0
pos_x = 0
time = 0

n.times do
  t, x, y = gets.chomp.split.map(&:to_i)

  dist = (y - pos_y).abs + (x - pos_x).abs

  if dist > (t - time)
    puts 'No'
    exit
  elsif (dist - (t - time)) % 2 != 0
    puts 'No'
    exit
  end

  pos_x = x
  pos_y = y
  time = t
end

puts 'Yes'


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

int njou(int n){
    int ans = 1;
    for(int i = 0;i<n;i++){
        ans *= 10;
    }
    return ans;
}

int main(){
    int n;
    int x,f = 0;
    cin >> n;
    x = n;
    //cout << n << endl;
    for(int i = 8;i>=0;i--){
        f += x/njou(i);
        x %= njou(i);
        //cout << "f:" << f << endl;
        //cout << "x:" << x << endl;
    }
    //cout << "for" << endl;
    if(n%f == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
//D
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3+10;
ll raw[maxn];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++)cin >> raw[i];
	ll ans = 0;
	raw[0] = 1e9;
	ll m = 1000,s = 0;
	for(int i = 1;i <= n;i++){
		if(raw[i] <= raw[i+1] and raw[i] <= raw[i-1]){
			s += m/raw[i];
			m -= raw[i]*(m/raw[i]);
		}
		else if(raw[i] >= raw[i+1] and raw[i] >= raw[i-1]){
			m += s*raw[i];
			s = 0;
		}
	}
	m += s*raw[n];
	cout << m;
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
//#define FUCKOJ
const int MAXN = 5e5+100;
int re[MAXN][5];
int num[MAXN];
int Max4(int a,int b,int c,int d)
{
	return max(max(a,b),max(c,d));
}
int Max3(int a,int b,int c)
{
	return Max4(a,b,c,0);
}

int op1(int i,int po)
{
	int tmp=Max3(re[i-1][0],re[i-1][2],re[i-1][3]);
	return max(tmp,re[i-1][1]);
}

int op2(int i,int po)
{
	int tmp=Max3(re[i-1][0]+num[i-1],re[i-1][2]+1,re[i-1][3]);
	if(po==1)	return max(tmp,re[i-1][1]);
	else return max(tmp,re[i-1][1]+num[i-1]-1);
}

int op3(int i,int po)
{
	int tmp=Max3(re[i-1][0]+max(num[i-1],num[i]-1),re[i-1][2]+num[i]-1,re[i-1][3]);
	if(po==1)	return max(tmp,re[i-1][1]);
	else return max(tmp,re[i-1][1]+max(num[i]-1,num[i-1]-1));
}

int op4(int i,int po)
{
	int tmp=Max3(re[i-1][0]+max(num[i-1],num[i]),re[i-1][2]+num[i],re[i-1][3]);
	if(po==1)	return max(tmp,re[i-1][1]);
	else return max(tmp,re[i-1][1]+max(num[i-1]-1,num[i]));
}


int N;
int dp(int n)
{
	if(n<=1)	return num[0]=0;
#ifdef FUCKOJ
	cout<<"now:";
	for(int i=0;i<n;++i)	cout<<num[i];
	cout<<endl;
#endif
	//memset(re,0,sizeof re);
	//for(int i=0;i<4;++i)	re[0][i]=0;
	for(int i=1,j;i<n;++i)
	{
		re[i][0]=op1(i,num[i-1]);
		re[i][1]=op2(i,num[i-1]);
		re[i][2]=op3(i,num[i-1]);
		re[i][3]=op4(i,num[i-1]);
		if(num[i]==1)	re[i][1]=re[i][3],re[i][2]=re[i][0];
	}
	for(int i=0;i<n;++i)	num[i]=0;

#ifdef FUCKOJ
	for(int i=0;i<n;++i)
		for(int j=0;j<4;++j)
			cout<<re[i][j]<<((j==3)?"\n":" ");
#endif

	
	int ans=Max4(re[n-1][0],re[n-1][1],re[n-1][2],re[n-1][3]);
#ifdef FUCKOJ
	cout<<"ans:"<<ans<<endl;
#endif
	return ans;
}
char str[MAXN];

int main()
{
	//int N;
	scanf("%d%s",&N,str);
	int cnt=0;
	int now;
	int i=0;
	int ans=0;
	while(i<N)
	{
	
		if(str[i]=='0')
		{
			if(num[cnt]==0)	ans+=dp(cnt),cnt=0;
			else cnt++;
	//		cout<<cnt<<endl;
		}else num[cnt]++;
		i++;
	}
	if(num[cnt]==0)	ans+=dp(cnt);
	else ans+=dp(cnt+1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	double x1,x2,y1,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	printf("%.4f\n",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> b(3);
    cin >> b[0] >> b[1] >> b[2];
    sort(b.begin(), b.end());
    cout << b[0] + b[1] << '\n';
    return 0;
}


Measured memory_bytes: 256
line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

tuples = []
arr = []
for i in range(n):
    line = raw_input().split()
    tuples.append( (int(line[0]), int(line[1]))  )

tuples = sorted(tuples, key = lambda x: x[0])

total = 0
for tup in tuples:
    total += tup[1]
    if total >= k:
        print tup[0]
        break


Measured memory_bytes: 22004
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,i,j,k,ans;
  cin>>n>>m>>x;
  vector<int> c(n),e(m);
  vector<vector<int>> a(n,vector<int>(m));
  for(i=0;i<n;i++){
    cin>>c.at(i);
    for(j=0;j<m;j++){
      cin>>a.at(i).at(j);
      e.at(j)+=a.at(i).at(j);
    }
  }
  for(j=0;j<m;j++) if(e.at(j)<x) break;
  if(j<m) cout<<-1<<endl;
  else{
    ans=10000000;
    for(k=0;k<(1<<n);k++){
      bitset<12> b(k);
      int an=0;
      vector<int> d(m);
      for(i=0;i<n;i++){
        if(b.test(i)){
          an+=c.at(i);
          for(j=0;j<m;j++) d.at(j)+=a.at(i).at(j);
        }
      }
      for(j=0;j<m;j++) if(d.at(j)<x) break;
      if(j==m) ans=min(ans,an);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

ll N,K;
ll weight[SIZE];

bool isOK(ll LIMIT){

	int weight_index = 0,truck_index = 0;
	int tmp_sum = 0;

	while(truck_index < K){

		while(weight_index < N && tmp_sum+weight[weight_index] <= LIMIT){

			tmp_sum += weight[weight_index];
			weight_index++;
		}

		if(weight_index == N)return true;

		truck_index++;
		tmp_sum = 0;
	}
	return false;
}

int main(){

	scanf("%lld %lld",&N,&K);

	ll sum = 0;

	for(int i = 0; i < N; i++){

		scanf("%lld",&weight[i]);
		sum += weight[i];
	}

	ll left = 0,right = sum,mid = (left+right)/2;
	ll ans = sum;

	while(left <= right){

		if(isOK(mid)){

			ans = mid;
			right = mid-1;

		}else{

			left = mid+1;
		}
		mid = (left+right)/2;
	}

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

	return 0;
}



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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	//cout<<"faaf\n";	
 	ll n,a,b,i,j,k;
 	sc(n);sc(a);sc(b);
 	j=b-a;
 	if(j%2)printf("Borys\n");
 	else printf("Alice\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
  int A,P;
  cin>>A>>P;
  cout<<(3*A+P)/2<<endl;
  return 0;
  }

Measured memory_bytes: 256
def main():
    n = int(input())
    A = sorted(map(int, input().split()), reverse=True)
    ans = 0
    mod = 10 ** 9 + 7
    m=A[0]
    for i in range(61):
        cnt0 = cnt1 = 0
        if m < 2 ** i:
            break
        for j, a in enumerate(A):
            if a < 2 ** i:
                cnt0 += n - j
                break
            if (a >> i) & 1:
                cnt1 += 1
            else:
                cnt0 += 1
        ans += (((2 ** i) % mod) * ((cnt1 * cnt0) % mod)) % mod
        ans %= mod

    print(ans)

if __name__ == "__main__":
    main()

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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector<int>
#define vvi         vector<vi>
#define pii         pair<int,int>
#define vii         vector<pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define mkpr        make_pair
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         998244353


signed main() {
        IO;
        string s;
        cin >> s;
        if (s.back() != 's') {
            s += 's';
        }
        else {
            s += "es";
        }
        cout << s;
}


Measured memory_bytes: 3560
#include<cstdio>
#include<cstdlib>

struct Node
{
	int key;
	Node *left;
	Node *right;
	Node *parent;
};

Node *root;
Node *NIL;

// 節点xを頂点とする部分木で最小値の節点を求める
Node * treeMinimum(Node *x)
{
	while (x->left != NIL)
	{
		x = x->left;
	}
	return x;
}

// 節点xの次節点(中間順巡回でxの次に訪問される節点)を求める
Node * treeSuccessor(Node *x)
{
	if (x->right != NIL) return treeMinimum(x->right);
	Node *y = x->parent;
	while (y != NIL && y->right == x)
	{
		x = y;
		y = x->parent;
	}
	return y;
}

// 削除実行
// ① 削除対象の接点を決める
// ② ①の子を決める
// ③ ①及び②のポインタをつなぎ変える
// ④ ①の値の避難
// ⑤ ①を削除する
void treeDelete(Node *z)
{
	Node *y;
	if (z->left == NIL || z->right == NIL)
	{
		y = z;
	}
	else
	{
		y = treeSuccessor(z);
	}

	Node *x;
	if (y->left != NIL) x = y->left;
	else x = y->right;

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

	z->key = y->key;
	free(y);
}

Node * find(Node *u, int key)
{
	while (u != NIL && key != u->key)
	{
		if (key < u->key)
		{
			u = u->left;
		}
		else
		{
			u = u->right;
		}
	}
	return u;
}

void insert(int key)
{
	// 挿入ノードの生成
	Node *z = (Node*)malloc(sizeof(Node));
	z->key = key;
	z->left = NIL;
	z->right = NIL;

	// 挿入位置の親を探す
	Node *y = NIL;	// 挿入位置の親
	Node *x = root; // 挿入位置
	while (x != NIL)
	{
		y = x;
		if (z->key < x->key)
		{
			x = x->left;
		}
		else
		{
			x = x->right;
		}
	}

	// 挿入の実行
	z->parent = y;
	if (y == NIL)
	{
		root = z;
	}
	else
	{
		if (z->key < y->key)
		{
			y->left = z;
		}
		else
		{
			y->right = z;
		}
	}
}

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

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

int main()
{
	int n;
	scanf("%d", &n);

	char com[10];
	int key;
	for (int i = 0; i < n; i++)
	{
		scanf("%s", com);
		if (com[0] == 'i')
		{
			scanf("%d", &key);
			insert(key);
		}
		if (com[0] == 'p')
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		if (com[0] == 'f')
		{
			scanf("%d", &key);
			if (find(root, key) != NIL)
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
		if (com[0] == 'd')
		{
			scanf("%d", &key);
			treeDelete(find(root, key));
		}
	}
	return 0;
}

/*
「ALDS1_8_A_BinarySearchTree2」の main関数

int main()
{
	int n;
	scanf("%d", &n);

	char com[10];
	int key;
	for (int i = 0; i < n; i++)
	{
		scanf("%s", com);
		if (com[0] == 'i')
		{
			scanf("%d", &key);
			insert(key);
		}
		if (com[0] == 'p')
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		if (com[0] == 'f')
		{
			scanf("%d", &key);
			if (find(root, key) != NIL)
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
	}
	return 0;
}
*/


Measured memory_bytes: 21332
package main

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

const pi = math.Pi

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

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	h := make([]int, N)

	for i := 0; i < N; i++ {
		h[i], _ = strconv.Atoi(read())
		h[i]--
	}

	dp := make([]int, N+5)
	for i := 1; i < N+1; i++ {
		dp[i] = 1e9
	}
	for i := 0; i < N-1; i++ {
		var t1, t2 int = 1e9, 1e9
		t1 = dp[i] + abs(h[i+1]-h[i])
		if i+2 < N {
			t2 = dp[i] + abs(h[i+2]-h[i])
		}
		dp[i+1] = min(dp[i+1], t1)
		dp[i+2] = min(dp[i+2], t2)
	}
	fmt.Println(dp[N-1])
}

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

var reader = bufio.NewScanner(os.Stdin)

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

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

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

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

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

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

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

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

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

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

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

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

type SortBy []int

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

type PriorityQueue []int

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


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	string s, t; cin >> s >> t;
	int n=s.size(), m=t.size();
	int ans=m;
	REP(i,n-m+1){
		int c=0;
		REP(j,m){
			if(s[i+j]!=t[j])
				c++;
		}
		ans=min(ans,c);
	}
	cout << ans << endl;
	return 0;
}

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

#define INF 2147483647
#define LINF 9223372036854775807
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

int n,p;
bool flg=false;

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

	cin>>n>>p;
	REP(i,n) {
		int a; cin>>a;
		if(a%2==1) flg=true;
	}
	if(!flg) {
		if(p==1) cout<<0<<endl;
		else cout<<(1LL<<n)<<endl;
	}
	else cout<<(1LL<<(n-1))<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
  char str[15];
  int num1,num2,Kth;
  scanf("%s",str);
  sscanf(str,"%d",&num1);
  scanf("%s",str);
  sscanf(str,"%d",&num2);
  scanf("%s",str);
  sscanf(str,"%d",&Kth);
  int comDiv[100];
  int i,testNum;
  for(i = 0, testNum = 1; testNum <= num1 && testNum <= num2 && i<100; testNum++){
    if(num1%testNum==0 && num2%testNum==0){ //testNumがnum1,num2の公約数であったら
      comDiv[i]=testNum;
      //printf("%dth:%d\n",i,comDiv[i]);
      i++;//次の番号にする
    }
  }
  //i--;//最大公約数の入っている位置にする
  printf("%d",comDiv[i-Kth]);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace abc116c
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            Console.ReadKey(true);
#endif
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int M = cin.ReadInt;
            int[] X = new int[100000];

            for (int i = 0; i < 100000; i++)
            {
                X[i] = int.MaxValue;
            }

            for (int i = 0; i < M; i++)
            {
                X[i] = cin.ReadInt;
            }
            Array.Sort(X);
            
            int[] L = new int[100000];

            for (int i = 0; i < M - 1; i++)
            {
                L[i] = X[i + 1] - X[i];
            }
            for (int i = M - 1; i < 100000; i++)
            {
                L[i] = int.MaxValue;
            }
            Array.Sort(L);

            int R = 0;
            for (int i = 0; i < M - N; i++)
            {
                R += L[i];
            }

            WriteLine($"{R}");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 21472
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[55];
int main(){
    LL k;
    scanf("%lld",&k);
    printf("50\n");
    for(int i=1;i<=50;i++) a[i]=(LL)(50-i);
    for(int i=1;i<=50;i++) {
        a[i]+=((k+49)/50);
        k--;
        printf("%lld%c",a[i],i==50?'\n':' ');
    }
    return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. A-BEGINNER.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP     PIC X(100).
01 IN-DATA.
   03 DT-X1 PIC X(10).
   03 DT-X2 PIC X(10).
01 IN-LEN.
   03 DT-L1 PIC 9(2).
   03 DT-L2 PIC 9(2).
01 IN-N     PIC 9(10).
01 IN-K     PIC 9(02).
01 I        PIC 9(2).
01 OUT-KETA PIC Z9.

PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO DT-X1 COUNT IN DT-L1
           DT-X2 COUNT IN DT-L2.
  MOVE DT-X1(1:DT-L1) TO IN-N.
  MOVE DT-X2(1:DT-L2) TO IN-K.

  MOVE 1 TO I.
  PERFORM UNTIL (IN-K ** I > IN-N)
    ADD 1 TO I
  END-PERFORM.
  MOVE I TO OUT-KETA.
  DISPLAY OUT-KETA.

MAIN-EXIT.
  STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define PQ priority_queue
#define pb push_back
#define fu(i,a,j) for(int i=a;i<j;i++)
#define fd(i,a,j) for(int i=a;i>=j;i--)
#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define MOD 1000000007 
#define MOD2 1000000021
#define MAXN 2000000
#define INF 1e9
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;

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

ll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }
ll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };
db dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }
int dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };
int dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };

int n, m, k, t;

string ansok[2] = { "NO","YES" };

int a[200005];
int main()
{
	SYNC;
	int d, t, s;
	cin >> d >> t >> s;
	bool ok = 0;
	int ans = 0;
	//분당 s미터 t시간까지
	if ((d + s - 1) / s <= t)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3648
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

ans=0

for i in range(n-1):
    if(a[i]+a[i+1]>x):
        rem =  a[i+1] + a[i] - x
        if(rem<=a[i+1]):
            a[i+1]-=rem
        else:
            rem-=a[i+1]
            ans+=a[i+1]
            a[i]-=rem
            a[i+1]=0
        ans+=rem
print(ans)


Measured memory_bytes: 14472
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] price = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            price[i] = sc.nextInt();
        }
        Arrays.sort(price);
        for (int i = 0; i < k; i++) {
            sum += price[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 38784
def getval():
    n,w = map(int,input().split())
    p = [list(map(int,input().split())) for i in range(n)]
    return n,w,p 


def main(n,w,p):
    #dp[n][v]
    dp = [[0 for i in range(n*10**3+1)]]
    ans = 0
    for i in range(n):
        item = p[i]
        temp = []
        for j in range(n*10**3+1):
            #Cannot achieve
            cur = 0
            if j<item[1]:
                cur = dp[i][j]
                temp.append(cur)
            elif j==item[1]:
                cur = item[0]
                if dp[i][j]:
                    cur = min(item[0],dp[i][j])
                temp.append(cur)
            else:
                if dp[i][j] and dp[i][j-item[1]]:
                    cur = min(dp[i][j],dp[i][j-item[1]]+item[0])
                elif dp[i][j]:
                    cur = dp[i][j]
                elif dp[i][j-item[1]]:
                    cur = dp[i][j-item[1]]+item[0]
                temp.append(cur)
            if cur and cur<=w:
                ans = max(ans,j)
        dp.append(temp)
    print(ans)

                    
if __name__=="__main__":
    n,w,p = getval()
    main(n,w,p)

Measured memory_bytes: 219644
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
bool f1,f2;

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

  if (n/100>0&&n/100<13) f1=true;
  if (n%100>0&&n%100<13) f2=true;

  if (f1&&!f2) ans="MMYY";
  else if (!f1&&f2) ans="YYMM";
  else if (f1&&f2) ans="AMBIGUOUS";
  else ans="NA";
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int h,n;
    cin >> h >> n;
    vi a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<ll> dp(300000,LINF);
    dp[0] = 0;
    ll ans = LINF;
    rep(j,200000){
        rep(i,n){
            if(j-a[i]>=0){
                dp[j] = min(dp[j],dp[j-a[i]] + b[i]);
                if(j>=h) ans = min(ans,dp[j]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688
using System;
using static System.Console;

public class Hello{
    public static void Main(){
        int num = int.Parse(ReadLine());
        string[] liststr = ReadLine().Split(' ');
        int[] list = new int[num];
        for(int i=0;i<num;i++){
            list[i] = int.Parse(liststr[i]);
        }
        int checker = -1;
        int count = 0;
        for(int i=0;i<num;i++){
            if(list[i] == i+1){
                count++;
                if(checker == i){
                    checker = -1;
                    count--;
                }else{
                    checker = i+1;
                }
            }
        }
        WriteLine(count);
    }
}

Measured memory_bytes: 18912
import datetime
while True:
	x = map(int,raw_input().split(' '))
	if x[0] != 0:
		day = datetime.date(2004,x[0],x[1])
		weekday = day.isoweekday()
		if weekday == 1:
			print 'Monday'
		if weekday == 2:
			print 'Tuesday'
		if weekday == 3:
			print 'Wednesday'
		if weekday == 4:
			print 'Thursday'
		if weekday == 5:
			print 'Friday'
		if weekday == 6:
			print 'Saturday'
		if weekday == 7:
			print 'Sunday'
		continue
	else:
		break

Measured memory_bytes: 4436
#include<stdio.h>
#include<algorithm>
using namespace std;
   int a[5];
   int main()
   {
   for(int i=0;i<3;i++) 
      scanf("%d",&a[i]);
   sort(a,a+3);
   if(a[0]==5&&a[1]==5&&a[2]==7)
   printf("YES\n");
   else
   printf("NO\n");
   } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar

using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= (int) 1e5+10;
const long base= 1e9+7;
int n,a[N],sz;
int ok[N];
long gt[N];
void input()
{
    cin>>n;
    up(i,1,n+1)
    {
    	cin>>a[i];
    	if (!ok[a[i]]) ok[a[i]]= i;
    	else sz= n+1-i+ ok[a[i]]-1;
    }

}
long power(int x,int k)
{
    if (k==1) return x;
    long xx= power(x,k/2);
    xx= xx*xx% base;
    if (k%2==1) xx= xx* x% base;
    return xx;
}
long C(int k,int n)
{
	if (n==0 or k>n) return 0;
    return gt[n] * power(gt[n-k]*gt[k]%base, base-2)% base;
}
void solve()
{
	gt[0] =1;
    up(i,1,n+1) gt[i]= gt[i-1]*i % base;

	cout<<n<<endl;
    up(k,2,n+1) cout<<(C(k,n+1)- C(k-1,sz)+ base) % base<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// scanf phai bo
    #define TASK "tmp"
    //freopen(TASK".inp","r",stdin);
    //freopen(TASK".out","w",stdout);

    input();
    solve();

    return 0;
}


Measured memory_bytes: 2816
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                sc.close();
                long p = 1;
                while(n > 1){ 
                        p *= n--;
                }   
                System.out.println(p);
        }   
}

Measured memory_bytes: 11000
import java.util.Scanner;

public class Main {
	static final int[] md = new int[12];
	static {
		int[] days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		int day = 0;
		for (int i = 0; i < 12; i++) {
			md[i] = day;
			day += days[i];
		}
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int y1, y2, m1, m2, d1, d2;
		while (true) {
			if ((y1 = in.nextInt()) < 0 || (m1 = in.nextInt()) < 0
					|| (d1 = in.nextInt()) < 0 || (y2 = in.nextInt()) < 0
					|| (m2 = in.nextInt()) < 0 || (d2 = in.nextInt()) < 0) {
				break;
			}
			long from = getL(y1, m1, d1);
			long to = getL(y2, m2, d2);
			System.out.println(to - from);
		}
	}

	private static long getL(int y, int m, int d) {
		long result = 365 * y + md[m - 1] + d;
		if (m > 2 && ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)) {
			result++;
		}
		result += (y - 1) / 4 - (y - 1) / 100 + (y - 1) / 400;
		return result;
	}
}

Measured memory_bytes: 19512
Public Class Main
    Public Shared Sub Main(ByVal args() As String)
        Dim A, B, C As Integer
        Dim arr(3) As String
        arr = Split(Console.ReadLine())
        A = arr(0) : B = arr(1) : C = arr(2)
        Dim flg As Boolean = False
        If A = B AndAlso B <> C Then
            flg = True
        End If
        If B = C AndAlso C <> A Then
            flg = True
        End If
        If C = A AndAlso A <> B Then
            flg = True
        End If
        Console.WriteLine(If(flg, "Yes", "No"))
    End Sub
End Class


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


int main(){
  
  queue<long long> Lun;
  long long j = 0, j__;
  long long i, K, cnt = 0;
  string j_;
  cin >> K;
  
  for (i = 1; i < 10; i++) Lun.push(i);
  
  while(cnt < K){
    
    j  = Lun.front();
    Lun.pop();
    j__ = j % 10;
    
    
    if (j__ == 0) {
      Lun.push(10 * j);
      Lun.push(10 * j + 1);
      
    } else if (j__ == 9) {
      Lun.push(10 * j + 8);
      Lun.push(10 * j + 9);
      
    } else {
      Lun.push(10 * j + j__ - 1);
      Lun.push(10 * j + j__);
      Lun.push(10 * j + j__ + 1);
            
    }
    
    cnt++;
  }
  
  cout << j << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<math.h>
#include<map>
#include<set>
#include<queue>
#include<vector>

using namespace std;



int main() {
	int ini = 1;
	int a, b;
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		a = ini * 2;
		b = ini + K;
		if (a > b) {
			ini = b;
		}
		else {
			ini = a;
		}
	}
	cout << ini;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  vector<int> favs(a);
  vector<int> foods;
  rep(i, a){
    cin >> favs.at(i);
    rep(j, favs.at(i)){
      int c;
      cin >> c;
      foods.push_back(c - 1);
    }
  }
  rep(i, 30){
    int count = 0;
    rep(j, foods.size()){
      if (i == foods.at(j)) count++;
    }
    if (count == a) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int n;
	int t, a;

	cin >> n;
	cin >> t >> a;

	int id = 0;
	double sub = INFINITY;

	for (int i = 1; i < n + 1; ++i)
	{
		int h;
		cin >> h;

		double hsub = fabs(t - (double)h*0.006 - a);

		if (hsub < sub) 
		{
			sub = hsub;
			id = i;
		}
	}

	cout << id << endl;

	return 0;
}

Measured memory_bytes: 256