akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
   int a, b, c;
   cin >> a >> b >> c ;
   
   if (a<=b){
       if (b<=c){
           cout << a << " " << b << " " << c << endl;
       }
       else if (c<=a){
           cout << c <<" "<< a <<" "<< b << endl;
       }
       else{
           cout << a <<" "<< c <<" "<< b << endl;
       }
   }
   else if(b<=a){
       if(a<=c){
           cout << b <<" "<< a <<" "<< c << endl;
       }
       else if (b<=c){
           cout << b <<" "<< c <<" "<< a << endl;
       }
       else{
           cout << c <<" "<< b <<" "<< a << endl;
       }
   }
   return 0;
}






Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long,long long> P;

int main(){
    int n,m;cin >> n >> m;
    vector<P> drink;

    for(int i= 0; i<n; i++){
        long long a,b;cin >> a >>b;
        drink.push_back(make_pair(a,b));
    }
    sort(drink.begin(),drink.end());

    long long res = 0;

    int i = 0;
    while(m>0){
        long long a = drink[i].first;
        long long b = drink[i].second;
        if(b<=m){
            res += b*a;
            m -= b;
        }else{
            res += a*m;
            m = 0;
        }
        i++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <memory>

class Dlist {
public:
    Dlist(std::shared_ptr<Dlist> prev, std::shared_ptr<Dlist> next, unsigned int key) : prev(prev), next(next), key(key) {
        //std::cout << "  construct:" << this << ", " << key << std::endl;
    }
    ~Dlist() {
        //std::cout << "    destruct:" << this << ", " << key << std::endl;
    }
    std::shared_ptr<Dlist> prev;
    std::shared_ptr<Dlist> next;
    unsigned int key;
};

std::shared_ptr<Dlist> origin;
std::shared_ptr<Dlist> last;

std::shared_ptr<Dlist> createDlist(std::shared_ptr<Dlist> prev, std::shared_ptr<Dlist> next, unsigned int key) {
    std::shared_ptr<Dlist> ptr(new Dlist(prev, next, key));
    return ptr;
}

void purgeNode(std::shared_ptr<Dlist> ptr) {
    ptr->next = nullptr;
    ptr->prev = nullptr;
}

void insertKey(unsigned int key) {
    std::shared_ptr<Dlist> ins = createDlist(origin, origin->next, key);
    if (origin->next != nullptr) {
        origin->next->prev = ins;
    } else {
        last = ins;
    }
    origin->next = ins;
}
void deleteKey(unsigned int key, std::shared_ptr<Dlist> cur) {
    if (key == cur->key) {
        if (cur->next != nullptr) cur->next->prev = cur->prev;
        cur->prev->next = cur->next;
        if (last == cur) last = cur->prev;
        purgeNode(cur);
    } else if (cur->next != nullptr) {
        deleteKey(key, cur->next);
    }
}
void deleteFirst(void) {
    std::shared_ptr<Dlist> temp = origin->next;
    if (origin->next->next != nullptr) origin->next->next->prev = origin;
    origin->next = origin->next->next;
    purgeNode(temp);
    temp = nullptr;
}
void deleteLast(void) {
    last = last->prev;
    purgeNode(last->next);
    last->next = nullptr;
}

void showNodes(std::shared_ptr<Dlist> cur) {
    std::cout << "key:" << cur->key << ", this:" << cur << ", prev:" << cur->prev << ", next:" << cur->next << std::endl;
    if (cur->next != nullptr)
        showNodes(cur->next);
    else
        return;
}

void answer(std::shared_ptr<Dlist> cur) {
    std::cout << cur->key;
    if (cur->next != nullptr) {
        std::cout << " ";
        answer(cur->next);
    }
}

int main() {
    unsigned int num;
    std::cin >> num;
    
    origin = createDlist(nullptr, nullptr, 0);
    last = origin;
    
    std::string command;
    unsigned int key;
    for (unsigned int i=0; i<num; i++) {
        std::cin >> command;
        if ((command != "deleteFirst") && (command != "deleteLast"))
            std::cin >> key;
        if (command == "insert") {
            insertKey(key);
        } else if (command == "delete") {
            deleteKey(key, origin->next);
        } else if (command == "deleteFirst") {
            deleteFirst();
        } else if (command == "deleteLast") {
            deleteLast();
        }
    }
    //showNodes(origin);
    answer(origin->next);
    std::cout << std::endl;
    purgeNode(origin);
    purgeNode(last);
}



Measured memory_bytes: 87620
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int vis[110];
int ch(string a,string b,int n,int vis[])
{
    for(int i=0;i<a.size();i++)
    {
        if(a[i]<b[n]&&!vis[i])
        {
            vis[i]=1;
            return 1;
        }
    }
    for(int i=0;i<a.size();i++)
    {
        if(a[i]==b[n]&&!vis[i])
        {
            vis[i]=1;
            return 2;
        }
    }
    return 3;
}
void sort1(string& s)
{
    for(int i=0;i<s.size();i++)
    {
        for(int j=i;j<s.size();j++)
        {
            if(s[i]<s[j])
            {
                char a=s[j];
                s[j]=s[i];
                s[i]=a;
            }
        }
    }
}
int main()
{
    memset(vis,0,sizeof(vis));
    string a,b;
    cin>>a>>b;
    sort1(b);
    if(a.size()<=b.size())
    {
        for(int i=0;i<a.size();i++)
        {
            int z=ch(a,b,i,vis);
            if(z==1)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
            if(z==3)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        if(a.size()==b.size())
            cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        for(int i=0;i<b.size();i++)
        {
            int z=ch(a,b,i,vis);
            if(z==1)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
            if(z==3)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
        return 0;
    }
    return 0;
}


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

using namespace std;

const int inf=1<<29;

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

int p[55][55];

int dp1[55][55];
int dp2[55][55];

int main(void){
	int n,d;
	cin >> n >> d;
	rep(j,n)rep(i,d) cin >> p[i][j];

	rep(i,55)rep(j,55) dp1[i][j]=dp2[i][j]=inf;
	dp1[0][0]=0;
	dp2[0][0]=0;

	rep(i,d)rep(j,n)rep(k,n){
		int p1=dp1[i][j];
		int p2=dp2[i][j];
		p1+=p[i][k];
		if(i!=0) p2+=(j!=k);
		if(p1<dp1[i+1][k]||(p1==dp1[i+1][k]&&p2<dp2[i+1][k])){
			dp1[i+1][k]=p1;
			dp2[i+1][k]=p2;
		}
	}

	int a1=inf,a2=inf;
	rep(i,n) if(dp1[d][i]<a1||(a1==dp1[d][i]&&dp2[d][i]<a2)) a1=dp1[d][i],a2=dp2[d][i];

	vector<int> ans;

	int c1=0,c2=0,c3=-1;
	for(int a=0;a<=d;++a){
		for(int b=0;b<n;++b){
			int n1=c1+p[a][b];
			int n2=c2;
			if(a!=0) n2+=(b!=c3);
			int n3=b;
			rep(i,55)rep(j,55) dp1[i][j]=dp2[i][j]=inf;
			dp1[a+1][b]=n1;
			dp2[a+1][b]=n2;
			for(int i=a+1;i<d;++i)rep(j,n)rep(k,n){
				int p1=dp1[i][j];
				int p2=dp2[i][j];
				p1+=p[i][k];
				if(i!=0) p2+=(j!=k);
				if(p1<dp1[i+1][k]||(p1==dp1[i+1][k]&&p2<dp2[i+1][k])){
					dp1[i+1][k]=p1;
					dp2[i+1][k]=p2;
				}
			}
			int t1=inf,t2=inf;
			rep(i,n) if(dp1[d][i]<t1||(t1==dp1[d][i]&&dp2[d][i]<t2)) t1=dp1[d][i],t2=dp2[d][i];
			if(t1==a1&&t2==a2){
				ans.push_back(b+1);
				c1=n1,c2=n2,c3=n3;
				break;
			}
		}
	}
	cout << a1 << " " << a2 << endl;
	rep(i,d) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <unordered_map>

int main() {
    int q;
    std::cin >> q;

    std::unordered_map<std::string, int> M;
    for (int i = 0; i < q; i++) {
        int op;
        std::string key;
        std::cin >> op >> key;
        if (op == 0) {
            int x;
            std::cin >> x;
            M[key] = x;
        } else if (op == 1) {
            if (M.count(key) > 0) {
                std::cout << M[key] << std::endl;
            } else {
                std::cout << 0 << std::endl;
            }
        } else if (op == 2) {
            M.erase(key);
        }
    }
}



Measured memory_bytes: 26496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    set<string> st;
    string s;
    int k;
    cin >> s >> k;
    rep(i, s.size()) {
        string tmp = ""; tmp += s[i];
        st.insert(tmp);
        for (int j=i+1; j<min((int)s.size(), i+k); ++j) {
            tmp += s[j];
            st.insert(tmp);
        }
    }
    int cnt = 0;
    string ret = "";
    for (auto& ans : st) {
        ret = ans;
        if (cnt+1 == k) break;
        cnt++;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

struct UnionFind{
	vector<int> elems;
	UnionFind(int n):elems(n, -1){ }
	void unite(int a, int b){
		int ra = root(a), rb = root(b);
		if(ra == rb){ return; }
		//if(a > b){ swap(a, b); }
		elems[ra] += elems[rb];
		elems[rb] = ra;
	}
	int same(int a, int b){
		return root(a) == root(b);
	}
	int root(int a){
		return elems[a] < 0 ?  a : elems[a] = root(elems[a]);
	}
	int size(int a){
		return -elems[root(a)];
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind uf(n), uf2(n);
    map<pair<int, int>, int> mp;
    for(int i=0;i<k;i++){
        int p, q;
        cin >> p >> q;
        p--; q--;
        uf.unite(p, q);
    }
    for(int i=0;i<l;i++){
        int r, s;
        cin >> r >> s;
        r--; s--;
        uf2.unite(r, s);
    }

    for(int i=0;i<n;i++){
        mp[{uf.root(i), uf2.root(i)}]++;
    }

    for(int i=0;i<n;i++){
        cout << mp[{uf.root(i), uf2.root(i)}] << ' ';
    }cout << endl;
    return 0;
}


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

using namespace std;

typedef long long int Int;

int main(void) {
    int M,N;
    map<string,int> m;

    cin>>N;
    for(int i = 0;i < N;i++) {
        string s;
        cin>>s;
        m[s]++;
    }
    cin>>M;
    for(int i = 0;i < M;i++) {
        string t;
        cin>>t;
        m[t]--;
    }

    int a = 0;
    for(map<string,int>::iterator it = m.begin();it != m.end();it++) {
        a = max(a,it->second);
    }

    cout<<a<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=5010;
inline int read()
{
    int s=0,w=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar(); return s*w;
}
int n,A,B,val[N];
int dp[N][N],p[N];
signed main()
{
	n=read(), A=read(), B=read();
	for(ri int i=1;i<=n;i++) {int x=read(); p[x]=i; }
	for(ri int i=1;i<=n;i++) for(ri int j=0;j<=n;j++) dp[i][j]=LONG_LONG_MAX/2;
	for(ri int i=1;i<=n;i++)
	{
		for(ri int j=0;j<=n;j++)
		{
			if(p[i]==j)
			{
				dp[i][j]=min(dp[i-1][j-1],dp[i][j]);
				continue;
			}
			dp[i][j]=min(dp[i][j],dp[i-1][j]+(j<p[i]?B:A));
		}
		for(ri int j=1;j<=n;j++) dp[i][j]=min(dp[i][j],dp[i][j-1]);
	}
	printf("%lld\n",dp[n][n]);
    return 0;
}

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

const int MAX_N = 1e5+10;
const int Sqrt_N = sqrt(MAX_N)+1;

vector<int> d[Sqrt_N];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    rep(i, N) d[i / Sqrt_N].push_back(a[i]);
    rep(i, Sqrt_N) sort(all(d[i]));
    int Q;
    cin >> Q;
    rep(_, Q) {
        int l, r, D;
        cin >> l >> r >> D;
        int ans = INF;
        ++r;
        int ml = l / Sqrt_N, mr = r / Sqrt_N;
        // cout << ml << " " << mr << endl;
        for(int i = ml+1; i < mr; ++i) {
            // binary search
            auto it = lower_bound(all(d[i]), D);
            if(it != d[i].end()) ans = min(ans, abs(*it-D));
            if(it != d[i].begin()) {
                --it;
                ans = min(ans, abs(*it-D));
            }
        }
        for(int i = l; i < min(r, (ml+1)*Sqrt_N); ++i) {
            ans = min(ans, abs(a[i]-D));
        }
        for(int i = max(l, mr*Sqrt_N); i < r; ++i) {
            ans = min(ans, abs(a[i]-D));
        }
        cout << ans << endl;
        // cout << " " << l << " " << min(r, (ml+1)*Sqrt_N) << endl;
        // cout << " " << mr*Sqrt_N << " " << r << endl;
    }
    return 0;
}


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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

//r本再利用されない時、N本から再利用して売れる本数
int rec(int m,int n,int N,int r){
  if(N == 0) return 0;

  int k = N/m * n;//新たに作り出す本数
  r = N%m;//再利用されない本数
  int res = N + k;//売った本数
  
  while(1){
    k = k/m * n;//k本からk/m本再利用
    res += k;
    r += k%m;
    if(k < m){//k本で再利用できなくなったら
      k += r;
      res += rec(m,n,k,r);
    }
  }
}

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if((A < C && C < B) || (B < C && C < A)) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int ar,al,br,bl,cr,cl,dr,dl;
double l,r;
void classify()
{
	if(l>=1.1)al++;
	else if(l>=0.6)bl++;
	else if(l>=0.2)cl++;
	else dl++;
	if(r>=1.1)ar++;
	else if(r>=0.6)br++;
	else if(r>=0.2)cr++;
	else dr++;
}
int main()
{
	while(cin >> l >> r)
	{
		classify();
	}
	cout << al << ' ' << ar << endl;
	cout << bl << ' ' << br << endl;
	cout << cl << ' ' << cr << endl;
	cout << dl << ' ' << dr << endl;
	return 0;
}

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

int main() {
	string s; cin>>s;
	int n; n=s.length();
	
	for(int i=0;i<n;i++){
		if(i%2==0&&s[i]=='L'){
			cout<<"No"; return 0;
		}
		if(i%2==1&&s[i]=='R'){
			cout<<"No"; return 0;
		}
	}
	
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
for i in range(n):
    x[i], y[i] = map(int,input().split())
ans = 0.0
def dis(i, j):
    return ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5
for i in range(n):
    for j in range(i+1,n):
        ans += dis(i,j)
print(ans*2/n)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	int x;
	cin >> x;
	while(x--){
		int n,k;
		cin >> n >> k;
		int a[n];
		vector<int> dist;
		for(int i=0;i<n;i++) cin >> a[i];
		if(n <= k){
			cout << 0 << endl;
			continue;
		}
		int ret = a[n-1] - a[0];
		for(int i=1;i<n;i++){
			dist.push_back(a[i] - a[i-1]);
		}
		
		sort(dist.begin(), dist.end(), greater<int>());
		for(int i=0;i<k-1;i++){
			ret -= dist[i];
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1816
d,n=map(int,input().split())
if d==0 and n!=100:
    print(n)
elif d==0 and n==100:
    print(101)
elif d==1 and n!=100:
    print(n*100)
elif d==1 and n==100:
    print(10100)
elif d==2 and n!=100:
    print(n*10000) 
elif d==2 and n==100:
    print(1010000)

         


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

#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOD(i,b,a) for(i=a;i>=b;i--)
#define pa pair<int,int>
#define fi first
#define se second
#define task "176A"

typedef long long ll;
const ll M=1e6+1;
const ll N=1e4+1;
using namespace std;

ll n, x, t;

void input()
{
    cin >> n >> x >> t;
    ll a = n/x;
    ll ans = a* t;
    ll b = n%x;
    if(b!=0) ans+=t;
    cout<<ans;
}


int main()
{
  	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	if(fopen(task".inp","r"))
        {
 	  freopen(task".inp","r",stdin);
 	  freopen(task".out","w",stdout);
	}
input();
   return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){

	string a;
	string b="";
	
	cin>>a;
	
	for(int i=0;i<a.size();i++){
		if(a[i]=='0'&&a[i+1]=='U'){
			b=b+"nn";
			i++;
	}
		else{
		switch(a[i]){
		case '2': b=b+"k"; break;
		case '3': b=b+"s"; break;
		case '4': b=b+"t"; break;
		case '5': b=b+"n"; break;
		case '6': b=b+"h"; break;
		case '7': b=b+"m"; break;
		case '8': b=b+"y"; break;
		case '9': b=b+"r"; break;
		case '0': b=b+"w"; break;
		case 'T': b=b+"a";break;
		case 'L': b=b+"i";break;
		case 'U': b=b+"u";break;
		case 'R': b=b+"e";break;
		case 'D': b=b+"o";break;
		default: break;
		}
	}
	}
	cout<<b<<endl;
		
	
}

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

int main() {

	int r, g, b;

	cin >> r >> g >> b;

	if ((10 * g + b) % 4 == 0) {

		cout << "YES" << endl;

	}
	else {

		cout << "NO" << endl;

	}
	
	return 0;
}

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

using namespace std;

int main(){
    int N;
    int H[1000000];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    for(int j = (N-1); j > 0; j--){
        if(H[j] < H[j-1]){
            H[j-1] -= 1;
        }
    }

    bool flag = true;
    int  cnt = 0;

    for(int k = 0; k < (N-1) ; k++){
        if(H[k] > H[k+1]){
            cnt++;
        }

        if(cnt > 0){
            flag = false;
            break;
        }
    }

    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

string text1,text2;
string longestCommonSubsequence(string text1, string text2) {
	int n = (int)(text1.size());
	int m = (int)(text2.size());

	VVI dp(n+1, VI(m+1,0));
	string ans = "";
	for (int i = 0; i <= n; ++i)
	{
		for(int j = 0; j <= m; j++) {
			if(i == 0 || j == 0) continue;
			if(text1[i-1] == text2[j-1]) {
				dp[i][j] = 1 + dp[i-1][j-1];
			} else {
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int idx = n, jidx = m;
	while(idx > 0 && jidx > 0) {
		if(text1[idx-1] == text2[jidx-1]) {
			ans += text1[idx-1];
			idx--;
			jidx--;
		}
		else {
			 if(dp[idx-1][jidx] > dp[idx][jidx-1]) {
				idx--;
			} else {
				jidx--;
			}
		} 
	}
	reverse(ans.begin(),ans.end());
	return ans;
}
void solve() {
	cin >> text1;
	cin >> text2;
	cout << longestCommonSubsequence(text1,text2);
}

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

	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    
    int N = 0;
    int K = 0;
    cin>>N>>K;
    vector<ll> data(N);

    for(int i = 0; i < N; i++){
        cin>>data[i];
    }

    sort(data.begin(),data.end());

    ll sum = 0;

    if(K >= N){
        cout<<0<<endl;
    }else{
        for(int i = 0 ; i < N - K ; i++){
            sum += data[i];
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef long double ld;
typedef unsigned long long ull;
#define X first
#define Y second
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class X> using indexed_map = tree<T, X, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int M = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int modpow(int n, int k, int MOD);

/**************** code starts here ****************/

bool cmp(pair<int, int> a, pair<int, int> b) {
	return a.first+a.second > b.first+b.second;
}

void poppingfever() {
	int n; cin >> n;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end(), cmp);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) ans += a[i].first;
		else ans -= a[i].second;
	}
	cout << ans;
} 

/**************************************************/

signed main() {
	#ifdef fastfurioustransform
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0); cin.tie(0);
	//cout << fixed << setprecision(12);

	int t = 1;
	while(t--) {
		poppingfever();
	}

	return 0;
}

int modpow(int n, int k, int MOD) {
	int ans = 1; n %= MOD;
	while (k > 0) {
		if (k & 1) ans = (ans*n) % MOD;
		k >>= 1; n = (n*n) % MOD;
	}
	return ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' ';pr(b);}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' ';pr(b,c);}
template<C T,C T2,C T3,C T4>void pr(T a,T2 b,T3 c,T4 d){cout<<a<<' ';pr(b,c,d);}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  cin >> s;
  int c=0;
  rep(i,s.size()) {
    if(c==0&&s[i]=='C') c++;
    if(c==1&&s[i]=='F') c++;
  }
  if(c==2) pr("Yes");
  else pr("No");
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "debug.h"
#endif

const int N = int(2e3) + 10;

vector<bool> func(string a, string b) {
	vector<bool> ret(a.size() + 1, true);
	for (int i = 0; i < a.size(); i++) {
		for (int j = i, k = 0; j < a.size() && k < b.size(); j++, k++) {
			if (a[j] != '?' && b[k] != '?' && a[j] != b[k]) {
				ret[i] = false;
				break;
			}
		}
	}
	return ret;
}

int solve(string a, string b, string c) {
	vector<bool> ab = func(a, b);
	vector<bool> ac = func(a, c);
	vector<bool> bc = func(b, c);

	int ans = INT_MAX;
	for (int i = 0; i <= a.size(); i++) if (ab[i]) {
		for (int j = i; j <= max(a.size(), i + b.size()); j++) {
			if ((j >= ac.size() || ac[j])
					&& (j - i >= bc.size() || bc[j - i])) {
				ans = min(ans, (int)max(a.size(), max(i + b.size(), j + c.size())));
			}
		}
	}
	return ans;
}

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	string a, b, c;
	cin >> a >> b >> c;

	int ans = INT_MAX;
	ans = min(ans, solve(a, b, c));
	ans = min(ans, solve(a, c, b));
	ans = min(ans, solve(b, a, c));
	ans = min(ans, solve(b, c, a));
	ans = min(ans, solve(c, a, b));
	ans = min(ans, solve(c, b, a));
	cout << ans << 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;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n,m; cin>>n>>m;
    int a[n]; rep(i,n) a[i]=1;
    bool red[n]; rep(i,n) red[i]=(i?0:1);
    rep(q,m){
        int x,y; cin>>x>>y;
        x--; y--;
        a[y]++;
        if(red[x]) red[y]=1;
        a[x]--;
        if(a[x]==0) red[x]=0;
    }
    int ans=0;
    rep(i,n)if(red[i]) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {

	void Solve() {
		UL N, K, S; cin >> N >> K >> S;
		vector<UL> ans;
		ans.assign(N, (S % 1000000000) + 1);
		rep(i, K) ans[i] = S;
		rep(i, N) {
			if (i != 0) cout << " ";
			cout << ans[i];
		}cout << endl;
	}

	
	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int main() {
  int s, a, b;
  cin >> s >> a >> b;
  if (max(s, a) - min(s, a) < max(s, b) - min(s, b)) cout << "A" << endl;
  else cout << "B" << endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Locale;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    StringBuilder s = new StringBuilder(sc.next());
    s.setCharAt(k - 1, String.valueOf(s.charAt(k - 1)).toLowerCase(Locale.ENGLISH).charAt(0));
    pw.println(s.toString());
  }
}


Measured memory_bytes: 21844
import sys
def input():
    return sys.stdin.readline()[:-1]

n  = int(input())
A = list(map(int, input().split()))
q  = int(input())
M = list(map(int, input().split()))

def solve(dp, n,A, i,m):
    if m==0:
        return True
    
    elif i>=n:
        return False
    
    elif dp[i][m] is not None:
        return dp[i][m]
    
    elif solve(dp,n,A, i+1,m):
        dp[i][m] = True
        return True
    
    elif m-A[i]>=0:
        dp[i][m] = solve(dp,n,A, i+1,m-A[i])
        return dp[i][m]
    
    else:
        dp[i][m]= False
        return False
    

dp = [[None for i in range(max(M)+1)] for j in range(n+1)]

for m in M:    
    if solve(dp, n,A, 0, m):
        print('yes')
    else:
        print('no')


Measured memory_bytes: 5980
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int a[3][100001];
int dp[3][100001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n)
	cin>>a[0][i]>>a[1][i]>>a[2][i];
	rep(i,n)
	dp[0][i]=dp[1][i]=dp[2][i]=0;
	dp[0][0]=a[0][0];
	dp[1][0]=a[1][0];
	dp[2][0]=a[2][0];
	forn(i,1,n){
		dp[0][i]=a[0][i]+max(dp[1][i-1],dp[2][i-1]);
		dp[1][i]=a[1][i]+max(dp[0][i-1],dp[2][i-1]);
		dp[2][i]=a[2][i]+max(dp[0][i-1],dp[1][i-1]);
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
	re 0;
}


Measured memory_bytes: 2560
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(i=1;i<=n;i++)
#define   FOR(i,a,b)      for(i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
LL n,i,j,ans = 0;
LL a[1000000] ; 
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL n ; 
    cin>>n ; 
    REP(i,n) cin>>a[i] ;
    vl V,V1,V2(n+3) ;  
    sort(a+1,a+1+n) ;
    for(i=n;i>n/2;i--) V.pb(a[i]) ; 
    LL p = 0; 
    for(i=1;i<=n/2;i++) V1.pb(a[i]) ;
    LL k = 0 ;  
    for(i=3;i<=n;i+=2)  V2[i] = V[k++] ;
    V2[1] = V[V.size()-1] ; 
    k = 0 ; 
    for(i=2;i<=n;i+=2)  V2[i] = V1[k++] ;
    for(i=2;i<=n;i++) p = p + abs(V2[i]-V2[i-1]) ; 
    ans = max(p,ans) ; 
    k = 0 ;
    if(n%2)
    {  V.clear() ; V1.clear() ; 
      for(i=n;i>n/2+1;i--) V.pb(a[i]) ; 
      for(i=1;i<=n/2+1;i++) V1.pb(a[i]) ;
      k = 0 ;  
      for(i=3;i<=n;i+=2) V2[i] = V1[k++] ;
      V2[1] = V1[V1.size()-1] ; 
      k = 0 ; 
      for(i=2;i<=n;i+=2) V2[i] = V[k++] ;  
      p = 0 ; 
      for(i=2;i<=n;i++) p = p + abs(V2[i]-V2[i-1]) ; 
      ans = max(p,ans) ; 
    }
    else
    { for(i=3;i<=n;i+=2)  V2[i] = V1[k++] ;
      k = 0 ; 
      V2[1] = V1[V1.size()-1] ; 
      for(i=2;i<=n;i+=2)  V2[i] = V[k++] ;
      p = 0 ;
      for(i=2;i<=n;i++) p = p + abs(V2[i]-V2[i-1]) ; 
      ans = max(p,ans) ; 
    }
    cout<<ans ;    

}
//Check for 0,1 and other corner cases.

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

int main() {
  ll n, m, s = 0; cin >> n >> m;
  vector<int> a(m);
  rep(i, m) {
    cin >> a[i];
    s += a[i];
  }
  if (s <= n) cout << n - s << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
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;}
typedef long long ll;

vector<int> par;
vector<int> rnk;

// N個要素に対して、N個のノードを用意して初期化
void init(int N){
  par.resize(N, 0);
  rnk.resize(N, 0);
  REP(i, N){
    par[i] = i; // 最初は自分自身が親
    rnk[i] = 0;
  }
}

// 木の根（親）を求める
int find(int X){
  if(par[X] == X){
    return X;
  }else{
    return par[X] = find(par[X]);
  }
}

// XとYの属する集合を併合
void unite(int X, int Y){
  X = find(X); Y = find(Y);
  if(X == Y) return;
  if(rnk[X] < rnk[Y]){
    par[X] = Y;
  }else{
    par[Y] = X;
    if(rnk[X] == rnk[Y]) rnk[X]++;
  }
}

// XとYが同じ集合に属するか否か
bool same(int X, int Y){
  return find(X) == find(Y);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  init(N);
  REP(i, M){
    int x, y, z; cin >> x >> y >> z; x--; y--;
    unite(x, y);
  }
  REP(i, N){
    find(i);
  }
  set<int> cnt;
  REP(i, N){
    cnt.insert(par[i]);
  }
  int ans = cnt.size();
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
using namespace std;
     
int main() {
int n,f = 0,s = 0;
cin >> n;
vector<int> a(n,0);
for(int i = 0;i < n;i++){
	cin >> a[i];
	if(a[i]%4 == 0)f++;
	else if(a[i]%2 == 0)s++;
}
if(f >= n/2)cout << "Yes\n";
else if(n-(f*2) <= s)cout << "Yes\n";
else cout << "No\n";
return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    ll m = s.size();
    ll tt = t.size();
    ll ans = s.size();
    rep(i,m-tt+1) {
        string tmp = s.substr(i,tt);
        ll su = 0;
        rep(j,tt) {
            if (tmp[j] != t[j]) {
                su++;
            }
        }
        ans = min(ans, su);
    }
    cout << ans << endl;
    return 0;
}


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

 int main()
 {
 	string a;
 	int s=753;
 	cin >> a;
 	for (int i = 0; i < 753; i++){
 		int x=s+i;
 		int y=s-i;
 		if(x<1000){
 		string m=to_string(x);
 		if (a.find(m) != string::npos)
 			{
 				cout << i << endl;
 				return 0;
 		}
 		}
 		if(y>0){
 		string n=to_string(y);
 		if (a.find(n) != string::npos)
 			{
 				cout << i << endl;
 				return 0;
 		}
 		}
 	
 		
 	}
 }

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    if(s.indexOf(t)!=-1){
      System.out.println(0);
    }
    else{
      int min=Integer.MAX_VALUE;
      for(int i=0;i<=s.length()-t.length();i++){
        //System.out.println(s.substring(i,i+t.length()));
        if(min>helper(s.substring(i,i+t.length()),t)){
          min=helper(s.substring(i,i+t.length()),t);
        }
      }
      System.out.println(min);
    }
  }
  public static int helper(String s1, String s2){
    int count=0;
    for(int i=0;i<s1.length();i++){
      if(s1.charAt(i)!=s2.charAt(i)){
        count++;
      }
    }
    return count;
  }
}

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

ll n,m;
char arr[1001][1001];
ll dp[1001][1001];

ll solve(ll i, ll j){
    if(dp[i][j]==-1){
        if(i>=n || j>=m)return dp[i][j]=0;
        //cout<<i<<" "<<j<<endl;
        if(i==n-1 && j==m-1){
            //cout<<"g ";
            return dp[i][j]=1;
        }
        if(arr[i][j]=='#')return dp[i][j]=0;
        if(i+1==n && j+1<m && arr[i][j+1]=='.')return dp[i][j]=solve(i,j+1)%mod;
        if(i+1<n && j+1==m && arr[i+1][j]=='.')return dp[i][j]=solve(i+1,j)%mod;
        return dp[i][j]=((solve(i+1,j)%mod)+(solve(i,j+1)%mod)%mod);
    }
    return dp[i][j]%mod;
}

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 
    cin>>n>>m;
    for(ll x=0; x<n; x++){
        for(ll y=0; y<m; y++){
            cin>>arr[x][y];
            dp[x][y]=-1;
            //cout<<arr[x][y];
        }
        //cout<<endl;
    }
    dp[n][m]=-1;
    cout<<solve(0,0)%mod;
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 


int main(){
	ios_base::sync_with_stdio(false);
	ll n;cin>>n;
	ll a[n],b[n];
	ll sum1=0,sum2=0;
	For(i,0,n){
		cin>>a[i];
		sum1+=a[i];
	}
	For(i,0,n){
		cin>>b[i];
		sum2+=b[i];
	}
	if(sum2>sum1){
		cout<<-1<<endl;return 0;
	}
	priority_queue<ll> give;
	For(i,0,n){
		if(a[i]>b[i]) give.push(a[i]-b[i]);
	}
	ll want=0;
	ll x=0;
	For(i,0,n){
		if(a[i]<b[i]) {
			want+=(b[i]-a[i]);
			x++;
		}
	}
	ll ans=0;
	ll c=0;
	while(give.size()>0){
		if(c>=want) break;
		ll curr = give.top();
		give.pop();
		c += curr;
		ans++;
	}
	cout<<ans+x<<endl;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    ll N,M;
    cin >> N >> M;
    if(N >= 2){
        N -= 2;
    }
    if(M >= 2){
        M -= 2;
    }
    cout << N * M << endl;
}

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

using namespace std;
 
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n , i, ans = 0;
	cin >> n;
	int a[n];
	for(i = 0; i < n ; ++i)
		cin >> a[i];
	long long sum = accumulate(a, a + n, 0);
	double avg = (double)sum / n , diff = abs((double)a[0]-avg);
	for(i = 1 ; i < n ;  ++i)
	{
		if(diff > abs((double)a[i]-avg))
		{
			ans = i;
			diff = abs((double)a[i]-avg);

		}
	}
	cout << ans;

	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    ll K,A,B;
    cin >> K >> A >> B ;

    ll ans = 0;
    if(B - A > 0 && A + 1 <= K){
        ans = B;
        ans += ((K - (A + 1))/ 2)*(B - A);
        ans += (K - (A + 1))%2;
    } 

    cout << max(ans,K+1) << endl;

    return 0;
}

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

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

    int ans = 0;

    if(a < b) ans += a;
    else ans += b;
    if(c < d) ans += c;
    else ans += d;

    cout << ans << endl;
}

Measured memory_bytes: 256
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

n = int(input())
a = [0] + list(map(int, input().split()))

ans = 0
for i in range(1, n+1):
	if i < a[i]:
		if a[a[i]] == i:
			ans += 1

print(ans)
		


Measured memory_bytes: 14008
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
LD cal(LD P) {
	return (P+1) / 2;
}
void solve() {
	int N, K;
	cin >> N >> K;
	vector<LD> P(N);
	for (int i = 0; i < N; ++i) {
		cin >> P[i];
	}
	LD ans = 0;
	int cnt = 0;
	LD res = 0;
	for (int i = 0; i < N; ++i) {
		if (cnt < K) {
			res += cal(P[i]);
			++cnt;
		}
		else {
			res = res - cal(P[i - K]) + cal(P[i]);
		}
		if (cnt == K) {
			if (ans < res) {
				ans = res;
			}
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

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

using namespace std;


  




int main(void)
{
    int sx,sy,tx,ty,dx,dy;
    string path[4],ans;

    cin>>sx>>sy>>tx>>ty;

    dx=tx-sx;
    dy=ty-sy;

  
    path[0]="L";
    rep(i,dy+1){
        path[0] += "U";
    }
    rep(i,dx+1){
        path[0]+="R";
    }
    path[0]+="D";

    path[1]="R";
    rep(i,dy+1){
        path[1]+="D";
    }
    rep(i,dx+1){
        path[1]+="L";
    }
    path[1]+="U";

    path[2]="";
    rep(i,dx){
        path[2]+="R";
    }
    rep(i,dy){
        path[2]+="U";
    }

    path[3]="";
    rep(i,dx){
        path[3]+="L";
    }
    rep(i,dy){
        path[3]+="D";
    }

    cout<<path[0]<<path[1]<<path[2]<<path[3]<<endl;


 
 
	return 0;
}


Measured memory_bytes: 3636
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var one = 0; var ret = 0;
        for (int i = 0; i < n; i++)
            if (a[i] == 1) { one++; ret = Math.Max(ret, one); }
            else one = 0;
        Console.WriteLine(ret + 1);

    }
}


Measured memory_bytes: 9208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    for(int i = 0; i < H;i++){
        string C; cin >> C;
        cout << C << endl << C << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S=ns().split()
print(S[1]+S[0])

Measured memory_bytes: 5204
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = max((a * b), (c * d));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}
int main(){	
	int n;
	cin >> n;
	cout << (n+n*n+n*n*n)<<endl;
	return 0;
}




Measured memory_bytes: 3616
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N;
    cin >> N;
    vi jobs;
    rep(i, 0, N){
        int a;
        cin >> a;
        jobs.push_back(a);
    }
    
    sort(jobs.begin(),jobs.end());
    double ans=0;
    rep(i,1,N){
        if(i==1){
            ans=((double)jobs[i-1]+jobs[i])/2;
        }else{
            ans=(ans+jobs[i])/2;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256