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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  sort(ALL(a));
  sort(ALL(b));

  if(n%2==1) cout << b[n/2]-a[n/2] + 1<< endl;
  else cout << b[n/2]+b[n/2-1] - (a[n/2]+a[n/2-1]) + 1<< endl;
}

Measured memory_bytes: 6292
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

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

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int D; cin >> D;
	if (D == 25) print("Christmas");
	if (D == 24) print("Christmas Eve");
	if (D == 23) print("Christmas Eve Eve");
	if (D == 22) print("Christmas Eve Eve Eve");
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int N,i,ans=0; 
    cin>>N;
    string s1;
    cin>>s1;
    for(i=0;i<N;i++)
    {
        char t=s1[i];
        while(t==s1[i]&&i<N)
        { i++; }
        ans++; i--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	int a, b; cin >> a >> b;
	int ans = 1e9;
	for (int i = 0; i <= 10000; ++i)
		if ((int)(i * 0.08) == a && (int)(i * 0.10) == b)
			ans = min(ans, i);
	cout << (ans == 1e9 ? -1 : ans) << endl;

	return 0;
}

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

const int MAX = 105;
int a[MAX];

int main() {

    int n = 0, k = 0;
    while (cin >> n) {
        cin >> k;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int dis = 0;
        for (int i = 0; i < n; i++) {
            int t = abs(a[i] - k);
            if (a[i] < t) dis += 2 * a[i];
            else dis += 2 * t;
        }
        cout << dis << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
const int N = 1 * 100000 + 100;
const int MOD = 1000000007;
const int oo = 1e9;
ll a, b;
int main() {
	cin >> a >> b;
	if (a == b)return puts("1"), 0;
	int id = -1;
	for (int i = 60; i >= 0; i--) {
		int b1 = !!(a & 1LL << i);
		int b2 = !!(b & 1LL << i);
		if (b1 != b2) {
			id = i; break;
		} else {
			a ^= (1LL << i) * b1;
			b ^= (1LL << i) * b2;
		}
	}
	vector<pair<ll, ll>>v;
	ll t = 1LL << id;
	v.push_back({a, t - 1});
	v.pb({t + a, 2LL * t - 1});
	if (b != t) {
		for (int i = id - 1; i >= 0; i--) {
			if (b & 1LL << i) {
				v.pb({t, (1LL << (i + 1)) - 1 + t});
				break;
			}
		}
	}else{
		v.pb(mp(t,t));
	}
	sort(v.begin(),v.end());
	vector< pair<ll,ll> > clr;
	for (int i = 0; i < v.size(); ++i){
		if(clr.size() && clr.back().second >= v[i].first){
			clr.back().second = max(clr.back().second,v[i].second);
			continue;
		}
		clr.pb(v[i]);
	}
	ll sha = 0;
	for (int i = 0; i < clr.size(); ++i){
		sha += clr[i].second-clr[i].first+1;
	}
	cout << sha << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scanln(&s)

	fmt.Println(logic(s))
}

func logic(s string) string {
	a := strings.Replace(s, "/", "", -1)
	b, _ := strconv.Atoi(a)

	if b < 20190501 {
		return "Heisei"
	}
	return "TBD"
}


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

using namespace std;

using int64 = long long;

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

  map< int, int > mp;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    mp[x]++;
  }

  int64 ret = 0;
  for(auto &p : mp) {
    if(p.second < p.first) ret += p.second;
    else ret += p.second - p.first;
  }

  cout << ret << endl;

}


Measured memory_bytes: 4864
def check(s,e,t):
    global ans
    if(not s or not e or not t):
        return
    ans=min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t)))

def dfs(s,e,t,i):
    if(i==N):
        check(s,e,t)
        return
    dfs(s,e,t,i+1)
    dfs(s+[l[i]],e,t,i+1)
    dfs(s,e+[l[i]],t,i+1)
    dfs(s,e,t+[l[i]],i+1)

N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]

ans=10**18
dfs([],[],[],0)
print(ans)

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < (y); x++)
#define Repe(x,y,z) for(int x = z; x <(y); x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    vector<int> a(1<<N);
    Rep(i,1<<N){
        Scd(a[i]);
    }

    using pii = pair<int,int>;
    vector<pii> dp(1<<N,pii(a[0],0));
    Rep(i,1<<N){
        dp[i].first = a[i];
    }
    vector<int> ss(4);
    Rep(j,N){
        Rep(i,1<<N){
            if( 0 == ( i & (1 << j) ) ) {
                int ji = i | (1<<j);
                ss[0] = dp[i].first;
                ss[1] = dp[i].second;
                ss[2] = dp[ji].first;
                ss[3] = dp[ji].second;
                sort(ss.begin(),ss.end());
                dp[ji].first = ss[3];
                dp[ji].second = ss[2];
            }
        }
    }

    int ma = 0;
    Repe(i,1<<N,1){
        ma = max( ma, dp[i].first + dp[i].second);
        printf ("%d\n", ma );
    }


    return 0;
}



Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v,u,w;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>a;
    k=0;
    for(i=0; a[i]; i++)
    {
        v.PSB(a[i]-'0');
    }

    for(i=1,t=0; i<=2; i++)
    {
        if(i==1)
        {
            p=v[0];
        }
        else
        {
            p=v[0]*-1;
        }
        for(j=1; j<=2; j++)
        {
            if(j==1)
            {
                q=v[1];
            }
            else
            {
                q=v[1]*-1;
            }
            for(l=1; l<=2; l++)
            {
                if(l==1)
                {
                    o=v[2];
                }
                else
                {
                    o=v[2]*-1;
                }
                for(z=1; z<=2; z++)
                {
                    if(z==1)
                    {
                        s=v[3];
                    }
                    else
                    {
                        s=v[3]*-1;
                    }
                    k=p+q+o+s;
                    if(k==7)
                    {
                        t=1;
                        cout<<p;
                        if(q>=0)
                        {
                            cout<<"+";
                        }
                        cout<<q;
                         if(o>=0)
                        {
                            cout<<"+";
                        }
                        cout<<o;
                         if(s>=0)
                        {
                            cout<<"+";
                        }
                        cout<<s<<"=7"<<endl;


                        break;
                    }
                }
                if(t==1)
                {
                    break;
                }
            }
            if(t==1)
            {
                break;
            }

        }
        if(t==1)
        {
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;

int main(){
  string s;
  cin>>s;
  rep(i,s.size()){
    cout<<char((s[i]-'A'-3+26)%26+'A');
  }
  cout<<endl;

}

Measured memory_bytes: 1180
def game(a,b):
    if a>b:
        return 3
    elif a<b:
        return 0
    else:
        return 1

n=int(input())
sum1=0
sum2=0
for i in range(n):
    a,b=input().split()
    sum1+=game(a,b)
    sum2+=game(b,a)
print(sum1,sum2)


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int M = 123456*2;
    vector<int> p_num(M+1, 1);
    p_num[0] = 0;
    p_num[1] = 0;
    for (int i = 2; i <= M; i++) {
        if (p_num[i] == 1) {
            for(int j = i+i; j <= M; j += i) {
                p_num[j] = 0;
            }
        }
    }
    for(int i = 3; i <= M; i++) {
        p_num[i] += p_num[i-1];
    }

    while(true) {
        int n; cin >> n;
        if(n == 0) break;
        cout << p_num[2*n] - p_num[n] << endl;
    }

}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;

int W, A, B;

int main() {
  ios_base::sync_with_stdio(0);
  cin >> W >> A >> B;
  if(A > B) swap(A, B);
  cout << ((B - (A + W)) > 0 ? (B - (A + W)) : 0) << "\n";
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        int cur = 0;
        int r = i;
        while(r < k){
            r = r*2;
            cur++;
        }
        ans+=(pow(0.5, cur));
    }
    cout << fixed << setprecision(12) << double(ans/double(n));
}

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


int main(){
	int s[3];
	scanf("%d%d%d", &s[0], &s[1], &s[2]);
	printf("%s\n", (s[0] && s[1] && !s[2]) || (!s[0] && !s[1] && s[2]) ? "Open" : "Close");


	return 0;
}

Measured memory_bytes: 2592
#include <stdio.h>

int main(void)
{
        int a[3],i,max,min;
        for(i=0;i<3;i++)
                scanf("%d",&a[i]);
        max=a[0];min=a[0];
        for(i=1;i<3;i++){
                if(max<a[i])max=a[i];
                else if(min>a[i]) min=a[i];
        }
        printf("%d\n",max-min);
        return 0;
}


Measured memory_bytes: 1704
import bisect
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
color = [a[n-1]]
for i in range(n-2,-1,-1):
    x = bisect.bisect_right(color,a[i])
    if x == len(color):
        color.append(a[i])
    else:
        color[x] = a[i]
print(len(color))

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

using namespace std;


int main()
{
	int A, B;

	cin >> A >> B;

	if ((A*B) % 2 == 0) {
		printf("No");
	}
	else {
		printf("Yes");
	}


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it=x.begin();it!=x.end();it++)
#define in insert
#define pb push_back
#define pi pair<int,int>
#define si(x) x->second
#define fi(x) x->first
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
using namespace std;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=p(a,b/2); if(b%2==0)return t*t; else return a*t*t; } 
//strlen(s.c_str());  set <int, greater<int>> s; numeric_limits<double>::max()
//---------------------------------------------------------------------------------------------------------------------------------------------
 


signed main(){
	//FILEIO
	int n;
	cin>>n;
	string s;
	cin>>s;
	int c1=0;

	int c2 =0;
	f(n){
		if(s[i]=='R'){
			c1++;
		}
		else{
			c2++;
		}
	}
	if(c1>c2){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

	
	
	






	return 0;
}



Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())) + [0]*K, dtype=np.int64)
H = np.array(h)
dp = np.full(N + K, 10 ** 10, dtype=np.int64)
dp[0] = 0
for i in range(1, N):
    dp[i:i + K] = np.minimum(dp[i:i + K],
                             np.abs(H[i:i + K] - H[i - 1]) + dp[i - 1])
print(dp[N - 1]) 

Measured memory_bytes: 38952
#include<stdio.h>
#include<math.h>
int main(void){
int i,r;
double n[1000],sum=0,ave;
while(1){
scanf("%d",&r);
if(r==0){break;}
for(i=0;i<r;i++){
scanf("%lf",&n[i]);
sum+=n[i];
}
ave=sum/r;
sum=0;
for(i=0;i<r;i++){
sum+=(n[i]-ave)*(n[i]-ave);
}
sum=sum/r;
printf("%lf\n",sqrt(sum));
sum=0;
}

return 0;
}

Measured memory_bytes: 660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  
  if(N % 500 <= A && N != 0){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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

typedef pair<int,int> pos;

void rotate(vector<pos> &v){
	for(int i=0;i<v.size();i++){
		int nx = -v[i].second;
		int ny = v[i].first;
		v[i].first=nx;
		v[i].second=ny;
	}
}

void fix(vector<pos> v1,vector<pos>& v2){
	pos p1=v1[0],p2=v2[0];
	int dx = p1.first - p2.first;
	int dy = p1.second - p2.second;
	for(int i=0;i<v2.size();i++){
		v2[i].first += dx;
		v2[i].second += dy;
	}
}

void rev(vector<pos>& v){
	vector<pos> t;
	for(int i=v.size()-1;i>=0;i--){
		t.push_back(v[i]);
	}
	v=t;
}

bool check(vector<pos> v1,vector<pos> v2 ){
	if(v1.size()!=v2.size())return false;
	
	for(int k=0;k<5;k++){
		fix(v1,v2);
		bool b=true;
		for(int i=0;i<v1.size();i++){
			if(v1[i]!=v2[i]){
				b=false;
				break;
			}
		}
		if(b)return true;
		rotate(v2);
	}
	rev(v2);
	
	for(int k=0;k<5;k++){
		bool b = true;
		fix(v1,v2);
		for(int i=0;i<v1.size();i++){
			if(v1[i]!=v2[i]){
				b=false;
				break;
			}
		}
		if(b)return true;
		rotate(v2);
		
	}
	return false;
}

int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0)return 0;
		int m;
		cin >> m;
		vector<pos> v1;
		for(int i=0;i<m;i++){
			int x,y;
			cin>>x>>y;
			v1.push_back(make_pair(x,y));
		}
		for(int i=0;i<n;i++){
			int m;
			cin >> m;
			vector<pos> v2;
			for(int k=0;k<m;k++){
				int x,y;
				cin>>x>>y;
				v2.push_back(make_pair(x,y));
			}
			//cout << "121" << endl;
			if(check(v1,v2))cout << i+1 << endl;
			//cout << "12" << endl;
		}
		cout << "+++++"<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    int x=0,y=0;
    for(int i=0;i<a.length()+b.length();i++)
    {
        if(i%2==0)
            {cout<<a[x];
            x++;}
        else
            {cout<<b[y];
            y++;}
    }
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int lg;
    cin >> lg;
    cin.get();
    char s[100005];
    int cnt=1;
    cin >> s;
    for (int i=1;i<lg;i++)
    {
        if (s[i]!=s[i-1]) cnt++;
    }
    cout << cnt;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	auto c = a;
	sort(a.begin(),a.end(),greater<int>());

	rep(i,n) {
		if (a[0] == c[i]) {
			cout << a[1] << endl;
		} else {
			cout << a[0] << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 4812
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cctype>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#define mem(a,b) memset((a),(b),sizeof(a))
using namespace std;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-12;
const int MAX=1000000+10;
const int EDGE=100000+10;//边的条数
typedef long long ll;
const int mod=1000000000+7;
ll mul2(ll a,ll b)
{
	ll ans=0;
	while(b)
	{
		if(b&1)
		{
			ans=(ans+a)%mod;
		}
		a=(a<<1)%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	ll n,s,i;
	while(~scanf("%lld",&n))
	{
		s=1;
		for(i=1;i<=n;i++)
		{
			s=mul2(s,i);
		}
		printf("%lld\n",s);
	}
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
    #ifdef LOACL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t;
    scanf("%d",&t);
    while(t--) {
    	ll a,b,ans;
    	scanf("%lld %lld",&a,&b);
    	if(a>b)swap(a,b);
    	if(a==b) {
    		ans=2*(a-1);
		} else if(a+1==b) {
			ans=2*(a-1);
		} else {
			ll c=sqrt(a*b);
			if(c*c==a*b)c--;
			if(c*(c+1)>=a*b) {
				ans=2*c-2;
			} else {
				ans=2*c-1;
			}
		}
		printf("%lld\n",ans);
	}
    return 0;
}

Measured memory_bytes: 128
use std::io::Read;

fn main(){
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();
    let mut d: Vec<i32> = (0..n)
        .map(|_| { iter.next().unwrap().parse().unwrap() })
        .collect();

    d.sort();
    let m1 = (n / 2 - 1) as usize;
    let m2 = (m1 + 1) as usize;
    let ans = d[m2] - d[m1];

    println!("{}", ans);
}

Measured memory_bytes: 6396
#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb
#include<bits/stdc++.h>
#define mp				make_pair
#define rep(i,n)		for(int i = 0; i < n; i++)
#define foreach(i,c)	for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF			0x7fffffff
#define INF				0x3f3f3f3f
#define LINF			3223372036854775807
#define END(s)			{cout<<s; return 0;}
#define CON(s)			{cout<<s; continue;}
#define BRE(s)			{cout<<s; break;}
#define pb				push_back
//#define int				long long
#define All(a)			a.begin(), a.end()  //with A in CAPITAL!!!
#define sz(a)			(int)a.size()
#define F				first
#define S				second
//#define usingFiles
using namespace std;

const int rp = 666666;
const bool debug = 1;

int n, m;
vector<int> a[100100];
int tag[100100];
int l[100100], r[100100];
bool res = 1;

void solve(int now, int par){
	l[now] = -INF - 1, r[now] = INF + 1;
	if(tag[now] != -INF){
		l[now] = tag[now];
		r[now] = tag[now];
	}
	rep(i, a[now].size()){
		if(a[now][i] == par) continue;
		solve(a[now][i], now);
		if(l[a[now][i]] < -INF/2) continue;
		if(l[now] < -INF/2){
			l[now] = l[a[now][i]] - 1;
			r[now] = r[a[now][i]] + 1;
		} else {
			l[now] = max(l[now], l[a[now][i]] - 1);
			r[now] = min(r[now], r[a[now][i]] + 1);
			if(abs(l[now]) % 2 == abs(l[a[now][i]]) % 2) res = false;
		}
	}
	if(l[now] > r[now]) res = false;
}

void make(int now, int par){
	if(now == 0 && tag[now] == -INF) tag[now] = l[now];
	rep(i, a[now].size()){
		if(a[now][i] != par){
			if(tag[a[now][i]] == -INF){
				if(tag[now] - 1 <= r[a[now][i]] && tag[now] - 1 >= l[a[now][i]]) tag[a[now][i]] = tag[now] - 1;
				else tag[a[now][i]] = tag[now] + 1;
			}
			make(a[now][i], now);
		}
	}
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	rep(i, n - 1){
		int v, g;
		cin >> v >> g;
		v--, g--;
		a[v].pb(g);
		a[g].pb(v);
	}
	cin >> m;
	rep(i, n) tag[i] = -INF;
	rep(i, m){
		int v, g;
		cin >> v >> g;
		v--;
		tag[v] = g;
	}
	solve(0, -1);
	if(!res) cout << "No\n";
	else{
		make(0, -1);
		cout << "Yes\n";
		rep(i, n){
			cout << tag[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 15360
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,j,sum=0,a,b,q;
    cin>>n;
    ll arr[n];
    map<ll,ll> m1;
    for(i=0;i<n;i++){
        cin>>arr[i];
        m1[arr[i]]+=1;
        sum+=arr[i];
    }
    cin>>q;
    while(q--){
        ll a,b,ans=sum;
        cin>>a>>b;
        ans-=(m1[a]*a);
        m1[b]+=m1[a];
        ans+=(m1[a]*b);
        m1[a]=0;
        cout<<ans<<endl;
        sum=ans;
    }
    return 0;
}


Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

void solve() {
    ll a, b, n;
    cin>>n;
    if(n==1) {
    	cout<<"a\n";
    	return;
    }
    
    string s;
    while(n) {
        ll r=n%26;
        char ch;
        
        if(r==0) {
        	ch='z';
        	n--;
        }
        else {
        	ch='a'+(r-1);
        }
        s.pb(ch);
        n/=26;
    }
    reverse(s.begin(), s.end());
    cout<<s<<endl;
}
int main() {
    ios_base::sync_with_stdio(0);
    int T=1 ,cas=0;
    while(T--) {
    	// for(int n=1;n<=10000;++n)
        solve();
    }
    return 0;
}

// ll, reset, 1, bottom

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

int main() {
	string s;
	getline(cin, s);
	
	int i = 0;
	while (i < s.length()) {
		if ('a' <= s[i] && s[i] <= 'z')
			s[i] = s[i] - 'a' + 'A';
		i++;
	}
	cout << s << endl;

	return 0;
}

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

int main() {
    
    int k;
    int a,b;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    
    int x,y;
    x = a/k;
    y = b/k;
    
    if (k * x == a || k * y == b) {
        cout << "OK";
    } else if ((k * (x+1) >= a && k * (x+1) <= b) || (k * (y+1) <= b && k * (y+1) >= a)) {
        cout << "OK";
    } else {
        cout << "NG";
    }
    
    

    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=2e3+10;
const ll mod=1e9+7;
int s[mn],t[mn];
ll dp[mn][mn];
int main(){
    int n,m,i,j;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)scanf("%d",s+i),dp[i][0]=1;
    for(i=1;i<=m;i++)scanf("%d",t+i),dp[0][i]=1;
    dp[0][0]=1;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1];
            if(s[i]==t[j])dp[i][j]+=dp[i-1][j-1];
            dp[i][j]%=mod;
        }
    }
    if(dp[n][m]<0)dp[n][m]+=mod;
    printf("%lld",dp[n][m]);
}


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

int n, k, a[52], p[52], d[52];

vector<int> ans;

bool comp(int x, int y){
    return a[x] > a[y];
}

int main(){
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]), p[i] = i;
    
    sort(p, p + n, comp);
    for(int i = 0; i < n - 1; i++){
        if(!a[p[i]]) return puts("-1"), 0;
        ans.push_back(p[i]), a[p[i]]--;
    }
    int bef = p[n - 1];
    while(k--){
        int min_a = 1e9, min_pi = -1;
        for(int i = 0; i < n; i++){
            if(p[i] == bef) continue;
            if(a[p[i]] < min_a){
                min_a = a[p[i]];
                min_pi = p[i];
            }
        }
        if(!a[bef]) return puts("-1"), 0;
        ans.push_back(bef), a[bef]--;
        for(int i = 0; i < n; i++){
            if(p[i] == bef || p[i] == min_pi) continue;
            if(!a[p[i]]) return puts("-1"), 0;
            ans.push_back(p[i]), a[p[i]]--;
        }
        bef = min_pi;
    }

    if(!a[bef]) return puts("-1"), 0;
    ans.push_back(bef), a[bef]--;
    printf("%d\n", ans.size());
    for(int x: ans) printf("%d ", x + 1);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean[] x = new boolean[3];
        int A = sc.nextInt();
        int B = sc.nextInt();
        x[A-1] = true;
        x[B-1] = true;
        int ans = 0;
        for (int i = 0; i < 3; i++) {
            if (!x[i]) {
                ans = i+1;
                break;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22356
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if a[i]+a[j] > a[k] and a[j]+a[k] > a[i] and a[k]+a[i] > a[j] and a[i] != a[j] and a[j] != a[k] and a[k] != a[i]:
                    cnt += 1
    print(cnt)


main()

Measured memory_bytes: 68076
fn main(){
    let n=readln();
    for _i in 0..n{
        let mut v:Vec<i64> = readln();
        v.sort();
        if v[0]*v[0] + v[1]*v[1]==v[2]*v[2] {
            println!("YES");
        }
        else{
            println!("NO");
        }
    }

}
    

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
 
pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);



Measured memory_bytes: 5028
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>pat[100000];
bool flag[100000];
int dfs(int node)
{
	flag[node] = true;
	int d[20];
	fill(d, d + 20, 0);
	for (int i = 0; i < pat[node].size(); i++)
	{
		if (!flag[pat[node][i]])
		{
			int t = dfs(pat[node][i]);
			for (int j = 0; j < 20; j++)if ((t&(1 << j)) != 0)d[j]++;
		}
	}
	int lb = 0;
	for (int i = 0; i < 20; i++)if (d[i] >= 2)lb = i + 1;
	int r = 0;
	for (int i = lb; i < 20; i++)
	{
		if (d[i] == 0)
		{
			r = i;
			break;
		}
	}
	int ret = (1 << r);
	for (int i = r + 1; i < 20; i++)if (d[i]>0)ret += 1 << i;
	return ret;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num - 1; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		pat[za].push_back(zb);
		pat[zb].push_back(za);
	}
	fill(flag, flag + num, false);
	int r = dfs(0);
	int maxi = 0;
	for (int i = 0; i < 20; i++)if ((r&(1 << i)) != 0)maxi = i;
	printf("%d\n", maxi);
}

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

int main() {
  	int n;
  	cin >> n;
  
  	for (int i = 1; i <= 9; i++)
    {
      	if (n % i == 0 && n / i <= 9 && n / i >= 1) {
        	cout << "Yes" << endl;
      		return 0;
        }
    }
  
  	cout << "No" << endl;
  
	return 0;
}

Measured memory_bytes: 256
/**
 *   author  : The San Cao (caothesan@gmail.com)
 *   created : 2020.02.08 11:01:47 +07
 */

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(NULL);
  int n, k, s; cin >> n >> k >> s;
  for (int i = 0; i < n; ++i) cout << s + (i >= k) * (s == 1 ? 1 : -1) << " ";
  return 0;
}


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

using namespace std;

constexpr int MAXN = 105;

char s[MAXN];
string dp[MAXN][MAXN];

bool cMin(string &a, string &b){
  if(a.size() > b.size() || (a.size() == b.size() && a > b) || a.empty()){
    return true;
  }
  return false;
}

string getAns(int l, int r){
  if(l > r){
    return "";
  }
  if(l == r){
    return dp[l][r] = "()";
  }
  if(dp[l][r] != ""){
    return dp[l][r];
  }
  string tempAns;
  for(int i = l; i < r; ++i){
    string t = getAns(l, i) + getAns(i + 1, r);
    if(cMin(tempAns, t)){
      tempAns = t;
    }    
  }
  if(s[l] == '('){
    string t = "(" + getAns(l + 1, r) + ")";
    if(cMin(tempAns, t)){
      tempAns = t;
    }
  }
  if(s[l] == '(' && s[r] == ')'){
    string t = "(" + getAns(l + 1, r - 1) + ")";
    if(cMin(tempAns, t)){
      tempAns = t;
    }
  }
  if(s[r] == ')'){
    string t = "(" + getAns(l, r - 1) + ")";
    if(cMin(tempAns, t)){
      tempAns = t;
    }
  }
  return dp[l][r] = tempAns;
}

int main(){
 int len;
 scanf("%d%s", &len, s);
 //cout << len << ' ' << endl;
 //int len = strlen(s) - 1;
 cout << getAns(0, len - 1) << endl;
 return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1ll<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("NO"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int bs(ll x) {
  return pcnt(x)&1;
}

int n;
ll n1;
vl ans;

void dfs(ll s, ll t, ll m) {
  if (pcnt(m) == n-1) {
    ans.pb(s);
    ans.pb(t);
    return;
  }
  ll x = s^t;
  ll b = x&-x;
  m |= b;
  ll mi = n1^m;
  ll d = mi&-mi;
  mi ^= d;
  ll e = mi&-mi;

  ll w = s^d;
  if ((w^b) == t) w = s^e;
  dfs(s,w,m);
  dfs(w^b,t,m);
}

int main() {
  scanf("%d",&n);
  n1 = bn(n);
  ll a,b;
  cin>>a>>b;
  if (bs(a) == bs(b)) dame;
  dfs(a,b,0);
  puts("YES");
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
//#define MOD 998244353
#define EPS (1 >> 30)
//#define INF (1 << 30)
#define INF (1LL << 60)
#define ff first
#define se second
//#define int long long
const int dx[]={0,-1,0,1};
const int dy[]={1,0,-1,0};

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll ans=0;
    ll cnt=0;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            ans++;
        }
        else{
            cnt++;
        }
    }
    rep(i,k){
        if(cnt>=2){
            ans+=2;
            cnt-=2;
        }
        else if(cnt==1){
            ans+=1;
            cnt-=1;
        }
        else{break;}
    }
    cout<<ans<<endl;
    
}

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

#define FOR(i,S,E) for(int i=S; i<E; i++)
#define ri(x) scanf("%d", &x)

int main() {
    int N;
    ri(N);
    int i;
    for(i=1; i*i <= N; i++) {
        continue;
    }
    printf("%d\n", (i-1)*(i-1));
}


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

typedef long long ll;

template<class T> inline bool chmax(T& a, T b){
  if (a < b) { a = b; return true; } return false;
}
ll INF = 1LL<<60;

ll dp[110][100100] = {0};

int
main(void)
{

  int n; cin >> n;
  ll w; cin >> w;
  ll value[110], weight[110];
  for(ll i = 0; i < n; i++){
    cin >> weight[i] >> value[i];
  }

  ll max_v = 0;
  for(ll i = 0; i < n; i++){
    max_v += value[i];
  }

  for(int i = 0; i < n; i++)for(ll j= 0; j <= max_v; j++)dp[i][j] = INF;
  dp[0][0] = 0;

  for(ll i = 0; i < n; i++){
    for(ll j = 0; j <= max_v; j++){
      if(j - value[i] >= 0) {
        dp[i + 1][j] = min(dp[i][j], dp[i][j - value[i]] + weight[i]);
      } else {
        dp[i + 1][j] = min(dp[i][j], dp[i][j]);
      }
    }
  }

  ll max = 0;
  for(ll i = 0; i <= max_v; i++){
    if(dp[n][i] <= w){
      max = i;
    } 
  }

  cout << max << endl;
  
  
  return 0;
}

Measured memory_bytes: 80128
def make_divisors(n,m):
    divisors = []
    for i in range(1,min(int(m**(1/2))+1,int(m//n)+1)):
      if m % i == 0:
          divisors.append(i)
          if i != m // i and m//i<=m//n:
              divisors.append(m//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> sum(N, 0);
    for (int i = 0; i < N; i++) { cin >> A[i], sum[i] = (i == 0 ? 0 : sum[i - 1]) + A[i]; }

    ll ans = 1LL << 60;
    for (int i = 1; i < N - 2; i++) {
        const ll fsum = sum[i];
        const ll fobj = (fsum + 1) / 2;
        auto it = lower_bound(sum.begin(), sum.begin() + i + 1, fobj);
        ll A, B, C, D;
        if (*it == fobj or it == sum.begin()) {
            A = fsum - *it, B = *it;
        } else {
            A = fsum - *it, B = *it;
            it--;
            const ll A_ = *it, B_ = fsum - *it;
            if (abs(B_ - A_) <= abs(B - A)) { B = B_, A = A_; }
        }
        const ll lsum = sum[N - 1];
        const ll lobj = (sum[N - 1] + fsum + 1) / 2;
        it = lower_bound(sum.begin() + i + 1, sum.end(), lobj);
        if (*it == lobj or it == sum.begin() + i + 1) {
            C = lsum - *it, D = *it - fsum;
        } else {
            C = *it - fsum, D = lsum - *it;
            it--;
            const ll C_ = *it - fsum, D_ = lsum - *it;
            if (abs(D_ - C_) <= abs(D - C)) { D = D_, C = C_; }
        }
        ans = min(max({A, B, C, D}) - min({A, B, C, D}), ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
S = input()

def ok(s):
  n = len(s) 
  if n % 2 == 1:
    return False
  else:
	#print(s[0:n//2] + " " + s[n//2:])
    return s[0:n//2] == s[n//2:]

for i in range(1, len(S)+1):
  if ok(S[0:len(S)-i]):
    print(len(S)-i)
    break

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    long long H,W,i,j;
    cin>>H>>W;
    char a[H+W][H+W];long long p[H+W][H+W];
    long long mod=1e9+7;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cin>>a[i][j];
        }
    }
    p[0][0]=1;
    for(i=1;i<H+W;i++){
        for(j=0;j<i+1;j++){
            if(a[j][i-j]=='#'){
                p[j][i-j]=0;
            }else{
                if(j==0){
                    p[j][i-j]=p[j][i-j-1];
                }else if(j==i){
                    p[j][i-j]=p[j-1][i-j];
                }else{
                    p[j][i-j]=(p[j][i-j-1]+p[j-1][i-j])%mod;
                }
            }
        }
    }
    cout<<p[H-1][W-1]<<endl;
}

Measured memory_bytes: 35200
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int ans = 0;
        for(int i = 0; i < n - 1; i++) {
            int minj = i;
            for(int j = i + 1; j < n; j++) {
                if(a[j] < a[minj]) minj = j;
            }

            if(i != minj){
                int tmp = a[i];
                a[i] = a[minj];
                a[minj] = tmp;
                ans++;
            }
        }

        printArray(a, n);
        System.out.println(ans);
    }

    private static void printArray(int[] a, int n) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++) {
            if(i != 0) sb.append(" ");
            sb.append(a[i]);
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 26304
R, G, B, n = map(int, input().split())
cnt = 0
for r in range((n//R)+1):
  for g in range((n//G)+1):
    
      if (n - (r*R + g*G)) % B == 0 and n - (r*R + g*G) >= 0:
        
        cnt +=1
print(cnt)

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { return ((a % mod) * (b % mod)) % mod;    }
ll add(ll a, ll b)  { return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;



ll solve(ll x)
{
ll n = 2e5;

vector<bool> is_prime(n+1, 1);
is_prime[0] = is_prime[1] = false;
for (ll i = 2; i <= n; i++) {
    if (is_prime[i] && (long long)i * i <= n) {
        for (ll j = i * i; j <= n; j += i)
            is_prime[j] = false;
    }
}

vector<ll>v;

forn(i,1,n)
{
	if(is_prime[i])
	{
		v.pb(i);
	}
}

ll ans = *lb(all(v),x);
return ans;

}
int main()
{
	speedup_IO;
	ll n;
	cin>>n;

	ll ans = solve(n);
	cout<<ans;
	return 0;
}

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

#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<"\n"
#define prints(a) for(auto i: a) cout<<i<<" "; cout<<"\n"
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e]

int main()
{
	fastio;
	int x, n, v;
	cin>>x>>n;

	map<int, int> mp;
	while(n--){
		cin>>v;
		mp[v] = 1;
	}

	int cnt = 0;
	while(1){
		int v1 = x-cnt, v2 = x+cnt;
		if(mp[v1]==0){
			cout<<v1<<"\n";
			break;
		}
		else if(mp[v2]==0){
			cout<<v2<<"\n";
			break;
		}

		cnt++;
	}	

	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char x, y; cin >> x >> y;
    if(x > y) cout << '>';
    if(x == y) cout << '=';
    if(x < y) cout << '<';
    cout << endl;
    return 0;
}



Measured memory_bytes: 256