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

int main()
{
    int a,b,i;
    char c[12];
    while(cin>>a>>b)
    {
        cin>>c;
        int k=0;
        for(i=0;i<a;i++)
            if(!(c[i]>='0'&&c[i]<='9'))
            {
                puts("No");
                k=1;
                break;
            }
        if(k) continue;
        if(c[a]!='-'){puts("No");continue;}
        for(i=a+1;i<b+a+1;i++)
            if(!(c[i]>='0'&&c[i]<='9'))
            {
                puts("No");
                k=1;
                break;
            }
        if(k) continue;
        puts("Yes");
    }
    return 0;
}

Measured memory_bytes: 256
N,*P=map(int,open(0))
ids=[0]*N
for i in range(N):
	ids[P[i]-1]=i
tmp=inc=1
for i in range(N-1):
	if ids[i]<ids[i+1]:
		tmp+=1
		inc=max(tmp,inc)
	else:
		tmp=1
print(N-inc)

Measured memory_bytes: 18992
#include<vector>
#include<queue>
#include<functional>
#include<algorithm>
#include<set>
#include<iostream>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;

const int MX = 1<<17;
const int MM = 1000000007;

int D[MX];
int N;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	sort(D+1, D+N+1);
	reverse(D+1, D+N+1);
	for(int i = 1; i <= N; i++){
		if( i+1 > D[i+1]){
			int ok = 1;
			for(int j = i; D[j] >= i; j++) ok ^= 1;
			ok |= (D[i] - i)&1;
			return !printf("%s\n", ok? "First" : "Second");
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    int N, a[100000], current = 0, cnt = 0;
    bool visited[100000];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        visited[i] = false;
    }
    visited[1] = true;
    while (!visited[current]) {
        visited[current] = true;
        current = a[current] - 1;
        cnt++;
    }
    cout << (current == 1 ? cnt : -1) << endl;
}

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

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

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	if(n & 1){
		REP(i,n){
			cin >> a[i];
			if(a[i] & 1){
				cout << 0 << endl;
				return 0;
			}
		}
		sort(a.begin(),a.end());
		for(int i = 0;i < n;i+=2){
			if(i == 0){
				if(a[i] == 0){i--;continue;}
				else {
					cout << 0 << endl;
					return 0;
				}
			}else{
				if(a[i] != i + 1 || a[i + 1] != i + 1){
					cout << 0 << endl;
					return 0;
				}
			}
		}
	}else{
		REP(i,n){
			cin >> a[i];
			if(!(a[i] & 1)){
				cout << 0 << endl;
				return 0;
			}
		}
		sort(a.begin(),a.end());
		for(int i = 0;i < n;i+=2){
			if(a[i] != i + 1 || a[i + 1] != i + 1){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	unsigned long long ans = 1;
	REP(i,n/2){
		ans <<= 1;
		ans %= (int)1e9 + 7;
	}
	cout << ans << endl;
	
  return 0;
}


Measured memory_bytes: 640
s = input()

al = list(set(s))

al_ans = 100

for ma in al:

    now = 0
    ans = 0

    for i in range(len(s)):
        if s[i]==ma:
            if ans<now:
                ans = now
            now = 0
        else:
            now = now+1
    else:
        if ans<now:
            ans = now
            
    if ans<al_ans:
        al_ans = ans
    
print(al_ans)

Measured memory_bytes: 3064
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var x = int.Parse(input.ReadLine());

        var p = x % 100;

        var c5 = p / 5; p = p % 5; //Debug.Write(c5); Debug.Write(' ');
        var c4 = p / 4; p = p % 4; //Debug.Write(c4); Debug.Write(' ');
        var c3 = p / 3; p = p % 3; //Debug.Write(c3); Debug.Write(' ');
        var c2 = p / 2; p = p % 2; //Debug.Write(c2); Debug.Write(' ');
        var c1 = p / 1; p = p % 1; //Debug.Write(c1); Debug.Write(' ');
        //Debug.WriteLine("");

        var n = c1*101 + c2*102 + c3*103 + c4*104 + c5*105;
        if (n <= x) return 1;
        else return 0;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,a[3],b;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3,greater<ll>());
    ll ans=(a[0]*10+a[1])+a[2];
    cout<<ans<<endl;
    

    
    
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

map<string,int> minCosts;
map<string,int> value;
map<string,vector<string> > gousei;

int resolveMinCost(string name){
	if(minCosts.find(name)!=minCosts.end())
		return minCosts[name];

	int cost=value[name];
	if(gousei.find(name)!=gousei.end()){
		int sumCost=0;
		for(int i = 0; i < gousei[name].size(); i++){
			sumCost+=resolveMinCost(gousei[name][i]);
		}
		cost=min(cost,sumCost);
	}

	minCosts[name]=cost;
	return cost;
}

int main(){

	int n;
	while(cin>>n&&n!=0){
		for(int i =0; i < n; i++){
			string str;
			cin>>str;
			int val;
			cin>>val;
			value[str]=val;
		}
		int m;
		cin>>m;
		for(int i = 0; i < m; i++){
			string name;
			int k;
			cin>>name;
			cin>>k;
			vector<string> v;
			for(int j = 0; j < k; j++){
				string str;
				cin>>str;
				v.push_back(str);
			}
			gousei[name]=v;
		}
		string item;
		cin>>item;

		cout<<resolveMinCost(item)<<endl;

		gousei.clear();
		value.clear();
		minCosts.clear();
	}
	
	return 0;
}

Measured memory_bytes: 0
N, M, Q = map(int, input().split())
LR = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(M):
    L, R = map(int, input().split())
    LR[L][R] += 1

S = [[0] * (N + 1) for _ in range(N + 1)]
for l in range(N+1):
    for r in range(1, N+1):
        S[l][r] = LR[l][r] + S[l-1][r] + S[l][r-1] - S[l-1][r-1]

for i in range(Q):
    p, q = map(int, input().split())
    ans = S[q][q] - S[p-1][q] - S[q][p-1] + S[p-1][p-1]
    print(ans)

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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

int main(){
//  ios::sync_with_stdio(false);
//  cin.tie(0);
  int a,b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 0; i < 2; i++) {
    if (a < b) swap(a,b);
    ans += a;
    a--;
  }
  cout << ans << endl;
  return 0;
}


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


bool pallindrome(string s) {

	for (int i = 0; i < s.length() / 2; i++) {
		if (s[i] != s[s.length() - i - 1]) {
			return false;
		}
	}

	return true;
}

int main() {
	string s;
	cin >> s;
	int n = s.length();
	
	string r = s.substr(0, (n - 1) / 2);

	if (pallindrome(r) && pallindrome(s)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

struct Card { char suit, value; };

void bubbleSort(struct Card C[], int n) {
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j > i; j--) {
            if (C[j].value < C[j-1].value) {
                swap(C[j], C[j-1]);
            }
        }
    }
}

void selectionSort(Card C[], int n) {
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (C[j].value < C[minj].value) {
                minj = j;
            }
        }
        swap(C[i], C[minj]);
    }
}

void output(struct Card C[], int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int n) {
    for (int i = 0; i < n; i++) {
        if (C1[i].value == C2[i].value && C1[i].suit != C2[i].suit) {
            return false;
        }
    }
    return true;
}

int main () {
    int n;
    cin >> n;
    Card C1[n], C2[n];

    for (int i = 0; i < n; i++) {
        cin >> C1[i].suit >> C1[i].value;
        C2[i] = C1[i];
    }

    bubbleSort(C1, n);
    output(C1, n);
    cout << "Stable" << endl;
    selectionSort(C2, n);
    output(C2, n);
    if (isStable(C1, C2, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}

Measured memory_bytes: 3104
#include <stdlib.h>
#include <iostream>
#include <list>
using namespace std;

bool linear_search(int *array, int size, int num);
void print_children(int *children, int size);
struct graph{
	int parent_id;
	int child_num;
	int depth;
	int* children;
};
int main(){
	int n;
	cin >> n;
	graph* g = (graph*)calloc(n, sizeof(graph));
	//input data
	for(int i = 0; i < n; ++i){
		int id;
		int child_num;
		cin >> id;
		cin >> child_num;
		g[id].child_num = child_num;
		g[id].children = (int*)malloc(child_num * sizeof(int));
		for(int j = 0; j < child_num; ++j){
			int child_id;
			cin >> child_id;
			g[child_id].parent_id = id;
			//for calculating root
			g[child_id].depth = -1;
			g[id].children[j] = child_id;
		}
	}

	//calculate depth
	int depth = 0;
	while(true){
		bool does_depth_exsit = false;
		for(int i = 0; i < n; ++i){
			if(g[i].depth == depth){
				if(g[i].depth == 0) g[i].parent_id = -1;
				int child_num = g[i].child_num;
				for(int j = 0; j < child_num; ++j){
					g[g[i].children[j]].depth = depth+1;
				}
				does_depth_exsit = true;
			}
		}
		++depth;
		if(!does_depth_exsit){
			break;
		}
	}
	for(int i = 0; i < n; ++i){
		cout << "node " << i
		<< ": parent = " << g[i].parent_id
		<< ", depth = " << g[i].depth;
		if(g[i].depth == 0){
			cout << ", root";
		}else{
			if(g[i].child_num == 0){
				cout << ", leaf";
			}else{
				cout << ", internal node";
			}
		}
		cout << ", [";
		print_children(g[i].children, g[i].child_num);
		cout << "]" << endl;
	}
	return 0;
}

void print_children(int *children, int size){
	for(int j = 0; j < size; ++j){
		 	cout << children[j];
		 	if(j != size-1){
		 		cout << ", ";
		 	}
	}

}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < 3; ++i)
		cnt += (s[i] == 'A' ? 1 : 0);
	cout << (cnt % 3 ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
   ll n,y;
   cin>>n>>y;
   ll a[n+1];
   for(int i=0;i<n;i++)
    {
      cin>>a[i];
    } 
    a[n]=y;
    //if(n==1)
      //cout<<a[0]<<endl;
    
    //else
    {
    sort(a,a+n+1);
    vi v;
    for(int i=1;i<=n;i++)
    {
       v.pb(a[i]-a[i-1]);
    }
    sort(v.begin(),v.end());

     ll x=__gcd(v[0],v[1]);
     for(int i=2;i<v.size();i++)
     {
      x=__gcd(x,v[i]);
     }
     cout<<x<<endl;
   }
}
return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;



int main()
{

    
    int n,k;
    cin >> n >> k;
    ve<pair<int,int>> a(n);
    rep(i,n) {
        cin >> a[i].se >> a[i].fi;
        a[i].se--;
    }
    priority_queue<pair<int,int>> fi_a;
    priority_queue<pair<int,int>> se_a;
    ve<int> b(n,-1);
    
    sort(all(a));
    reverse(all(a));
    
    int c = k;
    ll anss = 0;
    
    rep(i,n){
        int t = a[i].se,d = a[i].fi;
        if(b[t] == -1){
            if(c > 0){
                c--;
                anss += d;
            }
            b[t] = d;
            fi_a.push({d,t});
        }else{
            se_a.push({d,t});
        }
    }
    
    ll ans = 0,an = 0,num = 0;
    
    rep(i,k){
        //out(ans);
        pair<int,int> fia,sea;
        if(fi_a.empty()){
            fia = {0,0};
        }else fia = fi_a.top();
        if(se_a.empty()){
            sea = {0,0};
        }else sea = se_a.top();
        
        if(fia.fi >= sea.fi){
            fi_a.pop();
            an += (ll)fia.fi;
            
            num++;
            ans = num*num + an;
            
        }else{
            ll a_ans = num*num+an+(ll)sea.fi;
            ll b_ans = 0;
            if(fia.fi != 0){
                b_ans = (num+1)*(num+1)+an+(ll)fia.fi;
            }
            if(b_ans < a_ans){
                ans = a_ans;
                se_a.pop();
                an += (ll)sea.fi;
                

                
            }else{
                fi_a.pop();
                an += (ll)fia.fi;
                num++;
                ans = num*num + an;
                
                
                
            }
        }
    }
    if(anss + (ll)(k-c)*(ll)(k-c) > ans){
        out(anss + (ll)(k-c)*(ll)(k-c));
    }else{
    
        out(ans);
    
    }
    return 0;
}


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

int main() {
    int n, result, m;
    
    cin >> n;
    
    int num[n];
    
    for(int i=0; i<n; i++) {
        cin >> num[i];
    }
    m = num[0];
    result = num[1]-num[0];
    
    for(int i=1; i<n; i++) {
        result = max(result, num[i]-m);
        m = min(m, num[i]);
    }
    
    
    cout << result << "\n";
    
    return 0;
}


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

using namespace std;

using ll = long long;

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k)cout << k;
    else if(a + b >= k)cout << a;
    else cout << a + (-1 * (k - a - b));
    return 0;

}


Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	//ABC166 C
	int n,m;
	int temp;
	int ret = 0;
	// N M
	// H H H H H H 
	// A B
	// A B
	// A B

	// N 個の展望台
	// H 標高
	// M 本の道 が A と B を繋ぐ
	// 展望台につながる道がない or ある展望台につながる展望台が全部低い だったら +1
	cin >> n >> m;

	vector<unsigned long long> h(n);
	vector<unsigned long long> ans(n, 0);
	// hyoukou
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	vector<pair<int, int>> ab(m);

	for (int i = 0; i < m; i++) {
		cin >> temp;
		ab[i].first = temp - 1;
		cin >> temp;
		ab[i].second = temp - 1;

		// 2つの展望台の高さを比べる
		if (h[ab[i].first] > h[ab[i].second]) {
			if (ans[ab[i].second] == 0) {
				ans[ab[i].second] = h[ab[i].first];
			}
		} else if (h[ab[i].first] < h[ab[i].second]) {
			if (ans[ab[i].first] == 0) {
				ans[ab[i].first] = h[ab[i].second];
			}
		}
		else {
			if (ans[ab[i].first] == 0) {
				ans[ab[i].first] = h[ab[i].second];
			}
			if (ans[ab[i].second] == 0) {
				ans[ab[i].second] = h[ab[i].first];
			}
		}

	}

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

	cout << ret;

	return 0;
}

Measured memory_bytes: 5636
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;
using Graph = vector<vector<int>>;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  vector<int>b(n);
  for(int i=0;i<n;i++) cin>>a[i]>>b[i];
  int amax=0;
  int now=0;
  for(int i=0;i<n;i++){
    if(amax<a[i]){
      amax=a[i];
      now=i;
    }
  }
  cout<<amax+b[now]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;

  int ans=0;

  for (int i=0; i<= a.length() ;i++) {
      if (a[i]=='1') {
          ans++;
      }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        String input = values[0];
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < input.length(); i++) {
            s.append("x");
        }
        System.out.println(s.toString());
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
using namespace std;
int main(){
	
	int f[4]={0};
	string s;
	cin>>s;
	if(s.length()>=6)
		f[0]=1;
	if(f[0]==1){
		for(int i=0;i<s.length();i++){
			if(s[i]>='A'&&s[i]<='Z')
				f[1]=1;
			else if(s[i]>='a'&&s[i]<='z')
				f[2]=1;
			else if(s[i]>='0'&&s[i]<='9')
				f[3]=1;
		}
	}
		if(f[1]==1&&f[2]==1&&f[3]==1)
			cout<<"VALID"<<endl;
		else
			cout<<"INVALID"<<endl;
	
		
	
	
 	
}

Measured memory_bytes: 1180
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if (a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if (a < b) a = b;}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 10050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;


int cum[2][200020];
void solve() {
	int N, M, K; cin >> N >> M >> K;
	vector<int>A(N), B(M);
	REP(i, N) {
		cin >> A[i];
		cum[0][i + 1] = cum[0][i] + A[i];
	}
	REP(i, M) {
		cin >> B[i];
		cum[1][i + 1] = cum[1][i] + B[i];
	}
	int ans = 0;
	REP(i, N+1) {
		int res = i;
		int rem = K - cum[0][i];
		if (rem < 0)break;
		int ok = 0, ng = M + 1;
		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if (cum[1][mid] <= rem) {
				ok = mid;
			}
			else ng = mid;
		}
		chmax(ans, res + ok);
	}
	print(ans);
}

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

	 //int q;
	 //cin >> q;
	 //while (q--)
	solve();
}


Measured memory_bytes: 9468
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
using namespace atcoder;

// #if __has_include("print.hpp")
//   #include "print.hpp"
// #endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 998244353

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; }

typedef long long ll;
typedef pair<ll, ll> p;

using mint = modint998244353;
struct S{
  mint x, w;
  S(mint x=0, mint w=1): x(x), w(w){}
};

S op(S a, S b){
  return S(a.x*b.w + b.x, a.w*b.w);
}

S e() {return S();}

S mapping(int f, S a){
  if(f == 0) return a;
  return S((a.w-1)/9 * f, a.w);
}

int comp(int f, int g){
  if(f == 0) return g;
  return f;
}

int id(){ return 0;}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, q;
  cin >> n >> q;

  lazy_segtree<S, op, e, int, mapping, comp, id> t(n);

  rep(i, n) t.set(i, S(1, 10));
  while(q--){
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    t.apply(l, r, d);
    // S ans = t.prod(0, n);
    // cout << ans.x.val() << endl;
    // printf("%lld\n", (ll)t.all_prod().x.val());
    cout << t.all_prod().x.val() << endl;
  }
}


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

int main() {
  int A, a, b, c;
  cin >> A;
  a = A / 100;
  b = (A - 100 * a) / 10;
  c = A - 100 * a - 10 * b;
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=105;
int n,a[N],f[N][N],ans=1e9;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	memset(f,127/3,sizeof(f));
	memset(f[0],0,sizeof(f[0]));
	for (int i=1;i<=n;i++)
	  for (int j=1;j<=n;j++)
	    for (int k=1;k<=n;k++)
	      if (j!=k) f[i][j]=min(f[i][j],f[i-1][k]+(a[i]!=j));
	for (int i=1;i<=n;i++) ans=min(ans,f[n][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
#include <set>
#include <fstream>
#include <iomanip>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i,n){
        cin >> v[i];
    }
    int m;
    cin >> m;
    vector<int> w(m);
    REP(i, m){
        cin >> w[i];

    }
    set<int> st;
    int tmp;
    REP(i,(long long int)pow(2,n)){
     //   cout << i << endl;
        tmp = 0;
        REP(j,n){
            if(i&(long long int)pow(2,j)){
                tmp += v[j];
            }
        }
        st.insert(tmp);
    }

REP(i,m){
    if(st.count(w[i])){
        cout << "yes" << endl;
    }else{
        cout << "no"<<endl;
    }
}
}


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		System.out.println(Math.min(a, b) + Math.min(c, d));

		sc.close();
	}

}




Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<pair<ll,ll>,ll>mp;
vector<pair<ll,ll>>v;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n;
    ll mx=0;
    for(ll i=1;i<=n;++i){
        ll a,b;
        cin>>a>>b;
        v.emplace_back(a,b);
    }
    for(ll i=0;i<n;++i){
        ll a=v[i].first;
        ll b=v[i].second;
        for(ll j=0;j<n;++j){
            if(j==i)continue;
            pair<ll,ll>tmp;
            if(a>=v[j].first){
                tmp.first=a-v[j].first;
                tmp.second=b-v[j].second;
            }
            else continue;
            mp[tmp]++;
            if(mp[tmp]>mx){
                mx=mp[tmp];
            }
        }
    }
    cout<<n-mx<<endl;
}


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

int main() {
  int N;
  cin >> N;
  int r = 100000;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int n = 0;
    while (A%2 == 0 && A != 0) {
      A /= 2;
      n += 1;
    }
    if (n < r) r = n;
  }
  cout << r << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    string ans = "";
    for(int i = 0; i < n; i++){
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define pbb pop_back
#define make_pair mp
#define all(x) x.begin(), x.end()
#define mem(array, value) memset(array, value, sizeof(array))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a,b))*b
#define line cout << "==========" << endl
#define mod 1000000007
#define SIZE 1000001

int main ()
{
    int m, d;
    cin >> m >> d;
    if (d < m)
        cout << m-1 << endl;
    else
        cout << m << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

vec d[100010];
ll ans[100010];
int main(){
    ll N,M; cin>>N>>M;
    rep(i,M){
        ll a,b; cin>>a>>b;
        a--; b--;
        d[a].pb(b);
        d[b].pb(a);
    }
    REP(i,1,100010) ans[i]=-1;
    queue<ll> Q;
    Q.push(0);
    while(!Q.empty()){
        ll x=Q.front();
        Q.pop();
        rep(i,d[x].size()){
            ll a=d[x][i];
            if(ans[a]==-1){
                ans[a]=x;
                Q.push(a);
            }
        }
    }
    bool able=true;
    rep(i,N) if(ans[i]==-1) able=false;
    if(!able) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        REP(i,1,N) cout<<ans[i]+1<<endl;
    }


}

Measured memory_bytes: 13044
#include <iostream>
#include<string>
#include <cmath>
#include<map>

using namespace std;
typedef long long ll;
const int N =1e6+5 ;
const int mod=1e9+7;
int Get_Divisors(int x)
{
    map<int,int>frq;
    for(ll i=1;i<=x;i++)
    {
    ll cur_num=i;
    for(ll j=2;j*j<=cur_num;j++)
    {
        while(cur_num%j==0)
        {
            frq[j]++;
            cur_num/=j;
        }
    }
    if(cur_num!=1)
    {
        frq[cur_num]++;
    }
    }
    ll divisors=1;
    map<int,int> ::iterator it =frq.begin();
    for(;it!=frq.end();it++)
    {
        divisors=(divisors*((it)->second+1))% mod;
        divisors%=mod;
    }
    return divisors;
}

int main()
{
    ll checkNuber;
    cin>>checkNuber;
   cout<<Get_Divisors(checkNuber);
    return 0;
}



Measured memory_bytes: 3608
#include <stdio.h>
#define PAI 3.14159265358979323846
 
int main(void)
{
  int r; // 半径R
  double enshu;
  
  scanf("%d", &r);
  
  enshu = 2.00 * PAI * (double)r;
  
  printf("%f", enshu);
  
  return 0;
}

Measured memory_bytes: 1752
///-BISMILLAHIR RAHMANIR RAHIM-///
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define pb push_back
#define scn(n) scanf("%lld",&n)
#define pi acos(-1)
#define ll long long
#define llu unsigned long long
#define mod 1000000007
int main()
{
    while(1)
    {
        string s;
        ll n,m,i,j=0;
        cin>>s;
        if(s=="-") break;
        cin>>n;
            while(n--)
            {
                cin>>m;
                j+=m;
            }
            ll len=s.size();
            ll k=j%len;
            ///cout<<j<<" "<<len<<" "<<k<<endl;
            for(i=k; i<len; i++)
            {
                cout<<s[i];
            }
            for(i=0; i<k; i++)
            {
                cout<<s[i];
            }
            cout<<endl;

    }
    return 0;
}



Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner io = new Scanner(System.in);
		String A = io.next();
		String B = io.next();
		
		int result = A.length()-B.length();
		
		if(result==0){
			for(int i = 0;i<A.length();i++){
				int a = Character.getNumericValue(A.charAt(i));
				int b = Character.getNumericValue(B.charAt(i));
				if(a-b!=0) {
					result = a-b;
					break;
				}
			}
		}
		System.out.println((result>0)? "GREATER":
							(result<0)? "LESS":
										"EQUAL");
		
	}
}

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

int main(){
  
  int N,Y;
  int a,b,c;
  int flag=0;

  cin >> N >> Y;
  
  for(a=0;a<=N;a++){
    for(b=0;b<=N-a;b++){
      c = N-a-b;
      if(10000*a + 5000*b + 1000*c == Y){
        flag=1;
      }
      if(flag == 1)
        break;
    }
      if(flag == 1)
        break;
  }
    
  if(flag == 1)
    cout << a << " " << " " << b << " " << c << endl;
  else
    cout << "-1 -1 -1" << endl;

  return 0;
}


Measured memory_bytes: 256
def check(c):
    f = False
    for i,s in enumerate(c):
        if c[i] != c[-(i+1)]:
            break
        if len(c) % 2 == 0 and i == len(c) / 2:
            f = True
            break
        if len(c) % 2 == 1 and i == (len(c) - 1) / 2:
            f = True
            break
    return f

S = input()
N = len(S)
if check(S) and check(S[0:(N-1)//2]) and check(S[(N+3)//2-1:N]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
MOD = 10 ** 9 + 7
n = int(input())
c = [int(input()) for _ in range(n)]
l = [c[0]]
for i in range(1, n):
    if c[i] != c[i - 1]:
        l.append(c[i])
n = len(l)
p = [-1] * (max(c) + 1)
q = [-1] * n
for i, x in enumerate(l[::-1]):
    q[n - i - 1] = p[x]
    p[x] = n - i - 1
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
    dp[i + 1] += dp[i]
    if q[i] != -1:
        dp[q[i] + 1] += dp[i + 1]
print(dp[n] % MOD)


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

int main() {

    const int maxValue = 100000 + 10;
    vector<bool> isPrime(maxValue, true);
    vector<int> primeSum(maxValue, 0);

    isPrime[0] = false;
    isPrime[1] = false;

    for(int i = 2; i * i <= maxValue; ++i) {

        if(!isPrime[i])
            continue;

        for(int j = 2; j * i <= maxValue; ++j)
            isPrime[i * j] = false;
    }

    for(int i = 2; i < maxValue; ++i) {
        if(isPrime[i] && isPrime[(i + 1) / 2])
            primeSum[i]++;

        primeSum[i] += primeSum[i - 1];
    }

    int n;

    cin >> n;

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

        int a, b;

        cin >> a >> b;

        cout << primeSum[b] - primeSum[a - 1] << endl;

    }

    return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
#define N 100010
int arr[ N ] , removes[ N ] , hashe[ N ];
multiset < pair < int , int > > hasheset[ N ] ;

int main() 
{
	int n , x , m ;
	cin >> n >> m ;
	
	for( int i = 0 ; i < n ; i++ ) {
		cin >> x ;
		arr[ x%m ]++ ;
		hashe[ x ]++;
	}
	
	int ans = ( arr[0] )/2 ;
	for( int i = 0 ; i < N ; i++ ) {
		if( hashe[ i ] ) 
			hasheset[ i%m ].insert( make_pair( 1 - hashe[i]%2 , hashe[ i ] ) );
	}
	
	for( int i = 1 , j = m - 1 ; i <= j ; i++,j-- ) {
		
		if( i == j ) {
			ans += arr[ i ]/2;
			arr[ i ] = 0 ;
			continue ;
		}
		int y = min( arr[ i ] , arr[ j ] );
		arr[ i ] -= y ;
		arr[ j ] -= y ;
		removes[ i ] = y ;
		removes[ j ] = y ; 
		ans += y ;
	}
	
	//cout << ans << endl ;
	
	//cout << 
	for( int i = 1 ; i < m ; i++ ) {
		if( arr[ i ] == 0 )
			continue ;
		
		while( removes[ i ] ) {
			pair < int , int > element = *hasheset[ i ].begin() ;
			hasheset[ i ].erase( hasheset[ i ].begin() );
			
			if( element.second == 0 ) continue ;
			removes[ i ]-- ;
			element.second-- ;
			element.first = 1 - element.first ;
			hasheset[ i ].insert( element );
		}
		
		for( multiset < pair < int , int > > :: iterator it = hasheset[ i ].begin() ; it != hasheset[ i ].end() ; it++ )
		{
			//cout << it -> second << " " << i << endl ;
			ans += ( it->second )/2;
		}
		//cout << ans << " " << i << "\n";
	}
	
	assert( ans <= n/2 );
	cout << ans ;
	
	return 0 ;
}

Measured memory_bytes: 10752
/*
	构造
	n为2的幂时显然无解 
	发现n大于3并且为奇数时很容易可以构造出一组解 
	每次增加两个时，两两配对即可
	如果最后还剩一个数也可以很容易配出来 
*/
#include <bits/stdc++.h>

using namespace std;

int n;

inline void link(int u, int v) {
	printf("%d %d\n", u, v);
}

int main() {
	scanf("%d", &n);
	if(n < 3 || (n & -n) == n) {
		puts("No");
	} else {
		puts("Yes");
		link(1, 2);
		link(2, 3);
		link(3, 1 + n);
		link(1 + n, 2 + n);
		link(2 + n, 3 + n);
		for(int i = 4; i < n; i += 2) {
			link(1, i);
			link(i, i + 1);
			link(1, i + 1 + n);
			link(i + 1 + n, i + n);
		}
		if(~n & 1) {
			int x = n;
			x ^= 1;
			for(int i = 2; i <= n; ++i) {
				int r = x ^ i;			
				if(r != 1 && r < n) {
					link(n, (i & 1 ? i + n : i));
					link(n + n, (r & 1 ? r + n : r));
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
const int N = 1e5+10;
int A[N],B[N],C[N];
ll cnt[N];
void inp(){
	int a,b,c;
	int n;scanf("%d",&n);
	for(int i =0 ;i<n;i++){ scanf("%d",&A[i]); }
	for(int i =0 ;i<n;i++){ scanf("%d",&B[i]); }
	for(int i =0 ;i<n;i++){ scanf("%d",&C[i]); }
	a = b = c = n;
	sort(A, A+a);
	sort(B, B+b);
	sort(C, C+c);
//	a = unique(A, A+a) - A;
//	b = unique(B, B+b) - B;
//	c = unique(C, C+c) - C;
//	sort(A, A+a);
//	sort(B, B+b);
//	sort(C, C+c);
	for(int i =0 ;i<b;i++){
		int *it = lower_bound(A, A + a, B[i]);
//		cout<<*it<<' '<<B[i]<<endl;
		cnt[i] = it - A;
	}
//	for(int i =0 ;i<n;i++){
//		cout<<cnt[i]<<endl;
//	}
	for(int i =1 ;i<n;i++){
		cnt[i] += cnt[i-1];
	}
	ll ans = 0;
	for(int i =0 ;i<c;i++){
		int *it = lower_bound(B ,B+b , C[i]);
//		cout<<*it<<' '<<C[i]<<' '<<(it-B)<<endl;

		ans += cnt[ it - B - 1];
	}
	printf("%lld\n", ans);
}
//C.cc by xsthunder at Sat Nov  4 20:06:40 2017


Measured memory_bytes: 2176
#include<math.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int dps(int x,int dp[],int vi[],int arr[],int k)
    {
        if(x<=0)
            return 0;
        if(vi[x]==1)
            return dp[x];
        vi[x]=1;
        int maxa=pow(10,9);
        
        for(int l=1;l<min(x+1,k+1);l++)
        {
            maxa=min((dps(x-l,dp,vi,arr,k)+abs(arr[x]-arr[x-l])),maxa);
        }
        dp[x]=maxa;
        return dp[x];
    }
int main(void)
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int dp[n];
    int vi[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        dp[i]=0;
        vi[i]=0;
    }
   
    
    cout<<dps(n-1,dp,vi,arr,k);
}   

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll n,a,b;
  cin>>n>>b>>a;
  ll p[n+1];
  for(i=0;i<n;i++) cin>>p[i];
  p[n]=n+1;
  vector<ll> dp(n+1,INF);

  dp[0]=0;
  for(i=1;i<=n;i++){
    ll tmp=0;
    for(j=i-1;j>=0;j--){
      if(p[j]>p[i]) tmp+=b;
      else {
        dp[i]=min(dp[i],dp[j]+tmp);
        tmp+=a;
      }
    }
    dp[i]=min(dp[i],tmp);
  }
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int i, j;
	int n, m;


	cin >> n;

	if (n == 25) {
		cout << "Christmas" << endl;
	}
	else if (n == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (n == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (n == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	


















	getchar();
	getchar();
	return 0;
}

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

typedef long long ll;

int n;
int v[29][200005];
int cntv[29];
int ans=0,x;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        for(int j=0;j<29;j++)
            v[j][cntv[j]++]=(x%(1<<(j+1)));
    }
    for(int i=0;i<29;i++)sort(v[i],v[i]+cntv[i]);
    for(int i=0;i<n;i++){
        cin>>x;
        for(int j=0;j<29;j++){
            int t=x%(1<<(j+1));
            int xzy=lower_bound(v[j],v[j]+cntv[j],(1<<j)-t)-v[j];
            int ctc=upper_bound(v[j],v[j]+cntv[j],(1<<(j+1))-t-1)-v[j]; 
            int hhy=lower_bound(v[j],v[j]+cntv[j],(1<<j)*3-t)-v[j]; 
            if ((ctc-xzy+n-hhy)%2) ans^=(1<<j);
        }
    }
    cout<<ans<<endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), id(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        id[x] = i;
        a[x] = y;
    }
    vector<pair<int, int>> s;
    for (int i = 0; i < n; i++) {
        int cur = a[i], sum = 1;
        while (!s.empty() && s.back().first < a[i]) {
            sum += s.back().second;
            cur = min(cur, s.back().first);
            s.pop_back();
        }
        s.emplace_back(cur, sum);
    }
    vector<int> ans(n);
    int cur = 0;
    for (auto p : s) {
        for (int i = cur; i < cur + p.second; i++) ans[id[i]] = p.second;
        cur += p.second;
    }
    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 5804
#include<bits/stdc++.h>
#define int long long
#define ll long long
template<class T> inline void read(T &x){
	x=0; register char c=getchar(); register bool f=0;
	while(!isdigit(c))f^=c=='-',c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar(); if(f)x=-x;
}
const int N=205;
int n,m,k,mod,binom[N][N],f[N][N][N][2],trans1[N][N][N],trans2[N][N][N];
inline void add(int &x,int y){x=(x+y)%mod;}
inline int fpow(int a,int b){int s=1;for(;b;b>>=1,a=(ll)a*a%mod)if(b&1)s=(ll)s*a%mod;return s;}
signed main(){
	// freopen("1.in","r",stdin);
	// freopen("1.out","w",stdout);
	read(n),read(m),read(k),read(mod);
	for(int i=0;i<=std::max(n,m);i++){
		binom[i][0]=1;
		for(int j=1;j<=i;j++)binom[i][j]=(binom[i-1][j]+binom[i-1][j-1])%mod;
	}
	for(int c=1;c<=k;c++)
		for(int d,i=0;i<=m;i++){
			d=(ll)(fpow(c,m-i)-fpow(c-1,m-i)+mod)%mod*fpow(k-c+1,i)%mod;
			for(int s=1,j=0;j<=n;j++,s=(ll)s*d%mod)trans1[c][i][j]=s;
		}
	for(int c=1;c<=k;c++)
		for(int d,i=0;i<=n;i++){
			d=(ll)(fpow(k-c+1,i)-fpow(k-c,i)+mod)%mod*fpow(c,n-i)%mod;
			for(int s=1,j=0;j<=m;j++,s=(ll)s*d%mod)trans2[c][i][j]=s;
		}
	f[0][0][0][0]=1;
	for(int c=0;c<k;c++){
		for(int i=0;i<=n;i++)
			for(int j=0;j<=m;j++){
				for(int k=0;i+k<=n;k++){
					// if((ll)f[c][i][j][0]*trans1[c+1][j][k]%mod*binom[n-i][k]%mod)printf("[%d %d %d %d] -> [%d %d %d %d] : %d %d %d\n",c,i,j,0,c  ,i+k,j,1,f[c][i][j][0],trans1[c+1][j][k],binom[n-i][k]);
					add(f[c  ][i+k][j][1],(ll)f[c][i][j][0]*trans1[c+1][j][k]%mod*binom[n-i][k]%mod);
				}
				for(int k=0;j+k<=m;k++){
					// if((ll)f[c][i][j][1]*trans2[c+1][i][k]%mod*binom[m-j][k]%mod)printf("[%d %d %d %d] -> [%d %d %d %d] : %d %d %d\n",c,i,j,0,c+1,i+k,j,1,f[c][i][j][1],trans2[c+1][i][k],binom[m-j][k]);
					add(f[c+1][i][j+k][0],(ll)f[c][i][j][1]*trans2[c+1][i][k]%mod*binom[m-j][k]%mod);
				}
			}
		// std::cerr<<f[c+1][n][m][0]<<std::endl;
	}
	// for(int c=1;c<=k;c++){
	// 	printf("=== %d ===\n",c);
	// 	for(int i=0;i<=n;i++)
	// 		for(int j=0;j<=m;j++)
	// 			printf("[%d %d]%c",f[c][i][j][0],f[c][i][j][1]," \n"[j==m]);
	// }
	printf("%d\n",f[k][n][m][0]);
}

Measured memory_bytes: 134400
#include<iostream> 

using namespace std;

int main(){
    string A, B;
    cin>> A >> B;
    bool flag_A = false;
    bool flag_B = false;
    if(A.size() == B.size()){
        for(int i = 0; i < A.size(); i++){
            if(A[i] == B[i]) continue;
            else if(A[i] > B[i]){
                flag_A = true;
                break;
            }
            else {
                flag_B = true;
                break;
            }
        }
    }
    if(A.size() > B.size() || flag_A ) cout << "GREATER" << endl;
    else if( A.size() < B.size() || flag_B ) cout << "LESS" <<endl;
    else cout << "EQUAL" <<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

ll dp[105][10];

int main(int argc, char* argv[])
{
    long h, w, k;
    scanf("%ld %ld %ld", &h, &w, &k);

    const long a[]={1,1,1,2,3,5,8,13,21};

    long i, j;
    dp[0][1]=1;
    for(i=1; i<=h; i++) {
        for(j=1; j<=w; j++) {
            if(j>1) dp[i][j]=(dp[i][j]+(dp[i-1][j-1]*a[j-1]%MOD *a[w-j+1] %MOD))%MOD;
            dp[i][j]        =(dp[i][j]+(dp[i-1][j]  *a[j]%MOD *a[w-j+1] %MOD))%MOD;
            if(j<w) dp[i][j]=(dp[i][j]+(dp[i-1][j+1]*a[j]%MOD *a[w-j] %MOD))%MOD;
        }
    }

    printf("%lld\n", dp[h][k]);

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <utility>
#include <set>
#include <tuple>

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string s = buf;
  size_t n = s.length();

  std::vector<size_t> rl;
  for (size_t i = 0; i+1 < n; ++i) {
    if (s[i] == 'R' && s[i+1] == 'L')
      rl.push_back(i);
  }

  std::vector<intmax_t> res(n);
  for (size_t i = 0; i < n; ++i) {
    if (s[i] == 'L') {
      auto it = --std::upper_bound(rl.begin(), rl.end(), i);
      size_t j = *it;
      if ((i - j) % 2 == 1) ++j;
      ++res[j];
    } else if (s[i] == 'R') {
      auto it = std::lower_bound(rl.begin(), rl.end(), i);
      size_t j = *it;
      if ((j - i) % 2 == 1) ++j;
      ++res[j];
    }
  }

  for (size_t i = 0; i < n; ++i)
    printf("%jd%c", res[i], i+1<n? ' ': '\n');
}


Measured memory_bytes: 1912