akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

i64 k;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

	cin >> k;
	if (k <= 9) {
		cout << k << '\n';
		return 0;
	}	
	priority_queue<i64, vector<i64>, greater<i64>> pq;
	for (int i = 1; i <= 9; ++i) pq.push(i);
	i64 cnt = 0;
	while (true) {
		i64 now = pq.top();
		pq.pop();
		++cnt;
		if (cnt == k) {
			cout << now << '\n';
			break;
		}
		int lst = now%10;
		if (lst == 0) {
			pq.push(now*10);
			pq.push(now*10+1);
		}	
		else if (lst == 9) {
			pq.push(now*10+9);
			pq.push(now*10+8);
		}	
		else {
			pq.push(now*10+lst-1);
			pq.push(now*10+lst);
			pq.push(now*10+lst+1);
		}	
	}

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
}

const ll INF = 1e17;
// https://atcoder.jp/contests/abc143/submissions/8034843

int main() {
    // input
    int N;
    cin >> N;

    // 偶数
    if (N%2 ==0)
    {
        cout << N/2-1 << endl;
    }
    else
    {
        cout << N/2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int x;
  cin >> x;
  
  int y = x / 500;
  int z = (x - 500 * y) / 5;
  
  cout << 1000 * y + 5 * z << endl;
  
} 

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    ll N, M;

    //input
    cin >> N >> M;

    if(N == M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner (System.in);
		
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();
		int min =0;

		if(n%x==0) {
			min = (n/x)*t;
		}else if(n%x != 0) {
			min = (n/x+1)*t;
		}
		
		System.out.println(min);

	}

}

Measured memory_bytes: 35644
// 2014/07/14 Tazoe

#include <iostream>
using namespace std;

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

	if(a<b){
		cout << "a < b\n";
	}
	else if(a>b){
		cout << "a > b\n";
	}
	else{
		cout << "a == b\n";
	}

	return 0;
}

Measured memory_bytes: 1124
#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
char _;

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,d,ans=0;
	cin>>n>>d;
	d*=d;
	for(int i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		ll c = a*a + b*b;
		if(c<=d) ans++;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3656
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]

r = set()
for i in range(h):
    ok = True
    for j in range(w):
        if a[i][j] == '#':
            ok = False
            break
    else:
        if ok:
            r.add(i)
c = set()
for j in range(w):
    ok = True
    for i in range(h):
        if a[i][j] == '#':
            ok = False
            break
    else:
        if ok:
            c.add(j)
for i in range(h):
    tmp = ''
    if i in r:
        continue
    for j in range(w):
        if j in c:
            continue
        tmp += a[i][j]
    print(tmp)


Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
   int n;
long long cnt=0,mnt=0,cnt1=0,s=0;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
       s+=i;
       if((i%3==0 && i%5==0))
        cnt+=i;
        else if(i%3==0)
            mnt+=i;
        else if(i%5==0)
            cnt1+=i;

   }
    long long  m=cnt+mnt+cnt1;
    printf("%lld",s-m);
    return 0;
}


Measured memory_bytes: 1736
#include<stdio.h>
int main(){
  int n,k,i;
  scanf("%d%d",&n,&k);
  int start=k,end=n;
  double sum=0,a;
  for(i=1;i<=n;i++){
    int num=i;
    double count=1;
    while(num<k){
      num*=2;
      count*=2;
    }
    sum+=1/count;
  }
  printf("%.10lf\n",sum/n);
  return 0;
}


Measured memory_bytes: 128
def divide(x, y):
    s = 1
    if(x < 0):s *= -1
    if(y < 0):s *= -1
    return abs(x) / abs(y) * s     

operator = {"+":(lambda x,y: x+y),
            "-":(lambda x,y: x-y),
            "*":(lambda x,y: x*y),
            "/":divide
            }

def ind(src, x):
    if x not in src:return 1<<30
    return src.index(x)
 
def _split(_src):
    c = 0
    l = len(_src)
    if l == 0:
        return []
    while c < l and ord('0') <= ord(_src[c]) <= ord('9'):
        c += 1

    if c == 0:
        return [_src[0]] + _split(_src[1:])
    else:
        return [int(_src[:c])] + _split(_src[c:])
         
 
def evaluate(src):
    if len(src) == 1:
        return src[0]
         
    if "(" in src:
        l = src.index("(")
        r = l
        st = 1
        while st:
            r += 1
            if src[r] == "(": st += 1
            if src[r] == ")": st -= 1
        
        mid = evaluate(src[l + 1:r])
        return evaluate( src[:l] + [mid] + src[r + 1:])
    
    if "*" in src or "/" in src:
        pos = min(ind(src, "*"), ind(src,"/"))
        op = src[pos]
        l, r = src[pos - 1], src[pos + 1]
        mid = operator[op](l, r)
        return evaluate(src[:pos - 1] + [mid] + src[pos + 2:])
    
    else:
        pos = min(ind(src, "+"), ind(src, "-"))
        op = src[pos]
        l, r = src[pos - 1], src[pos + 1]
        mid = operator[op](l, r)
        return evaluate(src[:pos - 1] + [mid] + src[pos + 2:])
     
for t in xrange(input()):
    _src = raw_input().strip("=")
    src = _split(_src)
    print evaluate(src)

Measured memory_bytes: 4384
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 100, MAXI = 100001, D = 9;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 100, flag = 1;
//     cout << tc << "\n";
//     int n = 1;

//     while (tc--)
//     {
    	
//     	int n = rand()%N + 1, m = rand()%N + 1;

//     	int a[n][m];
//     	for(int i=0;i<n;i++)
//     	{
//     		for(int j=0;j<m;j++)
//     		{
//     			int flag = rand()%4;
//     			if(flag==0)
//     				a[i][j] = -1;
//     			else
//     				a[i][j] = rand()%MAXI;
//     		}
//     	}

//     	a[n-1][0] = rand()%MAXI;

//     	cout << n << " " << m << "\n";
//     	for(int i=0;i<n;i++){
//     		for(int j=0;j<m;j++)
//     			cout << a[i][j] << " ";
//     		cout << "\n";
//     	}

//     	cout << "~\n";
//     }
 
//     return 0;
// }
 
 
//  int n, a[N];

// int MEM(int ind, vector<int> &v)
// {
// 	if(ind==n)
// 	{
// 		// o(n)
// 	}

// 	int ans = 0;
// 	if(a[ind]==-1)
// 	{
// 		for(int i=0;i<n;i++)
// 		{
// 			if(i!=ind)
// 			{
// 				v[ind] = i;
// 				ans += MEM(ind+1, v);
// 				if(ans>=mod)
// 					ans %= mod;
// 			}
// 		}
// 	}
// 	else
// 		ans = MEM(ind+1, v);

// 	return ans;

// }
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 

//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(3e17+10)
#define N 1005




// Driver code to test above functions
int32_t main()
{
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	cout.tie(NULL);

	
	int a;
	double b;

	cin >> a >> b;

	int bb = b*100;
	bb--;

	for(;abs(b*100*1.0 - bb)>0.5;bb++){}

	cout << a * bb/100;

	

    return 0;
 
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    ll A[n];
    for(ll& x : A) cin >> x;
    ll dp[k + 1];
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for(ll i = 1; i <= n; ++i){
        ll fake[k + 1];
        memset(fake, 0, sizeof(fake));
        for(ll j = k; j >= 0; --j){
            int temp = dp[j];
            int L = j + 1;
            int R = j + min(k - j, A[i - 1]);
            fake[L] = (fake[L] + temp) % mod;
            if(R + 1 <= k) fake[R + 1] = (fake[R + 1] - temp + mod) % mod;
            //for(int t = 1;t <= A[i - 1]; ++t) dp[j + t] += dp[j];
        }
        ll prefix_sum = 0;
        for(int i = 0; i <= k; ++i){
            prefix_sum = (prefix_sum + fake[i]) % mod;
            dp[i] = (dp[i] + prefix_sum) % mod;
        }
    }
    cout << dp[k] << endl;
    return 0;
}

Measured memory_bytes: 1920
X = int(input())

if X<100:
    print(0)
    exit()

X100over = X//100
X10 = X%100

X5 = X10//5
X1to4 = X10%5 !=0

if X5+X1to4 <= X100over:
    print(1)
else:
    print(0)


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

struct vec
{
    double x, y;
    vec (const double& x0 = 0, const double& y0 = 0) : x(x0), y(y0) {}
    vec operator + (const vec& t) const {return vec(x+t.x, y+t.y);}
    vec operator - (const vec& t) const {return vec(x-t.x, y-t.y);}
    vec operator * (const double& t) const {return vec(x*t, y*t);}
    vec operator / (const double& t) const {return vec(x/t, y/t);}
    const double len2 () const {return x*x + y*y;}
    const double len () const {return sqrt(len2());}
    vec norm() const {return *this/len();}
    vec rotate_90_c () {return vec(y, -x);}
};

double dot(const vec& a, const vec& b) {return a.x*b.x + a.y*b.y;}
double crs(const vec& a, const vec& b) {return a.x*b.y - a.y*b.x;}

vec lin_lin_int(const vec& p0, const vec& v0, const vec& p1, const vec& v1)
{
    double t = crs(p1-p0, v1) / crs(v0, v1);
    return p0 + v0 * t;
}

vec circle(const vec& a, const vec& b, const vec& c)
{
    return lin_lin_int((a+b)/2, (b-a).rotate_90_c(), (a+c)/2, (c-a).rotate_90_c());
}

int n;
vec pot[100005];

int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++) cin>>pot[i].x>>pot[i].y;
    random_shuffle(pot+1, pot+n+1);
    vec o;
    double r2 = 0;
    for(int i=1; i<=n; i++)
    {
        if((pot[i]-o).len2() > r2)
        {
            o = pot[i], r2 = 0;
            for(int j=1; j<i; j++)
            {
                if((pot[j]-o).len2() > r2)
                {
                    o = (pot[i]+pot[j])/2, r2 = (pot[j]-o).len2();
                    for(int k=1; k<j; k++)
                    {
                        if((pot[k]-o).len2() > r2)
                        {
                            o = circle(pot[i], pot[j], pot[k]), r2 = (pot[k]-o).len2();
                        }
                    }
                }
            }
        }
    }
    printf("%.16f\n", sqrt(r2));
    return 0;
}

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

int main()
{
  int n, ans = 0;
  vector<int> d(50);

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> d[i];
  for (int i = 0; i < n - 1; i++)
  {
    for (int j = i + 1; j < n; j++)
      ans += d[i] * d[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define MAXN 105
using namespace std;

long long N, W, w[MAXN], v[MAXN], dp[MAXN][100005];

int main() {
	cin >> N >> W;
	for (int i=0; i<N; i++) {
		cin >> w[i] >> v[i];
	}
	dp[0][w[0]] = v[0];
	for (int i=1; i<N; i++) {
		for (int j=0; j<=W; j++) {
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if (j - w[i] < 0) continue;
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}

	// for (int i=0; i<N; i++) {
	// 	for (int j=1; j<=W; j++) {
	// 		cout << dp[i][j] << ' ';
 // 		}
 // 		cout << "\n";
	// }

	long long ans = 0;
	for (int i=0; i<=W; i++) {
		ans = max(ans, dp[N - 1][i]);
	}
	cout << ans << "\n";
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  string ans = "No";
  for (int i=0; i<=X; i++) {
    if (i*2 + (X-i)*4 == Y) {
      ans = "Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
n=int(input())
a= list(map(int, input().split()))
# 寿司の皿を乗ってる寿司の数で分ける
x=[0,0,0]
for i in range(n):
    x[a[i]-1]+=1

# dp[k][i][j]:k3個、i2個、j1個の寿司が乗ってる皿の数。そこからの全部0になる回数の期待値
dp=[[[0]*(n+2) for i in range(n+2)] for j in range(n+2)]

for k in range(n+1):
    for i in range(n+1):
        for j in range(n+1):
            v=k+i+j
            if 0<v<=n:
                dp[k][i][j]+=(dp[k][i][j-1]*j+dp[k][i-1][j+1]*i+dp[k-1][i+1][j]*k+n)/v

print(dp[x[2]][x[1]][x[0]])

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

int main(void){

	long long int a,b,c,k;

	scanf("%lld %lld %lld %lld",&a,&b,&c,&k);

	if(a >= k){
		printf("%lld\n",k);
	}else if(a + b >= k){
		printf("%lld\n",a);
	}else{
		printf("%lld\n",a - k + a + b );

	}





	return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,tota,totb,a[N],b[N];
vector<pair<int,int> >ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x<=0) a[++tota]=x;
        else b[++totb]=x;
    }
    if(n==2)
    {
        if(totb==0)
        {
            sort(a+1,a+1+tota);
            printf("%d\n",a[2]-a[1]);
            printf("%d %d\n",a[2],a[1]);
        }
        else if(tota==0)
        {
            sort(b+1,b+1+totb);
            printf("%d\n",b[2]-b[1]);
            printf("%d %d\n",b[2],b[1]);
        }
        else
        {
            printf("%d\n",b[1]-a[1]);
            printf("%d %d\n",b[1],a[1]);
        }
        return 0;
    }
    if(tota==0)
    {
        sort(b+1,b+1+totb);
        a[++tota]=b[1]-b[totb];
        ans.push_back({b[1],b[totb]});
        for(int i=2;i<totb;i++)
            b[i-1]=b[i];
        totb-=2;
    }
    if(totb==0)
    {
        sort(a+1,a+1+tota);
        b[++totb]=a[tota]-a[1];
        ans.push_back({a[tota],a[1]});
        for(int i=2;i<tota;i++)
            a[i-1]=a[i];
        tota-=2;
    }
    while(totb>1)
    {
        ans.push_back({a[1],b[totb]});
        a[1]=a[1]-b[totb];
        totb--;
    }
    for(int i=1;i<=tota;i++)
    {
        ans.push_back({b[1],a[i]});
        b[1]=b[1]-a[i];
    }
    printf("%d\n",b[1]);
    for(int i=0;i<ans.size();i++)
        printf("%d %d\n",ans[i].first,ans[i].second);
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s, t;
    cin >> s >> t;
    
    int cnt = 0;
    for(int i = 0;i < s.size();i++){
        if(s[i] != t[i]){
            cnt++;
        }
    }
    
    cout << cnt;
    
    return 0;
}


Measured memory_bytes: 3912
n=int(input())
s=str(input())

#n = 9
#s = "........."
#print(s)
#print(len(s))

memo = []
countwb=0
now = s[0]
count = 0
if now == "#":
    memo.append(0)
while(count<n):
    if s[count]==now:
        countwb+=1
    else:
        memo.append(countwb)
        countwb = 1
        now = s[count]
    count+=1
memo.append(countwb)
#print(memo)

memo_r=[]
for i in range(len(memo)):
    memo_r.append(memo[-1*(i+1)])
#print(memo_r)

count_w = []
c_w = 0
if len(memo_r)%2==1:
    count_w.append(0)
    for  i in range(0,len(memo_r),2):
            c_w += memo_r[i]
            count_w.append(c_w)
else:
    count_w.append(0)
    count_w.append(0)
    for  i in range(1,len(memo_r),2):
            c_w += memo_r[i]
            count_w.append(c_w)
#print(count_w)

count_b = []
count_b.append(0)
count_b.append(0)
c_b = 0
for  i in range(1,len(memo),2):
        c_b += memo[i]
        count_b.append(c_b)
#print(count_b)

count_list = []
for i in range(len(count_b)):
    temp = count_w[-1*(i+1)]+count_b[i]
    count_list.append(temp)
#print(count_list)

print(min(count_list))

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

int main() {
    long long int n, ans_aj;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a+n);
    ans_aj = a[0];
    for(int i = 0; i < n - 1; ++i) {
        if(abs(a[n-1]/2.0 - ans_aj) > abs(a[n-1]/2.0 - a[i]))
            ans_aj = a[i];
    }
    
    cout << a[n-1] << " " << ans_aj << '\n';
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    string A,B,C;
    cin >> N;
    cin >> A >> B >> C;
    int ans=0;
    rep(i,N){
        if(A[i]==B[i] && B[i]==C[i]) ans+=0;
        else if(A[i]!=B[i] && B[i]!=C[i] && C[i]!=A[i]) ans+=2;
        else ans+=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
const ll MOD = 998244353;
const int INF = 1e9+9;
const int MAXN = 1000006;


int n, m, k, t, arr[MAXN];
bool feasible = true;
string s;
char c;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cout << 360/gcd(n,360) << endl;
}


Measured memory_bytes: 3652
import math

if __name__ == "__main__":
    N = int(input())
    n = 100
    f =[0]*10000000
    for x in range(1,n):
        for y in range(1,n):
            for z in range(1,n):
                f[x*x + y*y + z*z + x*y + y*z + z*x-1] += 1

    for i in range(N):
        print(f[i])


Measured memory_bytes: 87336
def digits(k, x):
    ans = 0
    while (k):
        ans += 1
        k //= x
    print(ans)

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    k, x = [int(_) for _ in in_str[0].split(' ')]
    digits(k, x)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Arrays;

class Main {
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] H = new int[N];
        for(int i = 0; i < N; i++) {
          H[i] = sc.nextInt();
          //System.out.println(H[i]);
        }
        Arrays.sort(H);
      	
        for(int i = 1; i <= K; i++) {
          if(N <= K) {
          	for(int j = 0; j < N; j++) {
          		H[j] = 0;  
        	}
            break;
          }
          H[N-i] = 0;
        }
    	
        long count = 0;
        for(int j = 0; j < N; j++) {
          count += H[j];  
        }
        System.out.println(count);
    }
}

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

int main()
{
    int x, y;
    cin >> x >> y;
    int sum = 0;
    if(x == 1) sum += 300000;
    if(x == 2) sum += 200000;
    if(x == 3) sum += 100000;
    if(y == 1) sum += 300000;
    if(y == 2) sum += 200000;
    if(y == 3) sum += 100000;
    if(x == 1 && y == 1) sum += 400000;
    cout << sum << endl;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

int main() {
  int n; cin >> n;
  vector<ll> A(n);
  loop(i,0,n) cin >> A[i];
  map<int, int> M;
  ll ans = 0;
  loop(i,1,n+1) {
    ll v = i+A[i-1];
    if (i==1) {
      if (v<200000) M[v]++;
      continue;
    }
    ll val = i - A[i-1];
    if (val >= 0) {
      ans += M[val];
    }
    if (v<200000) M[v]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12908
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
INF=10**9

def dfs(cur,a,b,c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
# include <bits/stdc++.h>
# define ll long long
# define f first
# define s second
using namespace std;
const int N = 2e5 + 10;
pair < int, int > x[N];
int timer = 0;
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int a, b;
		cin >> a >> b;
		x[i].f = b;
		x[i].s = a;
	}
	sort(x + 1, x + n + 1);
	for(int i = 1; i <= n; i++){
		timer += x[i].s;
		if(timer > x[i].f){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,K,count=0,flag=1;cin>>N>>M>>K;
  vector<int> a;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      a.push_back(i*M+j*N-i*j*2);
      count++;
    }
  }
  for(int i=0;i<count;i++){
    if(K==a.at(i)){
      flag=0;
      break;
    }
  }
  if(flag==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 6256
fun main(args: Array<String>) {
    val S = readInputLine().toCharArray()
    
    var ans = 0
    var prev = ""
    var now = ""
    
    for (c in S) {
        now = now + c.toString()
        if (prev != now) {
            ans++
            prev = now
            now = ""
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;

int main(){
        int N;
        cin>>N;
        vector <int> A(N);
        for(int i=0;i<N;i++){
                cin>>A[i];
        }
        int res=0, ans=0;
        sort(A.begin(), A.end());
        for(int i=0;i<N;i++){
                int cnt=1;
                //cout<<A[i]<<":";
                for(int j=i+1;j<N;j++){
                        if(A[i]==A[j]){
                                cnt++;
                                if(j==N-1){
                                        i=j;
                                        break;
                                }
                        }
                        else{
                                i=j-1;
                                break;
                        }
                }
                //cout<<cnt<<endl;
                res++;
                ans+=(cnt-1);
        }
        //cout<<res<<endl;
        if(ans%2!=0){
                res--;
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a[110],k,cnt[110];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    sort(a,a+n);
    k=a[n-1];
    if(cnt[k]==1){
        puts("Impossible");
        return 0;
    }
    if(k%2==0){
        for(int i=k/2;i<=k;i++){
            rep(j,(i==k/2?1:2)){
                if(cnt[i]==0){
                    puts("Impossible");
                    return 0;
                }
                cnt[i]--;
            }
        }
        for(int i=1;i<=k/2;i++){
            if(cnt[i]){
                puts("Impossible");
                return 0;
            }
        }
        puts("Possible");
    }
    else{
        for(int i=(k+1)/2;i<=k;i++){
            rep(j,2){
                if(cnt[i]==0){
                    puts("Impossible");
                    return 0;
                }
                cnt[i]--;
            }
        }
        for(int i=1;i<=(k+1)/2;i++){
            if(cnt[i]){
                puts("Impossible");
                return 0;
            }
        }
        puts("Possible");
    }
	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val ab = (0 until m).map { sc.next().toInt() to sc.next().toInt() }
    println(problem168d(n, m, ab))
}

fun problem168d(n: Int, m: Int, ab: List<Pair<Int, Int>>): String {
    val routes = Array(n + 1) { mutableListOf<Int>() }
    for (i in 0 until m) {
        val (a, b) = ab[i]
        routes[a].add(b)
        routes[b].add(a)
    }

    val distances = IntArray(n + 1) { -1 }
    val parents = IntArray(n + 1) { -1 }
    val queue = ArrayDeque<Int>()
    queue.offer(1)
    distances[1] = 0

    while(!queue.isEmpty()) {
        val current = queue.poll()
        for (i in 0 until routes[current].size) {
            val next = routes[current][i]
            if (distances[next] != -1) continue

            distances[next] = distances[current] + 1
            parents[next] = current
            queue.offer(next)
        }
    }
    return "Yes\n" + parents.drop(2).map { it }.joinToString("\n")
}

Measured memory_bytes: 92432
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    string s, t;
    cin >> s >> t;
    string no = "UNRESTORABLE";
    string ans(200, 'z');
    auto f = [&] (int m) {
        bool f = true;
        REP(i, m, m + t.size()) {
            if(i >= s.size()) return string();
            if(s[i] == '?') continue;
            if(s[i] != t[i - m]) return string();
        }
        string tmp;
        rep(i, m) {
            if(s[i] == '?') tmp += 'a';
            else tmp += s[i];
        }
        REP(i, m, m + t.size()) tmp += t[i - m];
        REP(i, m + t.size(), s.size()) {
            if(s[i] == '?') tmp += 'a';
            else tmp += s[i];
        }
        return tmp;
    };
    rep(i, s.size()) {
        string tmp = f(i);
        if(!tmp.empty()) {
            ans = min(ans, tmp);
        }
    }
    cout << (ans == string(200, 'z') ? no : ans) << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__);
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
const int INF = 1e18;
const int MX = 1000001;


int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    string s,t;
    cin>>s>>t;
    int res= t.size();
    for(int i = 0;i<=s.size()-t.size();i++){
        int diff= 0;
        for(int j = 0;j<t.size();j++){
            if(t[j]!=s[i+j])diff++;
        }
        res= min(res,diff);

    }
    cout<<res<<endl;
    
 
    return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T>
using MaxHeap = priority_queue<T, vector<T>, less<T>>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline void input(vector<T> &vec) {
    for (auto &e: vec) {
        cin >> e;
    }
}

template <class T>
inline void input(vector<vector<T>> &mat) {
    for (auto &vec: mat) {
        input(vec);
    }
}

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &strm, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        strm << e << delim[&e == &vec.back()];
    }
    return strm;
}

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(string, s, t);

    var(size_t, a, b);
    map<string, size_t> mp;
    mp[s] = a, mp[t] = b;

    var(string, u);
    mp[u]--;

    print(mp[s], mp[t]);

    return 0;
}


Measured memory_bytes: 256
/**
 *   Praveen Fulera    
**/


// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

typedef long long int ll;

#define endl '\n'
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl

void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "\n[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve(){
    int n; cin >> n;
    bool fl = false;
    for(int i = 1; i <= n; i++){
        int x; cin >> x;
        if(x&1) continue;
        if(x%3 && x%5){
            fl = true;
        }
    }
    if(fl) cout << "DENIED\n";
    else cout << "APPROVED\n";
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
        clock_t t1 = clock();
  int t = 1; //cin >> t;
  while(t--){      
     solve();
  }
        clock_t t2 = clock();
  //cout << "Time-Taken: " << ((t2 - t1) / (double)CLOCKS_PER_SEC) << endl;      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

vector<Int> A(3), B(3);

Int secondB(Int N){
  
  Int res = N;
  for(int k=0;k<3;k++){
    swap(A[0], A[2]), swap(A[0], A[1]);
    swap(B[0], B[2]), swap(B[0], B[1]);
    
    for(Int i=0; i <= 8001;i++){
      for(Int j=0;j <= 8001;j++){
	Int a = i;
	Int b = j;
	Int r = (N - (a * B[0] + b * B[1]));
	if(r < 0) break;
	Int c = r / B[2];
	Int t = r % B[2];
	Int M = a * A[0] + b * A[1] + max(c * A[2] + t, r);
	Max(res, M);
      }
    }
  }
  return res;
}

Int firstA(Int N){
    for(Int i=0;i<3;i++)
      for(Int j=2;j>0;j--) if(A[j-1] < A[j]) swap(B[j], B[j-1]) , swap(A[j], A[j-1]);
    
  Int res = N;
  for(Int i=0;i <= N;i++){
    for(Int j=0;j <= N;j++){
      Int a = i;
      Int b = j;
      Int r = (N - (a * A[0] + b * A[1]));
      Int c =  r/ A[2];
      Int t = r % A[2];
      if(r < 0) break;
      //assert(r >= 0);
      Int M = a * B[0] + b * B[1] + max(c * B[2] + t, r);
      Max(res, M);
    }
  }
  return secondB(res);
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  Int N;
  cin>>N;
  cin>>A>>B;

  Int ans = firstA(N);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

class WF{
	public:
	ll N;
	ll makeFlg;
	vector<vector<ll> >cost;
	WF(ll _N, ll INF = 1145141919){
		N = _N + 1;
		cost = vector<vector<ll> >(N, vector<ll>(N, INF));
		makeFlg = 0;
	}
	void add(ll a, ll b, ll c){
		cost[a][b] = min(cost[a][b], c);
		makeFlg = 0;
	}
	void make(){
		if(makeFlg)return;
		makeFlg = 1;
		for(ll i = 0; i < N; i++){
			for(ll j = 0; j < N; j++){
				for(ll k = 0; k < N; k++){
					cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
				}
			}
		}
	}
	ll get(ll a, ll b){
		if(makeFlg == 0)make();
		return cost[a][b];
	}
};

int main(){

    ll N, M;
    cin >> N >> M;
    WF wf(N);
    rep(i, M){
        ll a, b;
        cin >> a >> b;
        wf.add(a, b, 0);
    }
    rep1(i, N){
        vector<ll>ans;
        rep1(j, N){
            if(i == j)ans.push_back(j);
            else if(wf.get(i, j) == 0 && wf.get(j, i) == 0)ans.push_back(j);
        }
        rep(j, ans.size()){
            cout << ans[j];
            if(j + 1 == ans.size())cout << endl;
            else cout << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define bigint int64_t
#define vll vector<ll>
#define pll ar<ll,2>
#define vpll vector<pll>
#define pb push_back
#define MOD 1000000007
#define sz(x) (ll)(x).size()
#define ff first
#define ss second
#define en cout<<"\n"
#define LCM(a,b) (a*(b/__gcd(a,b)))
#define all(v) v.begin(),v.end()
#define maxqueue    priority_queue<int>
#define minqueue    priority_queue<int,vector<int>,greater<int> >
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
#define INF (ll)(1e18)
#define ini(a,b) memset(a,b,sizeof(a))
#define vvll vector<vector<ll>>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define prec(n) fixed<<setprecision(n)
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define forn(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define deb1(x)                cerr<<#x<<": "<<x<<endl
#define deb2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define GET5(a, b, c, d, e, ...) e
#define D_EBC(...) GET5(__VA_ARGS__, deb4, deb3, deb2, deb1)
#define deb(...) D_EBC(__VA_ARGS__)(__VA_ARGS__)
#define each(x, a) for (auto& x: a)

using namespace std;

template <typename T>
void read(T &x) {
    cin >> x;
}
template <typename T , typename T0>
void read(T &x, T0 &y) {
    cin >> x >> y;
}

template <typename T , typename T0 , typename T1>
void read(T &x, T0 &y, T1 &z) {
    cin >> x >> y >> z;
}

template <typename T , typename T0 , typename T1 , typename T2>
void read(T &x, T0 &y, T1 &z, T2 &w) {
    cin >> x >> y >> z >> w;
}

template <typename T>
void read(vector< T > &oneD, ll n) {
    for (ll i = 0; i < n; i++) {
        read(oneD[i]);
    }

}

template <typename T>
void read(T oneD[] , ll n) {
    for (ll i = 0; i < n; i++) {
        read(oneD[i]);
    }
}

const ll N=1e5;
ll dp[N+1];
void solve(){
    ll n,k;
    read(n,k);
    ll arr[n];
    read(arr,n);
    dp[0]=0;
    forn(i,1,n){
        dp[i]=MOD;
        forn(j,1,k+1){
        if(i-j>=0)
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    cout<<dp[n-1];
}

int main() {
    fast;
    int t=1;
    // read(t);
    forn(t) {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}


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

int count[50];

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

	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;

		for (int j = 0; j < k; j++) {
			int a;
			cin >> a;
			count[a - 1]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (count[i] == n) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
/*input
4
0 1 1 2
*/
#include<bits/stdc++.h>
using namespace std;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
typedef long double ld;
#define pii pair<ld,ld>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=50005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-8;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main() {
    int n;
    cin>>n;
    int fr[n];
    FILL(fr,0);
    for (int i = 0; i < n; i++) {
        int e;
        cin >> e;
        fr[e]++;
        if (i == 0 && e) {
            cout << 0;
            return 0;
        }
    }
    if (fr[0] != 1) {
        cout << 0;
        return 0;
    }
    int l = -1;
    REP(i,n){
        if (fr[i] == 0) break;
        l = i;
    }

    for(int i=l+1;i<n;i++){
        if (fr[i]) {
            cout << 0;
            return 0;
        }
    }
    ll ans = 1;
    REP1(i,n-2){
        if (fr[i] == 0) break;
        ans *= mypow(fr[i], fr[i + 1]);
        ans %= 998244353;
    }

    cout << ans;

}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll X;
    cin >> X;

    if(X >= 30) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 3620
N = gets.to_i
S = gets.chomp
bs = 0
ws = S.count(".")
ans = bs + ws
(0...N).each{ |i|
  if S[i] == "."
    ws -= 1
  else
    bs += 1
  end
  v = ws + bs
  ans = v if v < ans
}
p ans


Measured memory_bytes: 2172
class Arrow
  attr_reader :source, :sink, :label
  
  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

class Result
  attr_reader :target, :spell

  def initialize(target, spell)
    @target = target
    @spell = spell
  end
end

def advance(table, n, goes, arrows)
  next_table = [nil] * n
  (0...n).each do |node|
    best = table[node]
    goes[node].each do |arrow|
      result = table[arrow.sink]
      next unless result
      test = arrow.label + result.spell
      if !best || test < best.spell
        best = Result.new(arrow.sink, test)
      end
    end
    next_table[node] = best if best
  end
  next_table
end

def check(table, result, n)
  used = [false] * n
  loop do
    node = result.target
    return true unless node
    return false if used[node]
    used[node] = true
    result = table[node]
  end
end

def work(n, arrows, start, goal)
  goes = (0...n).map{[]}
  arrows.each do |arrow|
    goes[arrow.source] << arrow
  end
  table = {goal => Result.new(nil, '')}
  n.times do
    table = advance(table, n, goes, arrows)
  end
  unless table[start]
    puts 'NO'
    return
  end
  (n*5).times do
    table = advance(table, n, goes, arrows)
  end
  result = table[start]
  puts check(table, result, n) ? result.spell : 'NO'
end

loop do
  n, a, s, g = STDIN.gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = STDIN.gets.split
    x = x.to_i
    y = y.to_i
    Arrow.new(x, y, lab)
  end

  start = s
  goal = g

  work(n, arrows, start, goal)
end

Measured memory_bytes: 23868