akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int[] ans = GetAns(10000, inpt[1], inpt[0]);
        if(ans == null) {
            ans = new int[3].Select(a => -1).ToArray();
        }
        Console.WriteLine(String.Join(" ", ans));
    }


    Dictionary<int, Dictionary<int, Dictionary<int, bool>>> dic = new Dictionary<int, Dictionary<int, Dictionary<int, bool>>>();
    private int[] GetAns(int prevSatu, int remainAmount, int remainSatu) {
        if(remainAmount == 0) {
            if(remainSatu == 0) {
                return new int[3];
            }
            return null;
        }
        if(remainSatu<=0) {
            return null;
        }
        if(remainAmount<0) {
            return null;
        }
        if(prevSatu*remainSatu<remainAmount) {
            return null;
        }
        if(1000*remainSatu>remainAmount) {
            return null;
        }

        if(!dic.ContainsKey(prevSatu)) {
            dic.Add(prevSatu, new Dictionary<int, Dictionary<int, bool>>());
        }
        if(!dic[prevSatu].ContainsKey(remainAmount)) {
            dic[prevSatu].Add(remainAmount, new Dictionary<int, bool>());
        }
        if(dic[prevSatu][remainAmount].ContainsKey(remainSatu)) {
            return null;
        }
        int[] satuList = new int[] { 10000, 5000, 1000 };
        for (int i = 0; i < satuList.Length; i++) {
            int s = satuList[i];
            if(s>prevSatu) {
                continue;
            }
            int[] tmp = GetAns(s, remainAmount - s, remainSatu - 1);
            if(tmp!=null) {
                tmp[i]++;
                return tmp;
            }
        }
        dic[prevSatu][remainAmount][remainSatu] = true;
        return null;
    }


    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



2000 20000000

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13792
#include <stdio.h>
 
int main(void){
  char s[101],p[101];
  int i,j,sn=0,pn=0,t;
 
  scanf("%s %s",s,p);
 
//文字数カウント
  while(s[sn] != '\0') sn++;
  while(p[pn] != '\0') pn++;
 
  for(i=0;i<sn;i++){
    t=1;
    for(j=0;j<pn;j++)
      if(s[(i+j)%sn] != p[j]) t=0;
    if(t) break;
  }
 
  if( t )
    printf("Yes\n");
  else
    printf("No\n");
 
  return 0;
}
   


Measured memory_bytes: 2112
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var total = h.Skip(1).Where((x, i) => h.Take(i + 1).Max() <= h.Skip(i + 1).First()).Count();
            Console.WriteLine(total + 1);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  double n, k;
  cin >> n >> k;
  cout << ceil((n - 1) / (k - 1)) << endl;
  return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> v;
  rep(i, n){
    int x; cin >> x;
    auto it = lower_bound(v.begin(), v.end(), x);
    if(it == v.begin()){
      v.insert(v.begin(), x);
    }
    else{
      it--;
      *it = x;
    }
    /*rep(j, v.size()){
      cout << v[j] << " ";
    }
    cout << endl;*/
  }
  cout << v.size() << endl;
  return 0;
}


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

typedef long long int ll;


int main()
{
    string s;
    ll n;
    cin >> n >> s;

    for(ll i = 0;i < s.size();i++){
        if(s[i] + n > 'Z'){
            s[i] = s[i] + n - 26;
        }
        else{
            s[i] += n;
        }
    }

    cout << s;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

template<class T>
class SegmentTree{
  using F=function<T(T,T)>;
private:
  ll n=1;
  F dot;
  T e;
  vector<T> node;
public:
  SegmentTree(const vector<T> &A,F dot,T e):dot(dot),e(e){
    while(n<A.size()) n<<=1;
    node.resize(2*n,e);
    rep(i,A.size()) node[n+i]=A[i];
    for(ll i=n-1;i>0;--i) node[i]=dot(node[2*i],node[2*i+1]);
  }
  void update(ll i,T c){
    node[i+=n]=c;
    while(i>>=1) node[i]=dot(node[2*i],node[2*i+1]);
  }
  T sum(ll l,ll r){
    T vl=e, vr=e;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
      if(l%2==1) vl=dot(vl,node[l++]);
      if(r%2==1) vr=dot(node[--r],vr);
    }
    return dot(vl,vr);
  }
  ll bisect(ll l,ll r,T x,bool increase=true,ll i=1,ll a=0,ll b=-1){
    if(b==-1) b=n;
    if(increase){
      if(node[i]<=x||b<=l||r<=a) return -1;
      if(i>=n) return i-n;
      ll lv=bisect(l,r,x,increase,2*i,a,(a+b)/2);
      if(lv!=-1) return lv;
      return bisect(l,r,x,increase,2*i+1,(a+b)/2,b);
    } else {
      if(node[i]>=x||b<=l||r<=a) return -1;
      if(i>=n) return i-n;
      ll rv=bisect(l,r,x,increase,2*i+1,(a+b)/2,b);
      if(rv!=-1) return rv;
      return bisect(l,r,x,increase,2*i,a,(a+b)/2);
    }
  }
};

void solve(){
  ll n; cin>>n;
  vector<ll> H(n),A(n);
  rep(i,n){
    cin>>H[i];
    H[i]--;
  }
  rep(i,n) cin>>A[i];
  auto dot=[](ll a,ll b){return max(a,b);};
  SegmentTree<ll> tree(vector<ll>(n,0),dot,0);
  rep(i,n){
    tree.update(H[i],tree.sum(0,H[i])+A[i]);
  }
  cout<<tree.sum(0,n)<<"\n";
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/

int dp[5005][5005];

int main()
{
	FASTIO
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	int n;
	string s;
	cin >> n >> s;
	for (int i = n - 1; i >= 0; --i) {
		for (int j = n - 1; j >= 0; j--) {
			if (s[i] == s[j])
				dp[i][j] = dp[i + 1][j + 1] + 1;
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i >= j) continue;
			int x = min(dp[i][j], j - i);
			ans = max(ans, x);
		}
	}
	cout << ans << endl;
}

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

#define pb push_back
#define rb  pop_back
#define rf  pop_front
#define ins insert
#define f   first
#define s   second
#define um  unordered_map
#define us  unordered_set
#define pq  priority_queue

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef vector<double> vd;
typedef pair<double,double> pd;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef us<int> si;
typedef us<double> sd;
typedef us<ll> sll;
typedef vector<vd> md;


const int MAX = 1e6;
const int N = 200043;
const int MOD = 998244353;

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define EE endl
#define PI 3.14159265
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
#define SOT(A) sort(A.begin(),A.end())
#define SOTR(A) sort(A.rbegin(),A.rend())
#define REV(a) reverse(ALL(a))

// LOOP Control Statements
#define forn(i,j,n) for ( auto i=j ; i<n ; i++ )
#define fornd(i,j,n) for ( auto i=j ; i>n ; i-- )
#define FORE(i, b) for(auto &i:b)


#define SQ(i) (i*i)
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define tcase(term) int tc;cin>>tc;for(int term=0; cout<<"CASE "<<term+1<<EE,term<tc;term++)

vector<bool> is_prime(MAX+1, true);
void Sieve(){
	is_prime[0] = is_prime[1] = false;
	ll i,j;
	for (i = 2; i*i <= MAX; i++) {
    	if (is_prime[i]) {
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
    // tcase(term)
    {
    ll a,b,k,ans=0,x;
	cin>>a>>b;
	if(a<b)k=a,a=b,b=k;
	ll g=__gcd(a,b);
	if(g%2==0)ans++;
	while(g%2==0)g/=2;
	x=sqrt(g);
	for(int i=3;i<=x;i+=2)
		if(g%i==0)
		{
			ans++;
			while(g%i==0)g/=i;
			x=sqrt(g);
		}
	if(g>1)ans++;
	cout<<ans+1<<EE;
}}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  map<int, int> mp;
  priority_queue<int> pq;
  rep(i, n){
    int a; cin >> a;
    mp[a]++;
    if(mp[a] == 2){
      pq.push(a);
      mp[a] = 0;
    }
  }

  if(pq.size() < 2){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  ans *= pq.top(); pq.pop();
  ans *= pq.top(); pq.pop();
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int ans[501][501];
void build(int st,int pnum,int level){
	if(pnum==1) return;
	if(pnum==2){
		ans[st][st+1]=level;
		return ;
	}
	int zen=pnum/2;
	for(int i=st;i<st+zen;i++){
		for(int j=st+zen;j<st+pnum;j++){
			ans[i][j]=level;
		}
	}
	build(st,zen,level+1);
	build(st+zen,pnum-zen,level+1);
}
int main(){
	int N;
	scan(N);
	build(0,N,1);
	rep(i,N-1){
		for(int j=i+1;j<N;j++){
			printf("%d ",ans[i][j]);
		}
		kaigyo;
	}
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#define MAX 100
#define number 2000

struct graph {
   int next;
   int length;
};

int nord[MAX];
int start = 0;
int memo[MAX] = { 0 };
struct graph LIST[MAX][100];

int searchmin(int n, int *C) {
   int i, j;
   for (i = 0; i < n; i++) {
	  if (memo[i] != 0) {
		 for (j = 0; j < memo[i]; j++) {
			if (LIST[i][j].length == (*C) && ((nord[i] == 0 && nord[LIST[i][j].next] == 1) || (nord[LIST[i][j].next] == 0 && nord[i] == 1))) {
			   nord[i] = 1;
			   nord[LIST[i][j].next] = 1;
			   *C = 0;
			   return LIST[i][j].length;
			}
		 }
	  }
   }
   *C = *C + 1;
   return searchmin(n, C);
}

int main() {
   int n, ans = 0;
   int check = 0, cost;
   int i, j, d;

   scanf("%d", &n);

   for (i = 0; i < n; ++i) {
	  nord[i] = 0;
	  for (j = 0; j < n; ++j) {
		 scanf("%d", &d);
		 if (j > i && d != -1) {
			LIST[i][memo[i]].next = j;
			LIST[i][memo[i]].length = d;
			++memo[i];
		 }
	  }
   }

   nord[0] = 1;
   cost = 0;
   while (check == 0) {
	  ans += searchmin(n, &cost);
	  check = 1;
	  for (i = 0; i < n; ++i) {
		 check = check * nord[i];
		 if (nord[i] == 0)  break;
	  }
   }
   printf("%d\n", ans);
   return 0;
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	string t="CODEFESTIVAL2016";
	int c;
	rep(i,16){
		if(s[i]!=t[i]) c++;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 764
#include <iostream>

class Dice {
public:
    int num[6];
    void move (char cmd) {
        if (cmd == 'N') north();
        if (cmd == 'S') south();
        if (cmd == 'E') east();
        if (cmd == 'W') west();
        if (cmd == 'R') right();
        if (cmd == 'L') left();
    }
    void north () {
        std::swap(num[0], num[1]);
        std::swap(num[1], num[5]);
        std::swap(num[5], num[4]);
    }
    void south () {
        std::swap(num[0], num[4]);
        std::swap(num[4], num[5]);
        std::swap(num[5], num[1]);
    }
    void east () {
        std::swap(num[0], num[3]);
        std::swap(num[3], num[5]);
        std::swap(num[5], num[2]);
    }
    void west () {
        std::swap(num[0], num[2]);
        std::swap(num[2], num[5]);
        std::swap(num[5], num[3]);
    }
    void right () {
        move('W'); move('S'); move('E');
    }
    void left () {
        move('E'); move('S'); move('W');
    }
    bool operator == (Dice _dice) {
        int count = 0;
        for (int i=0;i<6;++i)
            if (this->num[i] != _dice.num[i])
                count++;
        if (count == 0) return true;
        else return false;
    }
};

int main() {
    Dice da, db;
    for (int i=0;i<6;++i)
        std::cin >> da.num[i];
    for (int i=0;i<6;++i)
        std::cin >> db.num[i];
    std::string cmd_gorogoro = "NNNNEEEE";
    std::string cmd_rotate = "RRRR";
    for (int i=0;i<(int)cmd_gorogoro.size();++i) {
        for (int j=0;j<(int)cmd_rotate.size();++j) {
            if (da == db) {
                std::cout << "Yes" << std::endl;
                return 0;
            }
            else da.move(cmd_rotate[j]);
        }
        da.move(cmd_gorogoro[i]);
    }
    std::cout << "No" << std::endl;
    
    return 0;
}


Measured memory_bytes: 3228
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=1e5+5;



int main()
{

       
         string s,t;
         cin >> s >> t;
         int len1=s.size();
         int len2=t.size();
         int dp[len1+1][len2+1];
         memset(dp,0,sizeof(dp));
         for(int i=1;i<=len1;i++)
         {
           for(int j=1;j<=len2;j++)
           {
              if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
              else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
           }
         }
         string ans="";
        int i=len1,j=len2;
        while(i>=1 && j >=1){
          if(s[i-1]==t[j-1])
          {
            ans.pb(s[i-1]);
            i--;
            j--;
          }
          else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
          else
         j--; 
        }
        reverse(ans.begin(),ans.end());
        cout<<ans;

         
     return 0;
}



Measured memory_bytes: 35456
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, K, S) = list(map(int,input().split()))
ans = [S for _ in range(K)]
if S != 10 ** 9: 
    ans[len(ans):len(ans)]= [10 ** 9  for _ in range(N-K)]
else:
    ans[len(ans):len(ans)]= [1  for _ in range(N-K)]
print(' '.join(list(map(str,ans))))
exit(0)



Measured memory_bytes: 12704
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9+7;
typedef long long int lli;
typedef pair<lli,lli> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<bool> vb;
long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
long long int binpow(long long a, long long b, long long 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;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

//############################ENDOFTEMPLATE############################



void solve(){
  lli n,k;
  cin>>n>>k;

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

  
  lli cnt1 = 0;
  for(int i = 0;i<n;i++){
    
    for(int j = i+1;j<n;j++){
      if(a[j]<a[i])
        cnt1++;
    }

    
  }

  lli cnt2 = 0;
  for(int i = 0;i<n;i++){
    for(int j = 0;j<n;j++){
      if(a[j]<a[i])
        cnt2++;
    }
  }

  

  long long ans = 0;
  lli m1 = (k*(k-1)/2)%mod;
  lli m2 = k%mod;

  ans = (cnt1*m2+cnt2*m1)%mod;

  cout<<ans;


}



int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //freopen("input_custom.txt","w",stdout);
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

const string YES = "Yes";
const string NO = "No";
void solve(long long N, long long M, std::vector<long long> A) {
    int sum = 0;
    rep(i, N) {
        sum += A[i];
    }
    int n = 0;
    rep(i, N) {
        if (4 * M * A[i] >= sum) {
            n++;
        }
    }
    cout << (n >= M ? YES : NO) << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    int[] D;
    int K;

    void solve() throws IOException {
    	int N = ni();
    	K = ni();
    	D = nia(K);

    	int n = N;
    	while (!ok(n)) {
    		n++;
    	}
    	out.println(n);
    }

    boolean ok(int n) {
    	boolean flg = true;
    	while (n != 0) {
    		int p = n % 10;
    		for (int i=0; i<K; i++) {
    			if (p == D[i]) {
    				flg = false;
    			}
    		}
    		n /= 10;
    	}
    	return flg;
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}


Measured memory_bytes: 8148
// ABC172.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

// A /////////////////////////////////////////////////

int main()
{
	int input;//, output;

	cin >> input;

	cout << input + (input * input) + (input * input * input);

	return 0;
}





Measured memory_bytes: 3168
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var a, b, c, k int
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)
	fmt.Fscan(r, &c)
	fmt.Fscan(r, &k)

	ans := min(k, a)
	k -= a
	k -= b
	if k > 0 {
		ans -= min(k, c)
	}
	fmt.Println(ans)
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

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

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

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 1824
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int a[101][10001],v[1001],w[1001],b,n;
int dp(int i,int j){
  if(a[i][j])return a[i][j];
  int res;
  if(i==n)res=0;
  else if(j<w[i])res=dp(i+1,j);
  else res=max(dp(i+1,j),dp(i+1,j-w[i])+v[i]);
  return a[i][j]=res;
}
int main(){
  cin>>n>>b;
  r(i,n)cin>>v[i]>>w[i];
  cout<<dp(0,b)<<endl;
}

Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; cin>>s;
    if(s=="AAA" || s=="BBB") cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--) 
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,0,n){
        cin >> p[i];
    }
    int cnt=0;
    rep(i,0+1,n-1){
        int rfmax,rfmin;
        rfmax=max(p[i-1],p[i+1]);
        rfmin=min(p[i-1],p[i+1]);
        if(p[i]>rfmin && p[i]<=rfmax){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 文字列の入力
    n <- getLine
    s <- getLine
    let res = map sum $ inits $ map (\c -> if c == '(' then 1 else -1) s
        xmin = minimum res
        ds = last res
    putStrLn $ replicate (negate xmin) '(' ++ s ++ replicate (ds - xmin) ')'


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

namespace abc177.a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = getIntParams();

            Console.WriteLine(input[0] <= (input[1] * input[2]) ? "Yes" : "No");
        }

        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }

        static string getStringParam()
        {
            return Console.ReadLine();
        }

        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}

Measured memory_bytes: 28308
#include <iostream>

using namespace std;

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

int main()
{
    int a, b;
    while (cin >> a >> b)
    {
        int d = gcd(a, b);
        cout << d << " " << (a / d) * b << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	if(k==n){
		mint ans=1;
		rep(i,n) ans*=a[i];
		cout<<ans<<'\n';
		return 0;
	}

	vector<lint> p,m;
	rep(i,n){
		if(a[i]>=0) p.emplace_back(a[i]);
		else        m.emplace_back(a[i]);
	}
	sort(p.rbegin(),p.rend());
	sort(m.begin(),m.end());

	if(m.size()==n){
		mint ans=1;
		if(k%2==0){
			rep(i,k) ans*=m[i];
		}
		else{
			rep(i,k) ans*=m[n-1-i];
		}
		cout<<ans<<'\n';
		return 0;
	}

	mint ans=1;
	int pidx=0,midx=0;
	if(k%2==1) ans*=p[pidx++], k--;
	while(k>0){
		if(pidx+1>=p.size()){
			ans*=m[midx++];
			ans*=m[midx++];
		}
		else if(midx+1>=m.size()){
			ans*=p[pidx++];
			ans*=p[pidx++];
		}
		else if(p[pidx]*p[pidx+1]>=m[midx]*m[midx+1]){
			ans*=p[pidx++];
			ans*=p[pidx++];
		}
		else{
			ans*=m[midx++];
			ans*=m[midx++];
		}
		k-=2;
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 200010;
const double oo = 1e100;
int h[N];
ll pd[N];

using line = pair<ll, ll>;

double intersect(const line& h1, const line& h2)
{
	ll a1 = h1.fi, b1 = -1, c1 = -h1.se;
	ll a2 = h2.fi, b2 = -1, c2 = -h2.se;

	ll num = c1 * b2 - b1 * c2;
	ll den = a1 * b2 - a2 * b1;

	return (1. * num)/den;
}

int main()
{
	int n;
	ll c;
	scanf("%d %lld", &n, &c);
	for (int i = 0; i < n; i++)
		scanf("%d", h+i);
	
	vector<double> vx;
	vector<line> l;
	l.eb(h[n-1], (ll)h[n-1] * h[n-1]);
	vx.eb(-oo);
	int sz = 1;
	for (int i = n-2; i >= 0; i--)
	{
		ll x = -2 * h[i];
		int pos = upper_bound(vx.begin(), vx.end(), 1.*x) - vx.begin();
		pos--;
		
		pd[i] = l[pos].fi * x + l[pos].se + c + (ll)h[i] * h[i];
		
		line cur(h[i], (ll)h[i] * h[i] + pd[i]);
		while (sz > 1)
		{
			if (intersect(cur, l[sz-2]) < intersect(l[sz-1], l[sz-2]))
			{
				l.pop_back();
				vx.pop_back();
				sz--;
			}
			else
				break;
		}
		l.pb(cur);
		sz++;
		vx.pb(intersect(l[sz-1], l[sz-2]));
	}
	printf("%lld\n", pd[0]);
	return 0;
}

Measured memory_bytes: 10480
#include <stdio.h>
int main(void)
{
    int i,j,k,n,m,l,a[100][100],b[100][100];
	long c[100][100];
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++)
            scanf("%d",&a[i][j]);
    }
    for(i=0;i<m;i++){
		for(j=0;j<l;j++)
			scanf("%d",&b[i][j]);
    }
    for(i=0;i<n;i++){
		for(j=0;j<l;j++){
	        c[i][j]=0;
        	for(k=0;k<m;k++){
            	c[i][j]=c[i][j]+a[i][k]*b[k][j];
        	}
			printf("%ld",c[i][j]);
			if(j!=l-1)
				printf(" ");
        }
    	printf("\n");
    }
    return 0;
}

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

int main(void){
  int n;
  vector<int> v;
  cin >> n;
  for (int i=0; i<n; i++){
    int t;
    cin >> t;
    v.push_back(t);
  }
  sort(v.begin(), v.end());
  cout << v[n-1]-v[0] << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N, K;
  
  cin >> N >> K;
  int sum = 0;
  
  int x;
  for (int i=0; i < N; i++) {
    cin >> x;
    if (K - x >= x) {
      sum += 2 * x;
    } else {
      sum += 2 * (K - x);
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[50][64];
char val[7];
bool v[7];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int a,b;
		scanf("%d%d",&a,&b);
		for(int i=0;i<a;i++){
			scanf("%s",str[i]);
		}
		for(int i=0;i<7;i++)v[i]=false;
		int now=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if(str[i][j]!='.'){
					bool p=false;
					for(int k=0;k<now;k++)if(str[i][j]==val[k])p=true;
					if(!p)val[now++]=str[i][j];
				}
			}
		}
		for(int i=0;i<now;i++){
			for(int j=0;j<now;j++){
				if(v[j])continue;
				int top=100;
				int bottom=0;
				int left=100;
				int right=0;
				for(int k=0;k<a;k++){
					for(int l=0;l<b;l++)if(val[j]==str[k][l]){
						top=min(top,k);
						bottom=max(top,k);
						left=min(left,l);
						right=max(right,l);
					}
				}
				bool ok=true;
				for(int k=top;k<=bottom;k++){
					for(int l=left;l<=right;l++){
						if(str[k][l]!=val[j]&&str[k][l]!=':')ok=false;
					}
				}
				if(ok){
					v[j]=true;
					for(int k=top;k<=bottom;k++){
						for(int l=left;l<=right;l++){
							str[k][l]=':';
						}
					}
				}
			}
		}
		bool ret=true;
		for(int i=0;i<now;i++)if(!v[i])ret=false;
		if(ret)printf("SAFE\n");
		else printf("SUSPICIOUS\n");
	}
}

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

using namespace std;

#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for (long long a = b; a < c; a++)
#define f0rd(a, b) for (long long a = b; a >= 0; a--)
#define f1rd(a, b, c) for (long long a = b; a >= c; a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define f first
#define s second

#define ao(a, n) {for (int ele = 0; ele < n; ele++) { if (ele) cout << " "; cout << a[ele]; } cout << endl;}

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const ll inf = 1e12;
const ll mod = 1e9 + 7;

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

    string s; cin >> s;

    ll sz = s.length();

    ll pref[sz];

    ll ret = 0;

    pref[0] = s[sz - 1] - '0';

    map<ll, ll> mp;

    ll pt = 10;

    for (int i = sz - 2; i >= 0; i--) {
        pref[sz - i - 1] = (pref[sz - i - 2] + pt * (s[i] - '0')) % 2019;

        pt = (pt * 10) % 2019;
    }


    f0r(i, sz) {
        if (pref[i] == 0) {
            ret++;
        }

        ret += mp[pref[i]];

        mp[pref[i]]++;
    }

    cout << ret << endl;




}




Measured memory_bytes: 5284
import math
def findFactors(n):
    now=n
    f=[]
    while now%2==0:
        now//=2
        f.append(2)
    p=3
    while p<=math.sqrt(n):
        while now%p==0:
            now//=p
            f.append(p)
        p+=2
        if now==1:
            break
    if now>math.sqrt(n):
        f.append(now)
    return f

C=[0]
for i in range(1,100):
    C.append(C[-1]+i)
    
n=int(input())
F=findFactors(n)

ans=0
now=0
cnt=0
for f in F:
    if now!=f:
        for c in range(1,90):
            if C[c]>cnt:
                break
        ans+=c-1
        now=f
        cnt=1
    else:
        cnt+=1
for c in range(1,100):
    if C[c]>cnt:
        break
ans+=c-1       
print(ans)

Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll N; cin >> N;
    ll cnt = 0;
    rep(ii, N) rep(jj, N) rep(kk , N){
        ll i = ii + 1;
        ll j = jj + 1;
        ll k = kk + 1;
        ll g = __gcd(i, j);
        cnt += __gcd(g, (ll)k);
    }
    pt(cnt);
}
 

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128


signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, tot;
  cin >> n >> tot;
  std::vector<int> a(n);  
  for(int i = 0; i < n; ++i) {
  	cin >> a[i];
  }
  sort(all(a));
  int sum = 0, res = 0;
  for(int i = 0; i < n; ++i) {
  	sum += a[i];
  	if(sum <= tot) {
  		++res;
  	} else {
  		break;
  	}
  }
  if(res == n && sum < tot) --res;
  cout << res << endl;
	return 0;
}

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



signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0LL,a+b-n);   

}


Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<vector<int> > bit(n);
  REP(i, n) {
    REP(j, 21) if (a[i] & (1 << j)) {
      bit[i].emplace_back(j);
    }
  }
  map<int, int> mp;
  long long ans = 0;
  int j = 0;
  REP(i, n) {
    while (j < n) {
      for (int e : bit[j]) ++mp[e];
      bool over = false;
      REP(k, 21) {
        if (mp[k] > 1) over = true;
      }
      if (over) {
        for (int e : bit[j]) --mp[e];
        break;
      }
      ++j;
    }
    ans += j - i;
    if (i == j) {
      for (int e : bit[j]) ++mp[e];
      ++j;
    }
    for (int e : bit[i]) --mp[e];
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n, m;
	cin >> n >> m;
	vector< pair<ll, ll> > vp(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		vp[i] = make_pair(a, b);
	}
	sort(all(vp));

	ll i = 0, ans = 0;
	while (m > 0) {
		if (m - vp[i].second > 0)
			ans += vp[i].first * vp[i].second;
		else
			ans += vp[i].first * m;
		m -= vp[i].second;
		++i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
map <int, int> m;
vector <pair<int, int>> g[16];
void sol() {
  int bit[16];
  int n;
  int a;
  cin >> n;
  int val = (int)pow(2, n);
  for(int i=0; i<n; i++) {
    int x, y;
    cin >> a;
    for(int j=0; j<a; j++) {
      cin >> x >> y;
      g[i].pb(mp(x, y));
    }  
  }
  int ans = 0;
  for(int pp=0; pp<val; pp++) {
    int cnt = 0;
    int v = 1;
    m.clear();
    memset(bit, 0, sizeof(bit));
    int k = pp, q = 0;
    while(k) {
      bit[n-(++q)] = k % 2;
      if(k % 2) cnt++;
      k/=2;
    }
    //for(int i=0; i<n; i++) cout << bit[i]; cout << endl;
    for(int i=0; i<n; i++) {
      
      if(!bit[i]) { 
        ;
      }
      else {
        for(auto j: g[i]) {
          int x = j.first;
          int y = j.second;
          //if(i == 1) cout << x << " " << y << endl; 
          //if(!bit[x-1]) continue;
          if(y != bit[x-1]) {
            //cout << "i = " << i << "\n";
            v = 0;
          } 
        }
      }
    }
    if(v) {
      ans = max(ans, cnt);
    }
  }
  cout << ans << "\n";
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

void solve() {
	ll k,n;cin>>k>>n;
	if(k*500ll>=n)cout<<"Yes";else cout<<"No";
}

int main()
{
    fastIO;ll t=1;
    // cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>

# define FILE
using namespace std;

const int N = 1e5 + 100;
int n, H[N], ans = 0;

int main()
{
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif // FILE
    ios_base::sync_with_stdio( false );
    long long n;
    cin >> n;
    cout << (n*(n-1))/2;
    return 0;
}


Measured memory_bytes: 256