akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()
{
    IOS;
    int k,s,ans = 0;
    cin>>k>>s;
    FOR(x,0,k+1)
    {
        FOR(y,0,k+1)
        {
            int z = s - x - y;
            if(z>=0 && z<=k) ans++;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

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

 
int main()
{
  vector<ll> a(4);
  rep(i,4) cin >> a[i];
  
  vector<ll> pro;
  rep(i,2)rep(j,2) pro.emplace_back(a[i]*a[j+2]);
  
  ll ans = LLONG_MIN;
  rep(i,4) ans = max(ans, pro[i]);
  cout << ans << endl;
}

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

int64_t MOD = 1e9 + 7;

int64_t factorial(int64_t x)
{
    int64_t sum = 1;
    for (int64_t i = 1; i <= x; i++)
    {
        sum = ((sum % MOD) * (i % MOD)) % MOD;
    }
    return (sum % MOD);
}

int main()
{
    int64_t N, M;
    cin >> N >> M;
    if (abs(N - M) > 1)
        cout << 0 << endl;
    else if (N == M)
    {
        int64_t n, m, ans;
        n = factorial(N);
        m = factorial(M);
        ans = (2 * (n % MOD) * (m % MOD)) % MOD;
        ans = ans % MOD;
        cout << ans << endl;
    }
    else
    {
        int64_t n, m, ans;
        n = factorial(N);
        m = factorial(M);
        ans = ((n % MOD) * (m % MOD)) % MOD;
        ans = ans % MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g; cin >> r >> g;
    cout << 2 * (g - r) + r << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

int k;

int func(vi &v)
{
	int n = v.size(), ans = (int)-1e15, tot = 0;
	f(i, 0, n) v.pb(v[i]);
	n *= 2ll;
	int m = n/2ll;
	int sum[m+1], pre[n+1] = {};
	f(i, 1, n+1) pre[i] = pre[i-1]+v[i-1];
	f(i, 0, m) tot += v[i];
	f(i, 0, m+1) sum[i] = -(int)1e15;
	f(l, 1, m+1)
	{
		f(j, 0, m)
		{
			int s = j+1, e = j+l;
			if(e > n) break;
			sum[l] = max(sum[l], pre[e]-pre[s-1]);
		}
	}
	if(k/m) ans = max(ans, tot*(k/m));
	f(i, 1, m+1)
	{
		if(k < i) continue;
		int x = max(0ll, tot*((k-i)/m));
		ans = max(ans, x+sum[i]);
	}
	return ans;
}

void solve()
{
	int n;
    vector <vi> allPerm;
    cin>>n>>k;
    int p[n], c[n], visited[n] = {};
    f(i, 0, n) cin>>p[i], p[i]--;
    f(i, 0, n) cin>>c[i];
    f(i, 0, n)
    {
    	int j = i;
    	vi temp;
    	while(!visited[j])
    	{
    		temp.pb(c[j]);
    		visited[j] = 1;
    		j = p[j];
    	}
    	if(temp.size()) allPerm.pb(temp);
    }
    int m = allPerm.size(), ans = (int)-1e15;
    f(i, 0, m) ans = max(ans, func(allPerm[i]));
    cout<<ans<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

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

int n, c[5005], p[5005], k;
typedef long long ll;
vector<ll> dists;
ll curr, ans;
#define INF  1023456789123456789
//#define debug

int main(){
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i){
        scanf("%d", &p[i]);
    }
    for (int i = 1; i <= n; ++i){
        scanf("%d", &c[i]);
    }
    ans = -INF;
    for (int i = 1; i <= n; ++i){
        curr = 0;
        dists.clear();
        int tmp = p[i];
        dists.push_back(c[p[i]]);
        while (tmp != i){
            dists.push_back(dists[dists.size() - 1] + c[p[tmp]]);
            tmp = p[tmp];
        }
        ll cycle_size = dists.size();
        #ifdef debug
        for (int j = 0; j < cycle_size; ++j){
            printf("%lld ", dists[j]);
        }
        printf("\n");
        #endif //debug
        if (dists[cycle_size - 1] > 0){
            //printf("%lld\n", dists[cycle_size - 1]);
            curr += dists[cycle_size - 1] * (k / cycle_size - 1);
            ll nk = k - cycle_size * (k / cycle_size - 1);
            ll t = 0;
            for (int j = 0; j < nk; ++j){
                if (j < cycle_size){
                    t = max(t, dists[j % cycle_size]);
                }
                else{
                    t = max(t, dists[j % cycle_size] + dists[cycle_size - 1]);
                }
            }
            //printf("%lld %lld\n", curr, curr + t);
            curr += t;
        }
        else{
            ll t = dists[0];
            for (int j = 1; j < cycle_size; ++j){
                t = max(t, dists[j]);
            }
            curr = t;
        }
        //printf("%lld\n", curr);
        ans = max(ans, curr);
    }
    printf("%lld", ans);
}


Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
const int E = (int)2e6 + 7;
const int INF1 = (int)1e6;
const ll INF2 = (ll)1e15;

struct Edge {
	int v, to;
	ll cap;

	Edge() : v(), to(), cap() {}
	Edge(int _v, int _to, ll _cap) : v(_v), to(_to), cap(_cap) {}
};
Edge ed[E];
int edSz;
vector<int> g[N];
int dist[N];
int qq[N];
int topQ;
int idx[N];
int S, T;

void addEdge(int v, int to, ll cap) {
	ed[edSz] = Edge(v, to, cap);
	g[v].push_back(edSz++);
	ed[edSz] = Edge(to, v, 0);
	g[to].push_back(edSz++);
}

bool BFS() {
	for (int i = 0; i <= T; i++)
		dist[i] = INF1;
	dist[S] = 0;
	topQ = 0;
	qq[topQ++] = S;
	for (int i = 0; i < topQ; i++) {
		int v = qq[i];
		for (int id : g[v]) {
			Edge e = ed[id];
			if (e.cap <= 0) continue;
			int to = e.to;
			if (dist[to] <= dist[v] + 1) continue;
			dist[to] = dist[v] + 1;
			qq[topQ++] = to;
		}
	}
	return dist[T] < INF1;
}
ll dfs(int v, ll flow) {
	if (v == T || flow == 0) return flow;
	ll res = 0;
	for (int &i = idx[v]; i < (int)g[v].size(); i++) {
		int id = g[v][i];
		Edge e = ed[id];
		int to = e.to;
		if (dist[to] != dist[v] + 1) continue;
		ll df = dfs(to, min(flow, e.cap));
		res += df;
		flow -= df;
		ed[id].cap -= df;
		ed[id ^ 1].cap += df;
		if (flow == 0) return res;
	}
	return res;
}
ll Flow() {
	ll res = 0;
	while(BFS()) {
		for (int i = 0; i <= T; i++)
			idx[i] = 0;
		res += dfs(S, INF2);
	}
	return res;
}

int n, m;
int p[N], q[N];
int pv[N], qv[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &p[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &q[i]);
	for (int i = 0; i < n; i++)
		pv[i] = qv[i] = -1;
	for (int i = 0; i < n; i++) {
		if (pv[i] != -1) continue;
		int x = i;
		while(pv[x] == -1) {
			pv[x] = m;
			x = p[x];
		}
		m++;
	}
//	int mid = m;
	for (int i = 0; i < n; i++) {
		if (qv[i] != -1) continue;
		int x = i;
		while(qv[x] == -1) {
			qv[x] = m;
			x = q[x];
		}
		m++;
	}
	S = m;
	T = S + 1;
	for (int i = 0; i < m; i++) {
		addEdge(S, i, INF1);
		addEdge(i, T, INF1);
	}
	for (int i = 0; i < n; i++) {
		if (p[i] == i) {
			addEdge(S, pv[i], INF1);
		}
		if (q[i] == i) {
			addEdge(qv[i], T, INF1);
		}
		addEdge(pv[i], qv[i], 1);
		if (p[i] == q[i])
			addEdge(qv[i], pv[i], 1);
	}
	printf("%lld\n", (ll)m * INF1 + n - Flow());

	return 0;
}


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

typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int n, M;
ll ans = 0, num = 0;
int main()
{
    cin >> n >> M;
    vector<pair<long long, long long>> a(n);
    rep(i, 0, n)
    {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end());
    for (auto v : a)
    {
        if (num >= M)
        {
            break;
        }
        else if (num + v.second <= M)
        {
            num += v.second;
            ans += v.first * v.second;
        }
        else
        {
            ans += v.first * (M - num);
            num = M;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	long int q;
	cin>>q;
 	int rev_count=0;
	string beg,end;
	while(q--){
		int t;
		cin>>t;
		if(t==1){
			rev_count=1-rev_count;
		}
		else if(t==2){
			int f;
			cin>>f;
			string x;
			cin>>x;
			if(rev_count==0){
			if(f==1){
				beg+=x;
			}
			else if(f==2){
				end+=x;
				}
			}
			else if(rev_count==1){
				if(f==2){
				beg+=x;
			}
			else if(f==1){
				end+=x;
				}
			}
		}
	}
	reverse(beg.begin(),beg.end());
	beg+=s;
	beg+=end;
	if(rev_count==1)
	reverse(beg.begin(),beg.end());
	cout<<beg;
	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
using namespace std;
int main(){
  int h;
  while (cin>>h,h|h!=0){
    string temp;
    int board[h][6];
    for (int i=0;i<h;i++){
      cin>>board[i][0]>>board[i][1]>>board[i][2]>>board[i][3]>>board[i][4];
    }
    int num,count;
    int check=0;
    int score=0;
    while (1){
      check=score;
      for (int i=h-2;i>=0;i--){
	for (int j=0;j<5;j++){
	  for (int k=h-1;k>i;k--){
	    if (board[k][j]==0){
	      board[k][j]=board[i][j];
	      board[i][j]=0;
	      break;
	    }
	  }
	}
      }
      for (int i=0;i<h;i++){
	count=1;
	num=0;
	for (int j=0;j<5;j++){
	  if (board[i][j]==num){
	    count++;
	  }
	  else{
	    if (count>2)
	      break;
	    count=1;
	  }
	  num=board[i][j];
	}
	if (count<=2)
	  num=0;
	score=score+num*count;
	int ii=0;
	for (int j=0;j<5;j++){
	  if ((ii==count-1||j==4||board[i][j+1]==num)&&board[i][j]==num){
	    board[i][j]=0;
	    ii++;
	  }
	  if (ii==count)
	    break;
	}
      }
      /* for (int i=0;i<h;i++){
	for (int j=0;j<5;j++){
	  cout<<board[i][j]<<" ";
	}
	cout<<endl;
	}*/
      if (check==score){
	break;
      }
      // cout<<" "<<score<<endl;
    }

    cout<<score<<endl; 
  }
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;

public class Main { // Template for CF
    public static class ListComparator implements Comparator<List<Integer>> {

        @Override
        public int compare(List<Integer> l1, List<Integer> l2) {
            for (int i = 0; i < l1.size(); ++i) {
                if (l1.get(i).compareTo(l2.get(i)) != 0) {
                    return l1.get(i).compareTo(l2.get(i));
                }
            }
            return 0;
        }
    }

    public static void main(String[] args) throws IOException {
        // Check for int overflow!!!!
        // Should you use a long to store the sum or smthn?
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(f.readLine());
        StringTokenizer st = new StringTokenizer(f.readLine());
        // long lcm = Integer.parseInt(st.nextToken());
        // long denom = 1;
        double ans = 0;
        for (int i = 0; i < N; i++) {
            double a = Double.parseDouble(st.nextToken());
            /*
             * long a = Integer.parseInt(st.nextToken()); long c = lcm(a, lcm); denom *= c /
             * lcm; denom += c / a; lcm = c;
             */
            ans += 1 / a;
        }
        // double ans = (double) lcm / (double) denom;
        // out.println(ans);
        out.println(1 / ans);
        out.close();
    }

    public static long lcm(long a, long b) {
        return (a * b) / gcd(a, b);
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

}

Measured memory_bytes: 21460
from collections import Counter
n = int(input())
l = list(Counter(input()) for i in range(n))
k =[]
m = 50
for i in l[0]:
  for t in l:
    m = min(m,t[i])
  k.append(i*m)
  m = 50
k.sort()
print("".join(k))

Measured memory_bytes: 3316
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yay!")
    else:print(":(")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
n = ip()                                     #入力整数1つ
#n,k= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
b = [int(i) for i in input().split()]
if n == 1:
    print(a[0]+b[0])
    exit(0)
elif n==2:
    print(a[0]+b[1]+max(a[1],b[0]))
    exit(0)
msum = a[0]+sum(b)
m = copy.copy(msum)
for i in range(1,n):
    msum = msum-b[i-1]+a[i]
    m = max(m,msum)
print(m)


Measured memory_bytes: 13376
#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int N;
 	cin >> N;
 	int x[N];
 	for (int i = 0; i < N; i++){
 		cin >> x[i];
 	}
 	sort(x,x+N);
 	int ans=x[N-1]/2;
 	for (int i = 1; i < N; i++){
 		ans=ans+x[N-1-i];
 	}
 	cout << ans << endl;
 }


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n;
ll ans,a[200005],s[200005],c[200005];
int main(){
	in(n);
	for(int i=0;i<n;i++)in(a[i]);
	for(int i=0;i<n;i++){
		s[i+1]=s[i]+a[i];
		c[i+1]=c[i]^a[i];
	}
	for(int i=0;i<n;i++){
		int l=i,r=n-1,sum=0;
		while(l<=r){
			int mid=(l+r)/2;
			int x=s[mid+1]-s[i];
			int y=c[mid+1]^c[i];
			if(x==y)sum=mid,l=mid+1;
			else r=mid-1;
		}
		ans+=sum-i+1;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
4
2 5 4 6
9 
0 0 0 0 0 0 0 0 0
19
885 8 1 128 83 32 256 206 639 16 4 128 689 32 8 64 885 969 1
*/

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

int a[100] ;

int main() {

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

        cin >> a[i] ;

    }
    int ans = 0;
    for(int i = 0, tmp; i < n; i++){

        cin >> tmp ;
        if(a[i] - tmp > 0){

            ans += a[i] - tmp ;

        }

    }
    cout << ans ;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i=1; i<=N; i++){
        cin >> A[i];
    }
    int ans = inf;
    for(int i=1; i<=N; i++){
        if(N%i == 0){
            bool can = true;
            for(int j=1; j<=i; j++){
                int now = A[j];
                for(int k=j; k<=N; k+=i){
                    if(now != A[k]){
                        can = false;
                        break;
                    }
                }
                if(!can) break;
            }
            if(can){
                chmin(ans,i);
            }
        }
    }
    cout << N/ans << enld;
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
const int maxn=10;
int n,m;
char pic[maxn][maxn];
int next[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
inline bool dfs(int sx,int sy){
  int cnt=0;
  int tx=-1,ty=-1;
  pic[sx][sy]='.';
  for(int k=0,nx,ny;k<4;k++){
    nx=sx+next[k][0];
	ny=sy+next[k][1];
	if(pic[nx][ny]=='#'){
	  cnt++;
	  if(k<=1)
	    tx=nx,ty=ny;
	}
  }
  if(sx==n&&sy==m&&cnt==0)return 1;
  if(sx==n&&sy==m)return 0;
  if(cnt!=1)return 0;
  return dfs(tx,ty);
}
int main()
{
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)
	scanf("%s",pic[i]+1);
  if(dfs(1,1))printf("Possible");
  else printf("Impossible");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i=0; i < N; i++) {
    cin >> X[i];
  }
  int y = 0;
  int z = 0;
  for (int i=0; i < N; i++) {
     y = X[y] - 1;
     z++;
    if (y == 1) break;
  }
  if (z == N) z = -1;
  cout << z << endl;
}
    

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n){
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans=0;
  rep(i, k){
    ans+=p[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

#define PT pair<int, int>

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


	int H, W, K;
	cin >> H >> W >> K;
	K = min(K, H + W);
	string S[800];
	rep(i, H) cin >> S[i];
	bool D[640000] = {};
	int k = 0;
	vector<int> que1;
	rep(i, H) rep(j, W) {
		if (S[i][j] == 'S') {
			que1.pb(k);
		}
		k++;
	}
	rep(d, K + 1) {
		vector<int> que2;
		for (int k : que1) {
			if (D[k]) continue;
			D[k] = true;
			int i = k / W;
			int j = k - i * W;
			if (i == 0 || j == 0 || i == H - 1 || j == W - 1) continue;
			else {
				if (!D[k + 1] && S[i][j + 1] != '#') que2.pb(k + 1);
				if (!D[k - 1] && S[i][j - 1] != '#') que2.pb(k - 1);
				if (!D[k + W] && S[i + 1][j] != '#') que2.pb(k + W);
				if (!D[k - W] && S[i - 1][j] != '#') que2.pb(k - W);
			}
		}
		que1 = que2;
	}

	int kotae = 1e9;
	k = 0;
	rep(i, H) rep(j, W) {
		if (D[k]) {
			int tmp = min(min(i, H - i - 1), min(j, W - j - 1));
			kotae = min(kotae, 1 + (tmp + K - 1) / K);
		}
		k++;
	}
	co(kotae);

	Would you please return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, M;
int S[2010], T[2010];
int dp[2010][2010];
int sum[2010][2010];

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

	cin >> N >> M;
	rep(i, 0, N)
	{
		cin >> S[i];
	}
	rep(i, 0, M)
	{
		cin >> T[i];
	}

	rep(i, 0, N)
	{
		rep(j, 0, M)
		{
			if (S[i] == T[j])
			{
				dp[i + 1][j + 1] = sum[i][j] + 1;
				dp[i + 1][j + 1] %= MOD;
			}
			sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j]+ MOD - sum[i][j] + dp[i + 1][j + 1];
			sum[i + 1][j + 1] %= MOD;
		}
	}

	cout << (sum[N][M] + 1) % MOD << endl;

	return 0;
}

Measured memory_bytes: 63104
N, M = map(int, input().split())
A = list(map(int, input().split()))

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = {i: -1 for i in range(N+1)}
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])

Measured memory_bytes: 15332
// 23.07.2017

/*
B - Traveling AtCoDeer Problem

Time limit : 2sec / Memory limit : 256MB
Score : 200 points
Problem Statement
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.
There are N houses along TopCoDeer street. The i-th house is located at coordinate a [i].
He has decided to deliver gifts to all these houses.
Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.
Constraints
    1 <= N <= 100
    0 <= ai <= 1000
    ai is an integer.
Input
Input is given from Standard Input in the following format:
N
a1 a2 … aN
Output
Print the minimum distance to be traveled.
Sample Input 1
4
2 3 7 9
Sample Output 1
7
The travel distance of 7 can be achieved by starting at coordinate 9 and traveling straight to coordinate 2.
It is not possible to do with a travel distance of less than 7, and thus 7 is the minimum distance to be traveled.
Sample Input 2
8
3 1 4 1 5 9 2 6
Sample Output 2
8
There may be more than one house at a position.
*/

# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <cstring>
# include <vector>
# include <stack>
# include <queue>
# include <algorithm>


//# define __TRR__

using namespace std;

int n, m, k, mi, ma;

int main ()
{
# ifdef __TRR__
   freopen ("B.TXT", "r", stdin);
   freopen ("B.OUT", "w", stdout);
# endif

   cin >> n >> mi;

   ma = mi;

   for ( int i=1; i < n; i++ )
   {
      cin >> k;
      if ( k > ma )
         ma = k;
      if ( k < mi )
         mi = k;
   }

   cout << (ma - mi);

//system ("pause");
   return 0;
}


Measured memory_bytes: 256
/*================= *\
|  ID : aman__guta__ |
|      LANG: C++     |
\*==================*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double 
#define pb push_back
#define mk make_pair
#define fs first
#define sc second 
#define mod 1000000007
#define sp <<" "<<
#define JOKER ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
int spf[10000001];
long long int fac[200005]; 
void sieve(int n)
{
    spf[1]=1;
    for(int i=2;i<=n;i++) spf[i]=i;
    for(int i=4;i<=n;i+=2) spf[i]=2;
    for(int i=3;i*i<=n;i++)
    {
        if(spf[i]==i)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(spf[j]==j) spf[j]=i;
            }
        }
    }
}
long long int power(long long int x, long long int y, long long int p) 
{ 
    long long int res = 1;
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
}
long long int modInverse(long long int n, long long int p) 
{ 
    return power(n, p-2, p); 
} 
long long int nCrModPFermat(long long int n, long long int r, long long int p) 
{ 
   if (r==0) 
      return 1; 
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}
int lps(string s)
{
    int n=s.size();
    int lps[n];
    lps[0]=0;
    int i=1;
    int j=0;
    while(i<n)
    {
        if(s[i]==s[j])
        {
            j++;
            lps[i]=j;
            i++;
        }
        else 
        {
            if(j)
            {
                j=lps[j-1];
            }
            else 
            {
                lps[i]=0;
                i++;
            }

        }
    }
    return min(n/2,lps[n-1]);
}
main()  
{
    JOKER
    int n,x,y;
    cin>>n>>x>>y;
    int a[n]={};
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            int ans=1e9;
            ans=min({abs(i-j),abs(i-x)+1+abs(y-j),abs(i-y)+1+abs(j-x)});
            a[ans]++;
        }
    }
    for(int i=1; i<n; i++)
    {
        cout<<a[i]/2<<endl;
    }
    cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
    return 0;
} 



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define INF (1e9)
#define M 2500
#define N 50
using namespace std;
int n,t[N],d,ans=INF,sum;
bool dp[2][M][M];

int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>t[i],sum+=t[i];
  dp[0][0][0]=dp[1][0][0]=true;
  d=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<M;j++){
      for(int k=0;k<M;k++){
	if(dp[d][j][k]){
	  dp[!d][j][k]=dp[!d][j+t[i]][k]=dp[!d][j][k+t[i]]=true;
	  ans=min(ans,max(max(sum-(j+t[i])-k,j+t[i]),k));
	  ans=min(ans,max(max(sum-j-(k+t[i]),j),k+t[i]));
	  ans=min(ans,max(max(sum-j-k,j),k));
	}
      }
    }
    d==0?d=1:d=0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 12280
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const ll INF = TEN(17);
int m;
vec<string> s;
vl cost;
vec<vec<pli>> g;

string rev(string s) {
    reverse(all(s));
    return s;
}

int main() {
    fastio();

    cin >> m;
    s = vec<string>(m);
    cost = vl(m);
    forn(i, m) {
        cin >> s[i] >> cost[i];
    }

    forn(i, m) {
        s.push_back(rev(s[i]));
        cost.push_back(cost[i]);
    }

    vec<vi> id(m * 2);

    int n = 1;
    forn(i, m * 2) {
        forn(j, s[i].size()) {
            id[i].push_back(n++);
        }
    }

    g = vec<vec<pli>>(n, vec<pli>());
    forn(i, s.size()) {
        int len = s[i].size();

        forn(j, s[i].size()) {
            forn(k, s.size()) {
                if (i / m == k / m) continue;

                int len2 = s[k].size();

                int w = min(len - j, len2);

                if (s[i].substr(j, w) != s[k].substr(0, w)) continue;

                int u = 0;
                if (len2 > w) {
                    u = id[k][w];
                } else if (len - j > w) {
                    u = id[i][j + w];
                }

                g[id[i][j]].emplace_back(u, cost[k]);
            }
        }
    }

    vl dist(n, INF);
    priority_queue<pli, vec<pli>, greater<pli>> q;
    forn(i, m * 2) {
        q.emplace(cost[i], id[i][0]);
        dist[id[i][0]] = cost[i];
    }

    while (!q.empty()) {
        auto [c, u] = q.top();
        q.pop();

        if (c > dist[u]) continue;

        for (auto [v, k] : g[u]) {
            if (dist[v] > c + k) {
                dist[v] = c + k;
                q.emplace(dist[v], v);
            }
        }
    }

    ll ans = dist[0];

    forn(i, m * 2) {
        forn(j, s[i].size()) {
            string t = s[i].substr(j);
            if (t != rev(t)) continue;
            chmin(ans, dist[id[i][j]]);
        }
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3756
<?php
$n = intval(fgets(STDIN));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$j = 0;
$bits = 0;
$sum = $n * ($n+1) / 2;
foreach($A as $a){
  while($bits & $a)$bits^=$A[$j++];
  $bits |= $a;
  $sum -= $j;
}
echo $sum;


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;
  ll count = 0;

  FOR(i, 1, n) {
    if (to_string(i).length() % 2 != 0) {
      // COUT(i);
      count++;
    }
  }
  COUT(count);


}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


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

namespace std
{
    class Test {
        static void Main(string[] args) {
           List<int> ary_H= new List<int>();
           List<int> ary_W= new List<int>();
           
           
            while(true) {
                var input = Console.ReadLine().Split(' ');
                var H = int.Parse(input[0]);
                var W = int.Parse(input[1]);
            
                if(H == 0 && W == 0) break;
                ary_H.Add(H);
                ary_W.Add(W);
                
            }        
            
            for (int k = 0; k <ary_H.Count; k++) {
            
                for (int i= 0; i < ary_H[k]; i++) {
                    for (int j = 0; j < ary_W[k]; j++) {
                        Console.Write("#");
                    } 
                    Console.WriteLine("");  //改行
                }
                 Console.WriteLine("");//空行
            }
        
    
        }
    }
    
}


Measured memory_bytes: 7852
#include <utility>
#include <vector>
#include <string>
#include <iostream>

using namespace std;
#define rep(i, n)  for(int i=0;i<(int)(n);++i)
#define for_(i, b, n)  for(int i=b;i<(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb(c) push_back(c)
#define ss size()
#define st first
#define nd second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
  string s; cin >> s;
  cout << ("2018" + s.substr(4)) << endl;
}

Measured memory_bytes: 256
<?php
list($a,$b,$c,$k)=explode(" ",trim(fgets(STDIN)));
if($a==$b){
echo 0;
}else{
$y=$a-$b;
if(abs($y)<=pow(10,18)){
if($k%2==0){
echo $y;
}else{
echo -$y;
}
}else{
echo "Unfair";
}
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> win(n, 0);
    rep(i, q){
        int a;
        cin >> a;
        win[a-1]++;
    }
    rep(i, n){
        if(k>q-win[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3784
import std.stdio, std.string, std.conv, std.algorithm, std.math;
void main() {
	readln;
	foreach (string l; lines(stdin)) {
		auto n = l.split.to!(int[]).sort;
		auto r = n[0].pow(2) + n[1].pow(2) == n[2].pow(2) ? "YES" : "NO";
		r.writeln;
	}
}

Measured memory_bytes: 2432
n=int(input())
A=list(map(int,input().split()))
x=1000
y=x//A[0]
z=x-y*A[0]
for i in range(n-1):
    a=x
    b=z+y*A[i+1]
    if a<b:
        x=b
    else:
        y=x//A[i+1]
        z=x-y*A[i+1]
print(x)        

Measured memory_bytes: 61880
import java.util.Scanner;

public class Main {
    //atcoder Coffeee A competition 160
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        String s = input.nextLine();

            if(s.charAt(2)==s.charAt(3) &&s.charAt(4) == s.charAt(5)){

                System.out.println("Yes");
            } else{
                System.out.println("No");
            }







    }

}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int n, m;

int main()
{
	in >> n >> m;
	out << (n - 1)*(m - 1) << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = new String[3];
        for (int i = 0; i < 3; i++) {
            s[i] = sc.next();
        }

        for (int i = 0; i < 3; i++) {
            System.out.print(s[i].substring(i, i + 1));
            if (i == 2)
                System.out.println("");
        }
    }
}


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

using namespace std;
typedef long long ll;

/*
ll DP[3002][3002];
int N;
vector<ll> nums;

ll findMax(int l, int r) {
	if (DP[l][r] != -1) { return DP[l][r]; }
	if (l > r) { return 0; }

	ll c1 = nums[r] - findMax(l, r - 1);
	ll c2 = nums[l] - findMax(l + 1, r);

	DP[l][r] = max(c1, c2);
	return DP[l][r];
}

int main() {
	cin >> N;
	nums.resize(N);
	for (auto &x : nums) { cin >> x; }
	memset(DP, -1, sizeof(DP));

	cout << findMax(0, N - 1) << endl;
}
*/

//BOTTOM UP

ll dp[3002][3002];

int main() {
	int n; cin >> n;
	vector<ll> nums(n);
	for (auto &x : nums) { cin >> x; }

	for (int l = n - 1; l >= 0; l--) {
		dp[l][l] = nums[l];
		for (int r = l + 1; r < n; r++) {
			dp[l][r] = max(nums[l] - dp[l + 1][r], nums[r] - dp[l][r - 1]);
		}
	}

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

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

int main() {
    cin >> N >> M;
    vector<vector<ll>> graph(N);
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >>b;
        --a;--b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<ll> ans(N,-1);
    set<ll> already;
    ans[0] = 0;
    already.insert(0);
    queue<ll> q;
    q.push(0);
    while(!q.empty()){
        ll p= q.front();q.pop();
        for(ll child:graph[p]){
            if(ans[child] != -1){
                continue;
            }
            ans[child] = p+1;
            already.insert(child);
            q.push(child);
        }
    }
    if(already.size() != N){
        cout <<"No"<<endl;
        return 0;
    }
    cout <<"Yes" << endl;
    for(int i=1;i<N;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 17624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
int main ()
 { 
	 ll a;
	  ld b;
	 cin>>a>>b;
	 //cout<<b<<endl;
	 ld r=a*b;
	ll p;
	p=(long long int)(r);
	 cout<<p<<endl;
 
 }

Measured memory_bytes: 3760
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[] primeNum = new int[n];
		
		
		
		for(int i = 0; i < n; i++) {
			primeNum[i] = sc.nextInt();
		}
		
		int cnt = 0;
		
		for(int i : primeNum) {
			if(primeDec(i)) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
	}
	
	static boolean primeDec(int N) {
		if(N == 2) {
			return true;
		} else if(N % 2 == 0) {
			return false;
		} else if(N < 9) {
			return true;
		} else if(N % 3 == 0) {
			return false;
		} else {
			for(int i = 5; i * i <= N; i+=6) {
				if(N % i== 0) {
					return false;
				} else if(N % (i + 2) == 0) {
					return false;
				}
			}
			
			return true;
		}
	}
}

Measured memory_bytes: 42548
def main():
    A = [[int(i)-1 for i in input().split()] for j in range(3)]
    A.sort()
    if A[0] == A[1] or A[1] == A[2] or A[2] == A[0]:
        return print("NO")
    from collections import Counter
    c = Counter(sum(A, []))
    if [1, 1, 2, 2] == sorted(c.values()):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


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

public class Main {

	public static final int X_MAX = 6;
	public static final int Y_MAX = 12;

	public static final int[][] move_dir = new int[][]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
	
	public static boolean is_ok(int x, int y){
		if(x < 0 || x >= X_MAX || y < 0 || y >= Y_MAX){
			return false;
		}else{
			return true;
		}
	}
	
	public static int detect(int x, int y, char[][] map, boolean[][] visited){
		visited[y][x] = true;
		
		int ret = 1;
		for(int[] move : move_dir){
			final int nx = x + move[0];
			final int ny = y + move[1];
			
			if(!is_ok(nx, ny)){
				continue;
			}else if(visited[ny][nx]){
				continue;
			}else if(map[y][x] != map[ny][nx]){
				continue;
			}
			
			ret += detect(nx, ny, map, visited);
		}
		
		return ret;
	}
	
	public static void erase_dfs(int x, int y, char[][] map){
		char old = map[y][x];
		map[y][x] = '.';
		
		for(int[] move : move_dir){
			final int nx = x + move[0];
			final int ny = y + move[1];
			
			if(!is_ok(nx, ny)){
				continue;
			}else if(map[ny][nx] == 'O'){
				map[ny][nx] = '.';
				continue;
			}else if(old != map[ny][nx]){
				continue;
			}
			
			erase_dfs(nx, ny, map);
		}
	}
	
	public static boolean erase(char[][] map, boolean[][] checked){
		for(int i = 0; i < Y_MAX; i++){
			Arrays.fill(checked[i], false);
		}
		
		boolean erased = false;
		
		for(int y = 0; y < Y_MAX; y++){
			for(int x = 0; x < X_MAX; x++){
				if(map[y][x] == 'O' || map[y][x] == '.'){
					continue;
				}else if(checked[y][x]){
					continue;
				}
				
				int chain = detect(x, y, map, checked);
				
				if(chain >= 4){
					erase_dfs(x, y, map);
					erased = true;
				}
			}
		}
		
		return erased;
	}
	
	public static void fall(char[][] map){
		for(int x = 0; x < X_MAX; x++){
			boolean found = false;
			
			for(int y = 0; y < Y_MAX - 1; y++){
				if(map[y][x] != '.' && map[y + 1][x] == '.'){
					found = true;
					map[y+1][x] = map[y][x];
					map[y][x] = '.';
				}
			}
			
			if(found){
				x--;
			}
			//print(map);
		}
	}
	
	public static void print(char[][] map){
		for(int i = 0; i < Y_MAX; i++){
			for(int j = 0; j < X_MAX; j++){
				System.out.print(map[i][j] + " ");
			}
			System.out.println();
		}
		System.out.println("-------------");
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[][] map = new char[Y_MAX][X_MAX];
		boolean[][] checked = new boolean[Y_MAX][X_MAX];
		
		final int T = sc.nextInt();
		
		for(int t = 0; t < T; t++){
			for(int i = 0; i < Y_MAX; i++){
				char[] input = sc.next().toCharArray();
				
				for(int j = 0; j < X_MAX; j++){
					map[i][j] = input[j];
				}
			}
			
			int count = 0;
			//print(map);
			while(true){
				boolean ok = erase(map, checked);
				
				if(!ok){
					break;
				}
				//print(map);
				fall(map);
				//print(map);
				count++;
			}
			
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 21152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
vector <ll> fact;
vector <ll> invfact;

ll modpow(ll a, ll n)
{
    if(n <= 0)
        return 1;

    ll rv = modpow(a, n / 2);
    rv = (rv * rv) % mod;

    if(n % 2)
        rv = (rv * a) % mod;

    return rv;        
}

void initialize(ll n)
{
    fact.resize(n + 1, 1);
    invfact.resize(n + 1, 1);

    for(ll i = 2; i <= n; i++)
        fact[i] = (fact[i - 1] * i) % mod;

    for(ll i = 2; i <= n; i++)
        invfact[i] = modpow(fact[i], mod - 2);    
}

ll ncr(ll n, ll r)
{
    if(n < 0)
        return 0;
    if(r < 0) 
        return 0;
    if(r > n)
        return 0;

    ll ans = (fact[n] * invfact[r]) % mod;
    ans = (ans * invfact[n - r]) % mod;
    return ans;           
}

int main()
{
    ll n;
    cin >> n;
    vector <ll> in(n + 1);

    for(ll i = 0; i <= n; i++)
        cin >> in[i];

    vector <ll> pos(n + 1, -1);
    ll i1, i2;

    for(int i = 0; i <= n; i++)
    {
        if(pos[in[i]] != -1)
        {
            i1 = pos[in[i]];
            i2 = i;
            break;
        }

        pos[in[i]] = i;
    }    

    ll ans = 0;
    initialize(n + 2);

    // cout << i2 <<" "<< i1 <<"\n";

    for(ll k = 1; k <= (n + 1); k++)
    {
        ans = (ncr(n + 1, k) - ncr(n - (i2 - i1), k - 1)) % mod;
        ans = (ans + mod) % mod;
        cout << ans <<"\n";
    }

    return 0;
}

Measured memory_bytes: 4352
N = input()
A = list(map(int, input().split()))

i = 0
while True:
    l = [j for j, x in enumerate(A) if int(x) % 2 == 0]
    A = list(map(lambda x : x / 2, A))
    if len(l) == len(A):
        i += 1
    else:
        print(i)
        break


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

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

int main() {
  int64_t N;
  cin >> N;
  
  vector<int64_t> Yakusuu;
  Yakusuu = divisor(N);
  
  int64_t MinSum = 2 * N;
  for(int i = 0;i < Yakusuu.size();i++){
    int64_t A,B;
    int64_t cost;
    
    A = Yakusuu.at(i);
    B = N / A; 
    
    cost = A + B - 2;
    if(cost < MinSum) MinSum = cost;
  }

  
  cout << MinSum << endl;
  return 0;
}


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

public class HelloWorld
{
    static public void Main ()
    {
        var S = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        
        if(S[0] < S[1]){
            Console.WriteLine (0);
        }else{
            Console.WriteLine (10);
        }
        

    }

}


Measured memory_bytes: 13268
N, A, B = map(int, input().split())
S = input()
total_pass = 0
oversea_pass = 0
for s in S:
    if s == 'a' and total_pass < A + B: print('Yes'); total_pass += 1;
    elif s == 'b' and total_pass < A + B and oversea_pass < B: print('Yes'); total_pass += 1; oversea_pass += 1;
    else: print('No')

Measured memory_bytes: 4016