akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,ans,a[N],b[N],c[N],d[N],L[N],R[N],LL[N],RR[N];
vector<int>g1[N],g2[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
int lowbit(int x)
{
	return x&-x;
}
void add(int x,int y)
{
	while(x>0)
	{
		c[x]=max(c[x],y);
		x-=lowbit(x);
	}
}
int find(int x)
{
	int res=0;
	while(x<=n)
	{
		res=max(res,c[x]);
		x+=lowbit(x);
	}
	return res;
}
void add2(int x,int y)
{
	while(x>0)
	{
		d[x]=min(d[x],y);
		x-=lowbit(x);
	}
}
int find2(int x)
{
	int res=1e9;
	while(x<=n)
	{
		res=min(res,d[x]);
		x+=lowbit(x);
	}
	return res;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)d[i]=1e9;
	for(int i=1;i<=n;i++)
	{
		L[i]=find(a[i])+1;
		add(a[i],i);
	}
	for(int i=n;i;i--)
	{
		if(find2(a[i])==1e9)R[i]=n;
		else R[i]=find2(a[i])-1;
		add2(a[i],i);
	}
	for(int i=1;i<=n;i++)
	{
		int x=L[i],y=R[i];
//		cout<<x<<" "<<y<<endl;
		g1[x-1].push_back(i);
		g2[y+1].push_back(i);
//		if(L[i]-1)
//		{
//			ans=ans+a[i]*(y-i+1)*(L[i]-1-L[L[i]-1]+1);
//		}	
//		if(R[i]+1<=n)
//		{
//			ans=ans+a[i]*(R[R[i]+1]-R[i])*(i-x+1);
//		}
//		cout<<ans<<endl;
	}
	for(int i=1;i<=n;i++)c[i]=0;
	for(int i=1;i<=n;i++)d[i]=1e9;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<g1[i].size();j++)LL[g1[i][j]]=find(a[g1[i][j]])+1;
		add(a[i],i);
	}
	for(int i=n;i;i--)
	{
		for(int j=0;j<g2[i].size();j++)
		{
			if(find2(a[g2[i][j]])==1e9)RR[g2[i][j]]=n;
			else RR[g2[i][j]]=find2(a[g2[i][j]])-1;
//			LL[g1[i][j]]=find(a[g1[i][j]])+1;
		}
//		if(find2(a[i])==1e9)R[i]=n;
//		else R[i]=find2(a[i])-1;
		add2(a[i],i);
	}
	for(int i=1;i<=n;i++)
	{
		int x=L[i],y=R[i];
//		cout<<x<<" "<<y<<" "<<LL[i]<<" "<<RR[i]<<endl;
//		g1[x-1].push_back(i);
//		g2[y+1].push_back(i);
		if(L[i]-1)
		{
			ans=ans+a[i]*(y-i+1)*(L[i]-1-LL[i]+1);
		}	
		if(R[i]+1<=n)
		{
			ans=ans+a[i]*(RR[i]-R[i])*(i-x+1);
		}
//		cout<<ans<<endl;
	}
	cout<<ans;
}

Measured memory_bytes: 69504
n = int(input())
h = list(map(int,input().split()))

i = min(h)
ans = i
h = list(map(lambda x:x-i,h))

ck = 0
while sum(h) > 0:
  for i in range(n):
   if h[i] == 0:
     ans += ck
     ck = 0
   else:
     h[i] -= 1
     ck = 1
  else:
   ans += ck
   ck = 0

print(ans)

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

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

  int SN = 0, N_copy = N;
  while(N_copy > 0){
    SN += N_copy % 10;
    N_copy /= 10;
  }

  if(N % SN == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, double> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };



int main() {
	
	string sa, sb, sc;
	cin >> sa >> sb >> sc;

	int sl = 100;
	char start = 'a';
	
	while (1) {
		if (start == 'a') {
			if (sa.size() == 0) {
				cout << 'A' << endl;
				break;
			}
			start = sa.at(0);
			sa.erase(0, 1);
		}
		else if (start == 'b') {
			if (sb.size() == 0) {
				cout << 'B' << endl;
				break;
			}
			start = sb.at(0);
			sb.erase(0, 1);
		}
		else if (start == 'c') {
			if (sc.size() == 0) {
				cout << 'C' << endl;
				break;
			}
			start = sc.at(0);
			sc.erase(0, 1);
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
program cm
   implicit none
   integer::N,M,Q,a(50),b(50),c(50),d(50),X(10),i,ans=0
   read*,N,M,Q
   do i=1,Q
      read*,a(i),b(i),c(i),d(i)
   end do
   X(1)=1
   call DFS(2)
   print"(I0)",ans
contains
recursive subroutine DFS(K)
   integer::K
   integer::i
   if(K==N+1)then
      ans=max(ans,calc())
      return
   endif
   do i=X(K-1),M
      X(K)=i
      call DFS(K+1)
   end do
end subroutine
integer function calc()
   integer::i
   calc=0
   do i=1,Q
      if(X(B(i))-X(A(i))==c(i))calc=calc+d(i)
   end do
end function
end program cm

Measured memory_bytes: 2872
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
  int i,j,k,l,n,m;
  char s[50][51]={{'\0'}};
  char tmp[50][51]={{'\0'}};
  int x=0,y=0,not=0,match=0;

  scanf("%d %d",&n,&m );


  for(i=0;i<n;i++) scanf("%s",s[i] );
  for(i=0;i<m;i++) scanf("%s",tmp[i] );

  for(i=0;i < n - m + 1;i++){
    for(j=0;j < n - m + 1;j++){
      if( s[i][j] == tmp[0][0]){
        not = 0;
        x = j; y = i;
        for(k=0,y=i;k < m && not!=1;k++,y++){
          for(l=0,x=j;l < m && not!=1;l++,x++){
            //printf("%d %d %d %d %c %c\n",x,y,k,l,s[y][x],tmp[k][l]);
            //printf("%c\n",s[y][x] );
            //printf("%c\n",tmp[k][l] );
            if(s[y][x] != tmp[k][l]){
              not=1;
              break;
            }
          }
        }
        if(not != 1){
          puts("Yes");
          return 0;
        }
      }
    }
  }

  puts("No");
  return 0;
}


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

int main() {
    int x;
    cin >> x;
    int ans = 0, now=0;
    while(1) {
        now+=x;
        ans++;
        if(now%360==0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000010;
const int MAXK = 100010;
const int MAXQ = 200010;

int n, h[MAXN], a[MAXN];
ll t[MAXN];

ll get(int u) {
    ll res = 0;
    while (u) {
        res = max(res, t[u]);
        u = u - (u & (-u));
    }
    return res;
}

void update(int u, ll gt) {
    while (u <= 200000) {
        t[u] = max(t[u], gt);
        u = u + (u & (-u));
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> h[i];
    FOR(i,1,n) cin >> a[i];
    ll res = 0;
    FOR(i,1,n) {
        int u = h[i]-1;
        ll Max = get(u) + a[i];
        res = max(res, Max);
        update(h[i], Max);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	string s;
	cin>>s;
	if(s[1]=='B'){
		cout<<"ARC"<<endl;
	}else{
		cout<<"ABC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3624
//>>>>>>>>>>>>>>>>>>>>>>>>>>JAI BAJRANG BALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//
//😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😇😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😝😝😝😝😝😝😝😝😝😝😝😝😝😂😂😂😂😂😂😂😜😜😜😜😜😜😜😜😜😜😜
#define HARSH_JUDGE
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define db(x)                   cout<<#x<<"="<<x<<'\n'
#define db2(x,y)                 cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define setbits(x)      __builtin_popcountll(x)
#define str string
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n;i>=a;i--)
#define cases   long long t;cin>>t;while(t--)
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define ss second
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define sp(x,y)         fixed<<setprecision(y)<<x
#define nl '\n'
#define sz(x) ((int)(x).size())
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
const ll N = 1e5 + 5;
#define printall(a) fo(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;



typedef vector<int> vi;
typedef map<ll, ll> mll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<ll, int> mli;
typedef map<char, int> mci;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

bool cmp(const pair<ll, ll>& a, const pair<ll, ll>& b)
{

	return a.ss < b.ss;
}

// >>>>>>>>>>>>>>>>>>>>>>>>>>TOR DE DUSHMAN KI NALI<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//

void solve()
{

	ll n, k, tt;
	cin >> n >> k >> tt;
	cout << (ll)(ceil(n * 1.0 / k * 1.0))*tt;




	return;
}

int main()
{	fio
#ifndef HARSH_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
#endif
	ll t = 1;
	// cin >> t;
	// clock_t timest = clock();
	// cerr << "[Executes in " << (double)(clock() - timest) / CLOCKS_PER_SEC << "s]" << endl;
	while (t--)
	{
		solve();

	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();        // 1 1 3 4 5 9
	int n;					//	4 9 1  5 1 3 // 3 9 1 5 1 4
 	cin >> n;
	ll a[n];
	FOR(i,n){
		cin >> a[i];
	}
	sort(a,a+n);
	ll sum=0,sum1=0,i=0,j=n-1;
	int b[n],k=0;
	if(n%2){
		std::vector<ll> v;
		std::vector<ll> v1;
		k=n/2;
		v.eb(a[k]);
		v1.eb(a[k]);
		while(i < k){
		v.PB(a[i]);
		v.PB(a[j]);
		v1.PB(a[j]);
		v1.PB(a[i]);
		i++;j--;
		}
		for(int l=0;l<n-1;l++) sum+=abs(v[l]-v[l+1]);
		for(int l=0;l<n-1;l++) sum1+=abs(v1[l]-v1[l+1]);
			
	}
	else{
		std::vector<ll> v,v1;
		k=n/2;
		int t=k-1;
		v.eb(a[k]);
		v1.eb(a[t]);
		while(i < k){
			v.eb(a[i]);
			v.eb(a[j]);
			i++;j--;

		}
		j=n-1;i=0;
		while(j>t){
			v1.eb(a[j]);
			v1.eb(a[i]);
			i++;j--;
		}
		for(int l=0;l<n-1;l++) sum+=abs(v[l]-v[l+1]);
		for(int l=0;l<n-1;l++) sum1+=abs(v1[l]-v1[l+1]);


	
	}

	cout << max(sum,sum1);
	
	return 0;
}

Measured memory_bytes: 6408
M, D = map(int, input().split())
if D <= 20 :
  X = 0
else :
  X = 0
  for i in range(D-20):
    if (i+21)%10 == 1:
      X += 0
    else : 
      s = str(i+21)
      A = int(s[0]) * int(s[1])
      if (A <= M) and (A != 0) :
        X += 1
      else :
        X += 0
print(X)



Measured memory_bytes: 3060
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
V = list(map(int, sys.stdin.buffer.readline().split()))

V = np.array(V, dtype=int)

V1 = V[::2]
V2 = V[1::2]
vc1 = np.bincount(V1, minlength=10 ** 5 + 1)
vc2 = np.bincount(V2, minlength=10 ** 5 + 1)

i1 = vc1.argmax()
i2 = vc2.argmax()

if i1 != i2:
    ans = N - (vc1[i1] + vc2[i2])
    print(ans)
else:
    m1 = vc1[i1]
    vc1[i1] = 0
    m2 = vc2[i2]
    vc2[i2] = 0
    j1 = vc1.argmax()
    j2 = vc2.argmax()
    ans = N - max(m1 + vc2[j2], m2 + vc1[j1])
    print(ans)


Measured memory_bytes: 21476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static final int FIRST_NUMBER = 0;
    public static final int SECOND_NUMBER = 1;

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

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	// ?¨?????????°
	int vertical = Integer.parseInt(br.readLine());

	int horizontal = Integer.parseInt(br.readLine());

	List<int[]> changeRequests = new ArrayList<>();
	for (int i = 0; i < horizontal; i++) {
	    String[] changeRequestStr = br.readLine().split(",");
	    int[] changeRequest = new int[2];
	    changeRequest[FIRST_NUMBER] = Integer.parseInt(changeRequestStr[FIRST_NUMBER]);
	    changeRequest[SECOND_NUMBER] = Integer.parseInt(changeRequestStr[SECOND_NUMBER]);
	    changeRequests.add(changeRequest);
	}

	int[] outputArray = getDrawedArray(changeRequests, vertical, horizontal);

	for (int i = 1; i < outputArray.length; i++) {
	    System.out.println(outputArray[i]);
	}

    }

    /**
     *
     * @param changeRequests
     * @param vertical
     * @param horizontal
     */
    private static int[] getDrawedArray(List<int[]> changeRequests, int vertical, int horizontal) {
	int[] outputArray = new int[vertical + 1];
	for (int i = 1; i < outputArray.length; i++) {
	    outputArray[i] = i;
	}

	for (int[] changeRequest : changeRequests) {
	    int mediator = 0;
	    mediator = outputArray[changeRequest[FIRST_NUMBER]];
	    outputArray[changeRequest[FIRST_NUMBER]] = outputArray[changeRequest[SECOND_NUMBER]];
	    outputArray[changeRequest[SECOND_NUMBER]] = mediator;

	}

	return outputArray;

    }

}

Measured memory_bytes: 24360
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
ll n , m , cc;
vector< pair<ll,ll> > g[1000005];
vector<ll> C[3000005];
ll p[100005];
ll id[1000005];
bool used[100005];
vector<ll> e[3000005];
ll d[3000005];
ll fs(ll x)
{
        return p[x] == x ? x : p[x] = fs(p[x]);
}
void us(ll a , ll b)
{
        a = fs(a);
        b = fs(b);
        p[b]=a;
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cin >> n >> m;
        for(ll i=1;i<=m;i++)
        {
                ll a , b, c;
                cin >> a >> b >> c;
                g[c].pb(make_pair(a , b));
        }
        cc = n;
        for(ll i = 1 ; i <= 1000001 ;i++) {
                if(g[i].size() == 0) continue;
                for(auto j : g[i]) {
                        p[j.first] = j.first;
                        p[j.second] = j.second;
                        id[j.first] = id[j.second] = -1;
                        used[j.first] = used[j.second] = false;
                }
                for(auto j : g[i]) {

                        us(j.first , j.second);
                }
                for(auto j : g[i]) {

                        if(used[j.first] == false) {

                                used[j.first] = true;
                                ll cap = fs(j.first);
                                if(id[cap] == -1) id[cap] = ++cc;
                                e[j.first].pb(id[cap]);
                                e[id[cap]].pb(j.first);
                        }

                        if(used[j.second] == false) {

                                used[j.second] = true;
                                ll cap = fs(j.second);
                                if(id[cap] == -1) id[cap] = ++cc;
                                e[j.second].pb(id[cap]);
                                e[id[cap]].pb(j.second);
                        }
                }
        }
        queue<ll> q;
        q.push(1);
        d[1] = 0;
        for(ll i=1;i<=cc;i++) d[i] = 1e12;
        d[1]=0;
        while(q.empty()==false) {

                ll u = q.front();
                q.pop();
                if(u == n) break;
                for(auto i : e[u]) {
                        if(d[i] == 1e12) {
                                d[i] = d[u]+1;
                                q.push(i);
                        }
                }
        }
        if(d[n] == 1e12) {
                cout << "-1\n"; return 0;
        }
        cout << d[n] / 2 << endl;
        return 0;
}


Measured memory_bytes: 192244
n, m = map(int, input().split())

a = []
k = []

for i in range(n):
    lst = list(map(int, input().split()))
    k.append(lst[0])
    a.append(lst[1:])


ans = [0 for _ in range(m)]


for i in range(n):
    for x in a[i]:
        ans[x-1] += 1

temp = 0

for x in ans:
    if x == n:
        temp += 1

print(temp)


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

using namespace std;


#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


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

VI v(100, 0);

long long check(int n) {
	if (n > 0) {
		int i = 0;
		long long sum = 0;
		while (true) {
			if (sum >= n) {
				break;
			}
			sum += pow(-2, i);
			i += 2;
		}
		v[i - 2] = 1;
		return pow(-2, i - 2);
	}
	else if (n < 0) {
		int i = 1;
		long long sum = 0;
		while (true) {
			if (sum <= n) {
				break;
			}
			sum += pow(-2, i);
			i += 2;
		}
		v[i - 2] = 1;
		return pow(-2, i - 2);
	}
	else {
		return 0;
	}
}

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

	if (n == 0) {
		ANS(0);
		return 0;
	}
	long long sum;
	//ANS(sum);

	long long purpose = n;
	

	while (purpose != 0) {
		sum = check(purpose);
		//ANS(sum);

		purpose = purpose - sum;
		
	}
	
	reverse(v.begin(), v.end());
	
	


	while (true)
	{
		if (v[0] == 0) {
			v.erase(v.begin());
		}
		else {
			break;
		}
	}
	REP(i, v.size()) {
		cout << v[i];
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll x,y;
    cin>>x>>y;
    if((2*x-y)%3!=0||(x-2*y)%3!=0) cout<<0;
    else{
        
    // 前処理
    COMinit();

    // 計算例
    cout<<COM((2*x-y)/3+(-x+2*y)/3,(2*x-y)/3);
    
    }
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
long long n,mx,w[110],v[110],dp[110][100010];

int main()
{
	scanf("%lld %lld",&n,&mx);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&w[i],&v[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=mx;j++)
		{
			dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
			if(j-w[i]>=0) dp[i][j] = max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
			//printf("%lld ",dp[i][j]);
		}
		//printf("\n");
	}
	printf("%lld\n",dp[n][mx]);
	return 0;
}

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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const ll INF =  0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){long long res=(long long)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}

int fact[MAX], invp[MAX];

void init() {
	fact[0] = 1, invp[0] = 1;
	for(int i = 1; i < MAX; ++i) {
		fact[i] = mul(fact[i-1], i, MOD);
	}
	invp[MAX-1] = mod_inverse(fact[MAX-1], MOD);
	for(int i = MAX-2; i >= 1; --i) {
		invp[i] = mul(invp[i+1], i+1, MOD);
	}
}

//Complexity : O(1)
int ncr(int n, int r) {
	if (r < 0 || r > n) return 0;
	return mul(fact[n], mul(invp[n-r], invp[r], MOD), MOD);
}

int n, d, a, b;
vector<int> v(MAX);
vector<bool> visited(MAX, false);
vector<int> indx(MAX);

int main(int argc, char const *argv[])
{
  //ios_base::sync_with_stdio(false);
  
  // #ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  // #endif

  scanf("%d" , &n);

  for(int i = 1 ; i <= (n+1) ; i++){
  	scanf("%d" , &d);
  	v[i] = d;
  	if(visited[d]){
  		a = indx[d];
  		b = i;
  	}
  	else{
  		visited[d] = true;
  		indx[d] = i;
  	}
  }

  init();
  int d = (b - a - 1);

  for(int k = 1 ; k <= n+1 ; k++){
  	ll ans = mod_neg(ncr(n+1, k) , ncr(n - d - 1, k-1), MOD);
  	printf("%lld\n", ans);
   }

  return 0;
}  

Measured memory_bytes: 2816
n,q = map(int,input().split())
s = input()
cnt = [0]*(n+1)
p = s[0]
for i in range(1,n+1):
    if p == "A" and s[i-1] == "C":
            cnt[i] = cnt[i-1] +1
    else:
        cnt[i] = cnt[i-1]
    p = s[i-1]

for i in range(q):
    l,r = map(int,input().split())
    print(cnt[r] - cnt[l])


Measured memory_bytes: 6164
S = input()

def can_be_mm(s):
    num = int(s[1])
    if s[0] == '0':
        if num != 0:
            return True
    elif s[0] == '1':
        if num >= 0 and num <= 2:
            return True
    return False

yymm = can_be_mm(S[2:])
mmyy = can_be_mm(S[:2])

if yymm and not mmyy:
    print('YYMM')
elif not yymm and mmyy:
    print('MMYY')
elif yymm and mmyy:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
 
int main()
{
	int i, n, cA = (int) 'A', cZ = (int) 'Z', distAZ = cZ - cA + 1;
    char s[10005];
 
    scanf("%d\n%s\n", &n, s);
 
    for(i = 0; s[i] != '\0'; i++){
		printf("%c", (char) ((s[i] - cA + n) % distAZ + cA));
	}
	printf("\n");
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X):
    return X.index(0) + 1


def main():
    X = read_int_n()
    print(slv(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76804
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val (n, m) = readIntegerList()
    val pList = readIntegerList()

    val unionFind = UnionFind(n)
    repeat(m) {
        val (x, y) = readIntegerList()
        unionFind.unite(x - 1, y - 1)
    }

//    var ans = 0
//    for (i in pList.indices) {
//        if (unionFind.sameRoot(i, pList[i] - 1)) {
//            ans++
//        }
//    }
//    println(ans)
    
    pList.withIndex()
        .count { unionFind.sameRoot(it.index, it.value - 1) }
        .let(::println)
}

/**　Union find 0 ~ (n - 1)　*/
class UnionFind(n: Int) {
    val parent = IntArray(n) { it }
    val rank = IntArray(n)
    val size = IntArray(n) { 1 }

    /** O(α(n)) */
    fun findRoot(x: Int): Int {
        if (parent[x] == x) return x

        parent[x] = findRoot(parent[x])
        return parent[x]
    }

    /** O(α(n)) */
    fun sameRoot(x: Int, y: Int) = findRoot(x) == findRoot(y)

    /** O(α(n)) */
    fun unite(x: Int, y: Int) {
        val x = findRoot(x)
        val y = findRoot(y)
        if (x == y) return

        if (rank[x] < rank[y]) {
            parent[x] = y
            size[y] += size[x]
        } else {
            parent[y] = x
            if (rank[x] == rank[y]) rank[x]++

            size[x] += size[y]
        }
    }

    /** O(α(n)) */
    fun getSize(x: Int) = size[findRoot(x)]
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 74180
n, k = list(map(int, input().split()))
tree = []
for _ in range(n):
    x = int(input())
    tree.append(x)

tree = sorted(tree)

minimum = 10**9
for i in range(n-k+1):
    minimum = min(minimum, tree[i+k-1] - tree[i])

print(minimum)


Measured memory_bytes: 8276
#include <iostream>
#include <string>

using namespace std;

string str;
bool check (int r) {
  for (int i = 0; i <= r; i++) {
    if (str[i] != str[r - i]) return false;
  }
  return true;
}

int main () {
  cin >> str;

  int n = str.size();
  if (check(n - 1) && check(n / 2 - 1)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    string S; cin >> S;
    
    sort(S.begin(), S.end());

    string ans = S=="abc" ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int mod = (int)1e7+9;
#define REP0(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<=n;i++)
#define F first
#define S second
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define inf (int)(1e18)
#define prec(x) fixed<<setprecision(x)<<x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(x) x.begin(),x.end()

const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

void solve(){
   int d,t,s;
   cin>>d>>t>>s;
   if(s*t >= d){
       cout<<"Yes";
   }
   else{
       cout<<"No";
   }
   cout<<endl;
}


int main(){
    fastio;
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    int tc = 1;
    // cin>>tc;
    for(int i=1;i<=tc;i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>

using namespace std;

int main(){
    long long int n,t;
    cin>>n>>t;
    long long int i,a,ans=0,end=0;
    for(i=0;i<n;i++){
        cin>>a;
        if(end<=a){
            ans+=t;
            end=(a+t);
        }else{
            ans-=(end-a);
            ans+=t;
            end=(a+t);
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
#define inf 0x3fffffff

string s,t,x;
int a,b;

int main()
{
    cin>>s>>t>>a>>b>>x;
    if (x==s) a--;
    else if (x==t) b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  ll N,X,Y;
  cin >> N >> X >> Y;
  vector<int> data(N,0);
  double c;
  c = (X+Y)/2;
  rep(i,1,N+1){
      rep(j,i+1,N+1){
          if(j<=X){
              data[j-i]++;
              //cout << i << j << endl;
          }
          if(i<=X&&X<j&&j<=c){
              data[j-i]++;
          }
          if(i>X&&i<Y&&j>X&&j<Y){
              int b =j-i;
              int c = Y-j+i-X+1;
              int a = min(b,c);
              data[a]++;
              //cout << i << j << endl;
          }
          if(i>=Y){
              data[j-i]++;
              //cout << i << j << endl;
          }
          if(i<Y&&i>=c&&j>=Y){
              data[j-i]++;
          }
          if(i<=X&&j>c){
              if(j<Y){
                  data[X-i+Y-j+1]++;
                  //cout << i << j << endl;
              }else{
                  data[X-i+j-Y+1]++;
                  //cout << i << j << endl;
              }
          }
          if(i<c&&j>=Y){
              if(i>X){
                  data[j-Y+i-X+1]++;
                  //cout << i << j << endl;
              }
          }
      }
  }
  int sum=0;
  rep(i,1,N){
      cout << data[i] << endl;
      sum += data[i];
  }
  //cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int N,i;
    scanf("%lld",&N);
    long long int a[N+5],j,x,sum=0;
    if(N>=2&&N<=10)
    {
        for(i=0; i<N; i++)
        {
            scanf("%lld",&a[i]);
            if(a[i]<100||a[i]>10000||a[i]%2!=0)
                scanf("%lld",&a[i]);
        }
        for(i=0; i<N; i++)
        {
            for(j=i+1; j<N; j++)
            {
                if(a[j]>a[i])
                {
                    x=a[i];
                    a[i]=a[j];
                    a[j]=x;
                }
            }
        }
        for(i=0; i<N; i++)
        {
            if(i==0)
            {
                sum=sum+a[i]/2;
            }
            else
            {
                sum=sum+a[i];
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
bool ans=true;
class code{
private:
    string S;
public:
    void setValue(string s)
    {
        S=s;
    }
    string getValue(){
       for(int i=0;i<S.size();i++)
       {
           if((i+1)%2==0)
           {
               if(S[i]=='L'||S[i]=='U'||S[i]=='D')
                   continue;
               else{
                ans=false;
                break;
               }

           }
           else
           {
               if(S[i]=='R'||S[i]=='U'||S[i]=='D')
                   continue;
               else{
                ans=false;
                break;
               }

           }
       }
       if(ans)
        return "Yes";
       else
        return "No";
    }
};
string ch;
int main()
{
    cin>>ch;
    code input;
    input.setValue(ch);
    cout<<input.getValue()<<endl;
    std::cin.get();
}


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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    string pre_s = "";
    rep(i, n) {
        string tmp_s;
        cin >> tmp_s;
        if ( mp[tmp_s] != 0 ) {
            cout << "No" << endl;
            return 0;
        }
        if ( i >= 1 && pre_s.back() != tmp_s[0] ) {
            cout << "No" << endl;
            return 0;
        }
        ++mp[tmp_s];
        pre_s = tmp_s;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const int mod = 1000000007;

int n, a[200010];
ll ans;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	ll cnt = 0;
	for (int i = 0; i < n; i++)cin >> a[i], cnt += a[i];
	for (int i = 0; i < n; i++) {
		cnt -= a[i];
		ans = (ans + a[i] * (cnt%mod)) % mod;
	}
	cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

i64 dp[101][2][2][5];

void solve() {
  dp[0][0][0][0] = 1;
  string S;
  cin >> S;
  int n = S.size();
  int K;
  cin >> K;
  rep(i, n) rep(j, 2) rep(k, 2) rep(l, 4) rep(d, 10) {
    int dig = S[i] - '0';
    if (j == 0 && dig < d) break;

    int _i = i + 1;
    int _j = j == 0 && dig == d ? 0 : 1;
    int _k = k == 0 && dig == 0 ? 0 : 1;
    int _l = _k == 1 && d != 0 ? l + 1 : l;
    
    dp[_i][_j][_k][_l] += dp[i][j][k][l];
  }
  cout << dp[n][0][1][K] + dp[n][1][1][K] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x,y,r,W,H;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if(x>=r&&W>=x+r&&y>=r&&H>=y+r){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	ll i, j;
	int N;
	cin >> N;
	int ans = N * N * N;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int nn, kk, ans = 0;
	cin >> nn >> kk;
	vector<int64> vv(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> vv[ii];
	}
	sort(vv.begin(), vv.end());
	for(int64 ii = 0;ii < kk;ii++)
	{
		ans += vv[ii];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))

ans = 0
k = 0
for i in range(n):
  res = max(a)
  if k % 2 == 0:
    ans += res
  else:
    ans -= res
  a.remove(res)
  k += 1
  
print(ans)

Measured memory_bytes: 9188
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S; cin >> S;
    if (S[2] == S[3] && S[4] == S[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]*(n+1)
counter = 1
for i in range(1,n + 1):
    d[i] = d[i - 1] + l[i - 1]
    if d[i] <= x:
        counter += 1
print(counter)


Measured memory_bytes: 62012
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main (){
    int n,x,y;
    cin >> n >> x >> y;
    x--;y--;
    vector<int> ans(n);
    rep(st,n){
        vector<int>dist(n,inf);
        queue<int>q;
        auto push =[&](int i, int j){
            if(dist[i]!=inf) return;
            dist[i]=j;
            q.push(i);
        };
        push(st,0);
        while(!q.empty()){
            int v=q.front();q.pop();
            if(v+1<n) push(v+1,dist[v]+1);
            if(v-1>=0) push(v-1,dist[v]+1);
            if(v==x) push(y,dist[v]+1);
            if(v==y) push(x,dist[v]+1);
        }
        rep(i,n) ans[dist[i]]++;
    }
    rep(i,n) ans[i]/=2;
    rep(i,n){
        if(i==0) continue;
        else cout << ans[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using std::cout;
using std::cin;
using std::endl;

#include<string>
using std::string;

#include<cstdlib>
using std::stoi;

int main()
{
  string s;
  cin >> s;
  
  if (stoi(s.substr(0, 4)) < 2019) cout << "Heisei" << endl;
  else if(stoi(s.substr(5, 2)) < 5) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  
  return 0;
}


Measured memory_bytes: 256
from sys import stdin

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()

INF  = 1005
ans = INF

for i in range(len(s) - len(t) + 1):
    newans = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            newans += 1
    ans = min(ans, newans)

print(ans)

Measured memory_bytes: 9028
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static int n;
    static int m;
    static int x;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        x = sc.nextInt();
        int before = 0;
        int after = 0;
        for (int i = 0; i < m; i++) {
            int ai = sc.nextInt();
            if (ai < x) {
                before++;
            } else {
                after++;
            }

        }
        System.out.println(Math.min(before, after));
    }

}


Measured memory_bytes: 23124
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b)
		printf("%d\n",c);
	else if(b==c)
		printf("%d\n",a);
	else
		printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
 
int cnt;
 
void insertionSort(int A[], int n, int g)
{
    int i;
    for (i = g; i < n; i++) {
        int v, j;
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}
 
void shellSort(int A[], int n)
{
    int i, m = 0;
    int G[10] = {262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1};
 
    for (i = 0; i < 10; i++) {
        if (G[i] <= n) {
            m++;
            insertionSort(A, n, G[i]);
        }
    }
 
    printf("%d\n", m);
     
    i = 10 - m;
 
    printf("%d", G[i]);
    for (i++; i < 10; i++) printf(" %d", G[i]);
    putchar('\n');
}
 
int main(void)
{
    int n;
    scanf("%d", &n);
 
    int A[n];
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &A[i]);
 
    shellSort(A, n);
 
    printf("%d\n", cnt);
 
    for (i = 0; i < n; i++)
        printf("%d\n", A[i]);
 
    return 0;
}

Measured memory_bytes: 4512
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    for (ll i = 1; i * (i + 1) / 2 <= N; i++) {
        if (i * (i + 1) / 2 == N) {
            cout << "Yes" << endl;
            cout << i + 1 << endl;
            vector<vector<ll>> ans(i + 1);
            ll num = 1;
            for (ll j = 0; j < i + 1; j++) {
                for (ll k = j + 1; k < i + 1; k++) {
                    ans[j].push_back(num);
                    ans[k].push_back(num);
                    num++;
                }
                cout << ans[j].size() << " ";
                for (ll k = 0; k < i; k++) {
                    printf("%lld%c", ans[j][k], " \n"[k == i - 1]);
                }
            }
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3200
def sol():
    S = input()
    N = len(S)

    if N == 2:
        if S[0] == S[1]:
            print(1, 2)
            return
        else:
            print(-1, -1)
            return

    for i in range(N - 3):
        sub = set(S[i: i + 3])
        if len(sub) <= 2:
            print(i + 1, i + 3)
            return

    print(-1, -1)
    return


sol()

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
int main(void){
    int n,d,i,j,k,count=0;
    double sum=0;
    scanf("%d %d",&n,&d);
    int p[n][d];
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            scanf("%d",&p[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            for(k=0;k<d;k++){
                sum+=pow(p[i][k]-p[j][k],2);
                //printf("%f\n",sum);
            }
            if(ceil(sqrt(sum))==floor(sqrt(sum))){
                count++;
                //printf("%d %d\n",i,j);
            }
            sum=0;
        }

    }
    printf("%d",count);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
// #define INT_MAX 1000000000 this is wrong as INT_MAX is already included in header<climits> and  2147483647  
// #define INT_MIN -1000000000
#define INF 1000000000
#define LL_MAX 1000000000000000000
#define LL_MIN -1000000000000000000
#define mod1 1000000007
#define ll long long 
#define ld long double
#define vi vector <int>
#define vvi vector <vector<int>>
#define vll vector<long long>
#define vvl vector <vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pair<int,int>>
#define pld pair<ld,ld>
#define vpll vector<pair<ll,ll>>
#define vpld vector<pair<ld,ld>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; } 
constexpr int pct(int x) { return __builtin_popcount(x); } 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

template<class T>
T binpow(T a, T b, T m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
set<pair<int,int>>vis;
int main(){
	int H,W,M;
    cin>>H>>W>>M;
    vi cr(H),cw(W);
    while(M--){
        int x,y;
        cin>>x>>y;
        --x,--y;
        cr[x]++,cw[y]++;
        vis.insert({x,y});
    }
    int mr,mc;
    mr=*max_element(all(cr));
    mc=*max_element(all(cw));
    vi r,c;
    for(int i=0;i<H;i++)if(cr[i]==mr)r.pb(i);
    for(int i=0;i<W;i++)if(cw[i]==mc)c.pb(i);
    bool flag = true;
    for(auto i:r){
        for(auto j:c){
            if(vis.find({i,j})==vis.end()){
                cout<<mr+mc<<endl;
                flag=false;
                break;
            }
        }
        if(flag==false)break;
    }
    if(flag)cout<<mr+mc-1;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/



Measured memory_bytes: 23856