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

using namespace std;

typedef long long ll;

const int MAX_N = 404;
const ll MOD = 998244353;

ll sq(ll x) { return x * x % MOD; }
ll qpow(ll a, ll b) { return b ? sq(qpow(a, b / 2)) * (b & 1 ? a : 1) % MOD : 1; }
ll inv(ll x) { return qpow(x, MOD - 2); }

int N;
ll A[MAX_N], B[MAX_N], P[MAX_N][MAX_N], sumA, sumB;
ll fac[MAX_N], ifac[MAX_N], invs[MAX_N];
ll F[MAX_N][MAX_N][MAX_N][2];

ll comb(ll n, ll m) { return fac[n] * ifac[n - m] % MOD * ifac[m] % MOD; }

void init() {
    fac[0] = 1;
    for (int i = 1; i < MAX_N; i++) fac[i] = fac[i - 1] * i % MOD;
    ifac[MAX_N - 1] = inv(fac[MAX_N - 1]);
    for (int i = MAX_N - 1; i; i--) ifac[i - 1] = ifac[i] * i % MOD;
    for (int i = 1; i < MAX_N; i++) invs[i] = ifac[i] * fac[i - 1] % MOD;

    scanf("%d", &N);
    ll S = 0;
    for (int i = 1; i <= N; i++) scanf("%lld%lld", &A[i], &B[i]), S += A[i];
    for (int i = 1; i <= N; i++) {
        P[i][0] = 1;
        for (int j = 1; j <= B[i]; j++) P[i][j] = P[i][j - 1] * A[i] % MOD;
    }
}

void solve() {
    F[0][0][0][0] = MOD - 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= sumB; j++) {
            for (int k = 0; k <= sumA; k++) {
                for (int l = 0; l <= 1; l++) {
                    (F[i][j][k][l] += F[i - 1][j][k][l]) %= MOD;
                    for (int m = 0; m < B[i]; m++) {
                        (F[i][j + m][k + A[i]][l] += F[i - 1][j][k][l] * comb(j + m, m) % MOD * P[i][m] % MOD * (MOD - 1)) %= MOD;
                    }
                }
                (F[i][j + B[i] - 1][k + A[i]][1] += F[i - 1][j][k][0] * comb(j + B[i] - 1, B[i] - 1) % MOD * P[i][B[i]] % MOD * (MOD - 1)) %= MOD;
            }
        }
        sumA += A[i];
        sumB += B[i];
    }
    ll ans = 0;
    for (int i = 0; i <= sumB; i++) {
        for (int j = 1; j <= sumA; j++) {
            (ans += F[N][i][j][1] * qpow(invs[j], i + 1) % MOD * (i + 1) % MOD * (1 + (sumA - j) * invs[j] % MOD)) %= MOD;
        }
    }
    printf("%lld\n", ans);
}

int main() {
    init();
    solve();
}


Measured memory_bytes: 996864
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Tue Jan 28 20:59:06 2020
//
package main

import "fmt"

var N int
var P []int

func main() {
	fmt.Scan(&N)
	P = make([]int, N)
	for i := range P {
		fmt.Scan(&P[i])
	}

	min := N + 100
	ans := 0
	for i := range P {
		if min > P[i] {
			ans++
			min = P[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4992
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

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

	int n,m;
	cin>>n>>m;
	string a="",b="";
	for(int i=0;i<n;i++)
	{
		a+=m+'0';
	}	
	for(int i=0;i<m;i++)
	{
		b+=n+'0';
	}	
	cout<<min(a,b);
}
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll ans(ll a){
  if(a%4==3) return 0;
  else if(a%4==1) return 1;
  else if(a%4==0) return a;
  else return 1^a;
}

int main(){
  ll n, m, an; cin >> n >> m;
  if(n==0) an = ans(m);
  else an = ans(n-1)^ans(m);
  cout << an << endl;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}


int main()
{
  ios::sync_with_stdio(false);
  double l;
  cin >> l;
  double ans = l*l*l/27.0;
  cout << fixed<< setprecision(6) << ans << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

ll mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(n);
  for (auto &v : vec)
    cin >> v;

  ll suma = 0;
  for (auto &v : vec)
    suma = (suma + v) % mod;

  ll ans = 0;
  for (auto &v : vec) {
    suma = (suma - v) % mod;
    if (suma < 0)
      suma += mod;

    ll tmp = v * suma % mod;
    ans = (ans + tmp) % mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4832
A, B, C, D, E, F = map(int, input().split(' '))
water = []
for i in range(31):
    if A*i >= F:
        break
    for j in range(16):
        if 100 * (A*i + B*j) < F:
            water.append(100*(A*i+B*j))
        else:
            break
water = sorted(list(set(water)))

sugar = []
for i in range(max(water)//100*E//C + 1):
    for j in range(max(water)//100*E//D + 1):
        temp_sugar = C*i + D*j
        if temp_sugar + water[1] <= F:
            sugar.append(temp_sugar)
        else:
            break
sugar = sorted(list(set(sugar)))

max_conc = 0
ans_W = 100*A
ans_sugar = 0
for W in water:
    if W == 0:
        continue
    for S in sugar:
        if S+W <= F and S <= W*E//100:
            if max_conc < S/(W+S):
                max_conc = S/(S+W)
                ans_W = W
                ans_sugar = S
        else:
            break
print('{0} {1}'.format(ans_W+ans_sugar, ans_sugar))


Measured memory_bytes: 10672
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < w + 2; i++){
        cout << '#'; 
    }
    cout << endl;
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        cout << '#' << s << '#' << endl;
    }
    for (int i = 0; i < w + 2; i++){
        cout << '#';
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAXN 100

int IsPalindrome(char *s)
{
    int i=0, j=strlen(s)-1;

    while( i<j )
    {
        if( s[i]!=s[j] )
            break;
        i++;
        j--;
    }
    if( i<j )
        return 0;
    else
        return 1;
}
int main(void)
{
    int n;
    char s[MAXN], temp[MAXN/2], flag=0;

    scanf("%s", s);

    if( IsPalindrome(s) )
    {
        n = strlen(s);
        strcpy(temp, s+(n+3)/2-1);
        if( IsPalindrome(temp) )
            flag = 1;
    }
    if( flag )
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
static constexpr int N_max = 200'000;

struct Task {
    int a, b;
};

int main() {
    int n;
    cin >> n;
    auto tasks = vector<Task>(n);
    for (auto &task : tasks)
        cin >> task.a >> task.b;
    sort(tasks.begin(), tasks.end(), [](auto &x, auto &y) { return (x.b < y.b); });

    auto t = 0;
    for (int i = 0; i < n; i++) {
        if (t + tasks[i].a > tasks[i].b)
            goto fail;
        t += tasks[i].a;
    }

    cout << "Yes";
    return 0;
fail:
    cout << "No";
    return 0;
}


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

using namespace std;

int main(void){
  int n,m;

  while(cin >> n >> m,n|m){
    vector<int>a(n),b(m);
    int suma=0,sumb=0;
    for(int i=0;i<n;i++)cin >> a[i],suma+=a[i];
    for(int i=0;i<m;i++)cin >> b[i],sumb+=b[i];

    int ansa=-1,ansb=-1,ans=10000000;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if((b[j]-a[i])*2==sumb-suma && abs(a[i]+b[j]) < ans){
	  ans = abs(a[i]+b[j]);
	  ansa=a[i],ansb=b[j];
	}
      }
    }
    if(ansa<0)cout << -1 << endl;
    else cout << ansa << " " << ansb << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int A,B;
	cin>>A>>B;
	if((A*B)%2) print("Odd");
	else print("Even");
	return 0;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<ll,ll,int> ti;
typedef vector<ti> vti;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 303;

ll dist[T][T];
ll tmp[T];
vii g[T];
bool vis[T];
bool ok[T];
ll n,m,tank;

void dij(int s) {
    vis[s] = 1;
    for(int i = 0; i <= n; i++) {
        dist[s][i] = 1e18;
        tmp[i] = -1e18;
        ok[i] = 0;
    }

    dist[s][s] = 0;
    tmp[s] = tank;
    priority_queue<ti,vti,greater<ti>> pq;
    pq.emplace(0,-tank,s);

    while(!pq.empty()) {
        ti at = pq.top();
        pq.pop();

        ll t,r,u;
        tie(t,r,u) = at;

        if(ok[u]) continue;
        ok[u] = 1;

        for(ii v : g[u]) {
            ll nr = r+v.se;
            ll nt = t;
            if(nr > 0) {
                if(tank < v.se) continue;
                nr = -tank + v.se;
                nt++;
            }
            if(dist[s][v.fi] > nt or (dist[s][v.fi] == nt and tmp[v.fi] < abs(nr))) {
                dist[s][v.fi] = nt;
                pq.emplace(nt,nr,v.fi);
                tmp[v.fi] = abs(nr);
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m >> tank;

    while(m--) {
        int a,b,c; cin >> a >> b >> c;
        g[a].eb(b,c);
        g[b].eb(a,c);
    }

    int q; cin >> q;
    while(q--) {
        int s,t; cin >> s >> t;
        if(!vis[s] and !vis[t]) {
            if(!vis[s]) dij(s);
            else if(!vis[t]) dij(t);
        }
        if(vis[s]) cout << (dist[s][t] == 1e18? -1 : dist[s][t]) << endl;
        else if(vis[t]) cout << (dist[t][s] == 1e18? -1 : dist[t][s]) << endl;
    }

    return 0;
}



Measured memory_bytes: 3912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B =sc.next();
		String C =sc.next();
		if (A.charAt(A.length()-1)==B.charAt(0)&&B.charAt(B.length()-1)==C.charAt(0)) {
			System.out.println("YES");
			return ;
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 22740
program ccc
implicit none

integer :: l, i, res1, res2
character(10**5+1) :: s, s1, s2

read*, s
s=trim(s)
l=len_trim(s)

res1=0
res2=0
do i=1,l,2
s1(i:i)='0'
s1(i+1:i+1)='1'
s2(i:i)='1'
s2(i+1:i+1)='0'
end do

s1=trim(s1(1:l))
s2=trim(s2(1:l))

do i=1,l
if(s(i:i)==s1(i:i)) res1=res1+1
if(s(i:i)==s2(i:i)) res2=res2+1
end do

write(*,'(i0)') min(res1,res2)

end program

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

namespace std {

template<class Fun>
class y_combinator_result {
	Fun fun_;
public:
	template<class T>
	explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

	template<class ...Args>
	decltype(auto) operator()(Args &&...args) {
		return fun_(std::ref(*this), std::forward<Args>(args)...);
	}
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
	return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

} // namespace std

const char* IMPOSSIBLE = "Impossible";
const char* POSSIBLE = "Possible";

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<bool> A(1<<N);
	for (int m = 0; m < (1<<N); m++) {
		char c; cin >> c;
		assert(c == '0' || c == '1');
		A[(1<<N)-1-m] = (c == '1');
	}

	for (int m = 0; m < (1<<N); m++) {
		for (int i = 0; i < N; i++) {
			// m2 is a superset
			if (A[m] > A[m | (1<<i)]) {
				cout << IMPOSSIBLE << '\n';
				exit(0);
			}
		}
	}
	cout << POSSIBLE << '\n';
	vector<int> pattern = std::y_combinator([&](auto self, int n, int l, int r) -> vector<int> {
		assert(A[r-1]);
		if (n == 0) {
			return {};
		}
		vector<int> a = self(n-1, l + (1<<(n-1)), r);
		vector<int> res = a;
		res.push_back(n);
		if (A[l+(1<<(n-1))-1]) {
			vector<int> b = self(n-1, l, l + (1<<(n-1)));
			for (int i : b) res.push_back(i);
			res.push_back(-n);
			reverse(b.begin(), b.end());
			for (int i : b) res.push_back(-i);
		}
		return res;
	})(N, 0, (1<<N));

	vector<bool> patA(1<<N);
	for (int m = 0; m < (1<<N); m++) {
		stack<int> st;
		for (int i : pattern) {
			if (m & (1<<(abs(i)-1))) {
				continue;
			}
			if (!st.empty() && st.top() == -i) {
				st.pop();
			} else {
				st.push(i);
			}
		}
		patA[m] = st.empty();
	}

	for (int m = 0; m < (1<<N); m++) {
		assert(patA[m] == A[m]);
	}

	vector<pair<int, int>> pos;
	pos.emplace_back(0,1);
	auto goToPt = [&](int x) {
		assert(pos.back().second == 1);
		if (pos.back() == pair<int, int>(x,1)) {
			return;
		}
		pos.emplace_back(pos.back().first, 0);
		while (pos.back().first < x) {
			pos.emplace_back(pos.back().first+1, 0);
		}
		while (pos.back().first > x) {
			pos.emplace_back(pos.back().first-1, 0);
		}
		pos.emplace_back(x,1);
	};
	for (auto i : pattern) {
		assert(i != 0);
		if (i > 0) {
			goToPt(i-1);
			pos.emplace_back(i, 1);
		} else {
			goToPt(-i);
			pos.emplace_back(-i-1, 1);
		}
	}

	goToPt(0);

	if (int(pos.size()) - 1 > 250000) {
		while (true);
	}
	cout << pos.size()-1 << '\n';
	for (auto it : pos) {
		cout << it.first << ' ' << it.second << '\n';
	}

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct node{
  node *p,*l,*r;
  int val;
};

node* root=NULL;

void insert(node* z){
  node* x=root;
  node* y=NULL;
  while(x!=NULL){
    y=x;
    if(z->val<x->val)x=x->l;
    else x=x->r;
  }
  z->p=y;

  if(y==NULL)root=z;
  else if(z->val<y->val)y->l=z;
  else y->r=z;
}

void dfs1(node* v){
  if(v->l!=NULL)dfs1(v->l);
  cout<<" "<<v->val;
  if(v->r!=NULL)dfs1(v->r);
}

void dfs2(node* v){
  cout<<" "<<v->val;
  if(v->l!=NULL)dfs2(v->l);
  if(v->r!=NULL)dfs2(v->r);
}

int main(){
  int q;
  cin>>q;
  while(q--){
    string s;
    cin>>s;
    if(s=="insert"){
      int v;
      cin>>v;
      node* z=(node *)malloc(sizeof(node));
      z->p=NULL; z->l=NULL; z->r=NULL;
      z->val=v;
      insert(z);
    }else{
      dfs1(root);
      cout<<endl;
      dfs2(root);
      cout<<endl;
    }
  }
	return 0;
}



Measured memory_bytes: 26596
#include <iostream>
#include <bits/stdc++.h>
#include <vector>

using namespace std;

#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)

using ll = int;

int main()
{
      // 追加２, 以降 cin の入力元が 'input.txt' になる
//   std::ifstream in("resource/input.txt");
//    std::cin.rdbuf(in.rdbuf());

    ll N,streak,res,iMax,iMin;

    cin >> N;

    vector <ll> h(N);
    vector <ll> c(N,0);

    streak = 0;
    res = 0;
    iMax = 0;
    iMin = 1000;

    REP(i,N)
    {
        cin >> h[i];

        iMax = max(iMax,h[i]);
        iMin = min(iMin,h[i]);
    }

    for(ll j = 0; j <= iMax; j++)
    {
        REP(i,N)
        {
            if(c[i] == h[i])
            {
                streak = 0;
            }
            else
            {
                if(streak == 0)res++;
                streak++;
                c[i]++;
            }
        }
        streak = 0;
    }

    cout << res << endl;
    return 0;
}



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

using namespace std;
int n,k;
int ar[100005][4];
long long mem[100005][4];

long long solve(int ind,int prev){
    if(ind==n){
        return 0;
    }
    if(mem[ind][prev]!=-1){
        return mem[ind][prev];
    }
    int ch1=solve(ind+1,1)+ar[ind][0],ch2=solve(ind+1,2)+ar[ind][1],ch3=solve(ind+1,3)+ar[ind][2];
    if(prev==1){
        return mem[ind][prev]=max(ch2,ch3);
    }
    else if(prev==2){
        return mem[ind][prev]=max(ch1,ch3);
    }
    else if(prev==3){
        return mem[ind][prev]=max(ch1,ch2);
    }
    else{
        return mem[ind][prev]=max(ch1,max(ch2,ch3));
    }
}

int main() {
    //freopen("input.in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem,-1,sizeof mem);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    }
    cout<<solve(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n,m; cin >> n >> m;
	ll sum = 0;
	vl a(n); rep(i,n) cin >> a[i], sum += a[i];
	sort(rall(a));
	if(a[m-1]*4*m < sum) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, M;
  cin >> N >> M;
  vector<pii> A(N), C(M);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    A[i] = {a, b};
  }
  for (int i = 0; i < M; i++) {
    int c, d;
    cin >> c >> d;
    C[i] = {c, d};
  }

  for (int i = 0; i < N; i++) {
    int mi = 1e9 + 1, mi_j;
    for (int j = 0; j < M; j++) {
      int d = abs(C[j].first - A[i].first) + abs(C[j].second - A[i].second);
      if (mi > d) {
        mi_j = j;
        mi = d;
      }
    }
    cout << mi_j + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let (a, b, c, d): (i64, i64, i64, i64) = parse_line().unwrap();

    println!(
        "{}",
        *[a*c, a*d, b*c, b*d].iter().max().unwrap()
    );
}


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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	int a;

	cin >> a;
	cout<<!a<<endl;
		return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <iostream>


using namespace std;

signed main() {
    long n;
    cin >> n;
    long long min_val = 1000000000;
    long long max_val = 1;
    long long num;
    for (int i = 0; i < n; i++) {
        cin >> num;
        if (num < min_val) {
            min_val = num;
        }
        if (max_val < num) {
            max_val = num;
        }
    }
    cout << max_val - min_val << endl;
}

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

string s;
int solve(){
    cin>>s;
    for(int i=0;i<s.size();++i){
        if(s[i]=='U' || s[i]=='D')continue;
        if(s[i]=='R' && !(i&1) )continue;
        if(s[i]=='L' && (i&1) )continue;
        return 0;
    }
    return 1;
}

int main(){
    cout<<(solve() ? "Yes":"No")<<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;
using ll = long long;

int main(){
  vector<int> x(5);
  rep(i,5) cin >>x[i];
  rep(i,5){
    if(x[i]==0){
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,r,g,b,ans=0;
    scanf("%lld%lld%lld%lld",&r,&g,&b,&n);
    // ll [n];
    rep(i,0,n/r+1){
        // if(n-i>g+b) continue;
        ll gp=n-i*r,bp=0;
        while(gp>=0){
            if(gp%g==0 && bp%b==0) ans++;
            gp--;
            bp++;
        }
    }

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;
const int MOD = (int)1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    if (abs(n - m) > 1)
    {
        OUT(0);
        return 0;
    }
    ll ans;
    if (abs(n - m) == 0)
    {
        ans = 2;
    }
    else
    {
        ans = 1;
    }
    while (n > 0)
    {
        ans *= n;
        ans %= MOD;
        n--;
    }
    while (m > 0)
    {
        ans *= m;
        ans %= MOD;
        m--;
    }
    OUT(ans);
}

Measured memory_bytes: 256
S = str(input())
N = len(S)
ans1 = [0] * 2019
ans2 = 0

T = [0] *  (N + 1)
T[N] = 0
ans1[0] += 1

P = 1
for i in range(N - 1, -1, -1):
  #print(i)
  T[i] = (T[i + 1] + P * int(S[i])) % 2019
  ans1[T[i]] += 1
  P = 10 * P % 2019

for i in range(2019):
  x = ans1[i]
  ans2 += x * (x - 1) / 2
  
#print(ans1[0])
#print(T)
print(int(ans2))  



Measured memory_bytes: 16396
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
INT_MIN=-10**13
import bisect as B
###############################################################################\
s=input()

cr=0
cs=0
for i in range(len(s)):
    if s[i]=="R":
        cr+=1
    else:
        cs+=1

if s[0]==s[1]==s[2]=="R":
    print(3)
elif cr==2:
    if s[1]=="S":
        print(1)
    else:
        print(2)
elif cr==1:
    print(1)
else:
    print(0)


Measured memory_bytes: 62388
#include<stdio.h>
int main(){
	int hand[5][2],p,a,b,f;
	for(;;){
		if(scanf("%d,%d,%d,%d,%d",&hand[0][0],&hand[1][0],&hand[2][0],&hand[3][0],&hand[4][0]) == EOF){break;}
		p = 0;
		for(a=0;a<5;a++){hand[a][1] = 1;}
		for(a=0;a<5;a++){
			if(hand[a][1] == 1){
				f = 0;
				hand[a][1] = 0;
				for(b=a;b<5;b++){
					if(hand[a][0] == hand[b][0] && hand[b][1] == 1){
						f++;
						hand[b][1] = 0;
					}
				}
				if(f == 1){p+=2;}
				if(f == 2){p+=3;}
				if(f == 3){p+=10;}
			}
		}
		if(p == 0){
			for(a=0;a<5;a++){
				for(b=0;b<4;b++){
					if(hand[b][0]>hand[b+1][0]){
						f = hand[b][0];
						hand[b][0] = hand[b+1][0];
						hand[b+1][0] = f;
					}
				}
			}
			for(a=0;a<4;a++){
				if(hand[a][0]+1 != hand[a+1][0]){break;}
			}
			if(a == 4){p = 1;}
		}
		if(hand[0][0] == 1 && hand[1][0] == 10 && hand[2][0] == 11 && hand[3][0] == 12 && hand[4][0] == 13){p = 1;}
		if(p == 0){printf("null\n");}
		else if(p == 1){printf("straight\n");}
		else if(p == 2){printf("one pair\n");}
		else if(p == 3){printf("three card\n");}
		else if(p == 4){printf("two pair\n");}
		else if(p == 5){printf("full house\n");}
		else if(p == 10){printf("four card\n");}
	}
	return 0;
}

Measured memory_bytes: 0
a,b,c = map(int, input().split())
old_abc = [a,b,c]
res = 0
flg = 0
while a%2==0 and b%2==0 and c%2==0 and flg == 0:
  tmp_a = a/2
  tmp_b = b/2
  tmp_c = c/2
  a = tmp_b + tmp_c
  b = tmp_c + tmp_a
  c = tmp_a + tmp_b
  res += 1
  if old_abc == [a,b,c]:
    flg = 1
if flg == 1:
  print(-1)
else:
  print(res)

Measured memory_bytes: 3064
import math
from sys import exit, stdin
N = int(stdin.readline().rstrip())
xy = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(N):
        ans += math.sqrt((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)/N
print(ans)

Measured memory_bytes: 3064
# 2019-11-11 14:35:02(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 
from copy import deepcopy

def main():
    n, m = (int(x) for x in sys.stdin.readline().split())
    PY = [[int(x) for x in sys.stdin.readline().split()] for _ in range(m)]
    py = sorted(deepcopy(PY))

    ids = dict()
    for i in range(m):
        p, y = py[i][0], py[i][1]
        if not p in ids:
            ids[p] = dict()
            x = 0
        x += 1
        id_i = '0' * (6 - (math.floor(math.log10(p)) + 1)) + str(p) + '0' * (6 - (math.floor(math.log10(x)) + 1)) + str(x)
        ids[p][y] = id_i
    
    for i in range(m):
        p, y = PY[i][0], PY[i][1]
        print(ids[p][y])


if __name__ == "__main__":
    main()


Measured memory_bytes: 77172
#include <stdio.h>

int		main(void)
{
	char s[1000];
	scanf("%s", s);
	int i = 0;
	while (s[i])
	{
		if (s[i] == '7')
		{
			printf("Yes");
			return 0;
		}
		i++;
	}
	printf("No");
	return (0);
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
 
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
 
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}



void solve()
{
    string a,b;
    cin>>a>>b;
    cout<<b+a<<endl;
}




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    */
        ll t;
    //cin>>t;
    //while(t--)
        solve();
}



Measured memory_bytes: 256
import sys
s = input()
gx,gy = map(int, input().split(' '))
x_d = [0]
y_d = []
cnt = 0
for i in range(len(s)):
    if s[i] == "T":
        cnt += 1
        if cnt % 2 == 0:
            x_d.append(0)
        elif cnt % 2 == 1:
            y_d.append(0)
    if s[i] == "F":
        if cnt % 2 == 0:
            x_d[-1] += 1
        elif cnt % 2 == 1:
            y_d[-1] += 1
gx -= x_d[0]
x_d[0] = 0
x_d.append(0)
y_d.append(0)
if (sum(x_d)-gx) % 2 or (sum(y_d)-gy) % 2 or sum(x_d) < abs(gx) or sum(y_d) < abs(gy):
    print("No")
    sys.exit()
x_n = (sum(x_d)-gx)//2
y_n = (sum(y_d)-gy)//2
DPx = [[False for i in range(x_n+2)] for j in range(len(x_d))]
DPy = [[False for i in range(y_n+2)] for j in range(len(y_d))]
for x in DPx:
    x[0] = True
for y in DPy:
    y[0] = True
for i in range(len(x_d)-1):
    for j in range(x_n+1):
        if DPx[i][j]:
            DPx[i+1][j] = True
            if j+x_d[i] <= x_n+1:
                DPx[i+1][j+x_d[i]] = True
for i in range(len(y_d)-1):
    for j in range(y_n+1):
        if DPy[i][j]:
            DPy[i+1][j] = True
            if j+y_d[i] <= y_n+1:
                DPy[i+1][j+y_d[i]] = True
if DPx[len(x_d)-1][x_n] and DPy[len(y_d)-1][y_n]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 111324
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for a in range(A+1) :
    for b in range(B+1) :
        for c in range(C+1) :
            if 500*a+100*b+50*c == X :
                ans += 1
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var AB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B) = (AB[0], AB[1]);

        var ans = 0;

        if (A <= 5)
            ans = 0;
        else if (A <= 12)
            ans = B / 2;
        else
            ans = B;

        WriteLine(ans);
    }
}


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

int main(){
  int cntN=0;
  int cntW=0;
  int cntS=0;
  int cntE=0;
  string str;
  bool chk = true;
  
  cin >> str;
  
  for(int i = 0; i < str.size(); i++){
    if(str.at(i) == 'N') cntN++;
    else if(str.at(i) == 'W') cntW++;
    else if(str.at(i) == 'S') cntS++;
    else cntE++;
  }
  
  if((cntN > 0 && cntS == 0) || (cntN == 0 && cntS > 0)){
    chk = false;
  }
  if((cntE > 0 && cntW == 0) || (cntE == 0 && cntW > 0)){
    chk = false;
  }
  
  if(chk == true) cout << "Yes";
  else cout << "No";
  
}

Measured memory_bytes: 256
#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() {
    string s, t;
    cin >> s >> t;

    int ls, lt;
    ls = s.size();
    lt = t.size();
    int ans=100000;
    rep(i, ls-lt+1){
        int a=0;
        rep(j, lt){
            if(t[j] != s[j+i]) a++;
        }
        ans = min(ans, a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("date.in");
ofstream g("date.out");
int n,i;
unsigned long long a[105];
int main()
{
    cin>>n;
    a[0]=2;
    a[1]=1;
    for(i=2;i<=n;i++)
    {
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n];
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;

    int r = 0, b = 0;
    REP(i, S.length()) {
        if (S[i] == '0')
            r++;
        else
            b++;
    }

    cout << min(r, b) * 2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

const ll M = 998244353;
 
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    for(int i=0; i<n; i++){
        res *= a;
        res %= mod;
    }
    return res;
}

int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll N, m, K; cin >> N >> m >> K;
    ll ans = 0;
    ll p = K;
    for(int i=N-K; i<N+1; i++){
        ll h = 1;
        h *= m;
        h *= mpow(m-1, i-1);
        h %= M;
        h *= comb(i+p-1, i-1);
        ans += h;
        ans %= M;
        p--;
    }
    cout << ans;
}

Measured memory_bytes: 7868
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

def fun(A,N):
    dp = [0]*N
    for pos in range(N):
        if pos == 0:
            dp[pos] = 0
        elif pos == 1:
            dp[pos]  = abs(A[pos-1] - A[pos])
        else:
            dp[pos]= min(abs(A[pos] - A[pos-1]) + dp[pos-1], abs(A[pos] - A[pos-2]) + dp[pos-2])
    return dp[-1]

N = int(input())
A = alele()
print(fun(A,N))

Measured memory_bytes: 85928
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=2000009;
ll  dp[100009]; ///number of way to use i coins
ll  pre[100009];
int main()
{
    ll  n,k;
    cin>>n>>k;
    dp[0]=1;
    for(ll  i=0;i<n;i++)
    {
        ll  x; cin>>x;
        for(ll  used=0;used<=k;used++)
        {
            ll  suru=used+1;
            ll  ses=used+min(x,k-used);
            if(suru<=ses)
            {
                pre[suru]+=dp[used],pre[ses+1]-=dp[used];
                pre[suru]%=mod;
                pre[ses+1]=(pre[ses+1]+mod)%mod;

            }
        }
            for(ll  i=1;i<=k;i++)
            {
                pre[i]+=pre[i-1];
                pre[i]%=mod;
                dp[i]+=pre[i];
                dp[i]%=mod;
            }
            for(ll  i=0;i<=k;i++) pre[i]=0;
    }
    cout<<dp[k]<<endl ;
}


Measured memory_bytes: 1792
k,n=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in range(n):
    if i==0:
        s=max(s,k+a[i]-a[i-1])
    else:
        s=max(s,a[i]-a[i-1])
print(k-s)

Measured memory_bytes: 99936
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

// digit {{{
vector<int> digit(int_fast64_t n) {
    vector<int> ret;
    do { ret.emplace_back(n % 10); n /= 10; } while (n > 0);
    return ret;
}
// }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    size_t sum = 0;
    for (auto &di: digit(N)) {
        sum += di;
    }

    cout << (!(N % sum) ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
ll n, a, b;
int main()
{
	cin >> n >> a >> b;
	if (a > b)
		swap(a, b);
	if ((b - a) & 1)
		cout << (b - a) / 2 + min(a - 1, n - b) + 1 << '\n';
	else
		cout << (b - a) / 2 << '\n';
	return 0;
}


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

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int n;
vector<int> a;

int main(int argc, char const* argv[])
{
  cin >> n;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    a.pb(x);
  }
  int res = inf;
  for(int i = -100; i < 101; i++){
    int tmp = 0;
    for(int j = 0; j < n; j++){
      tmp += (a[j] - i) * (a[j] - i);
    }
    if(tmp < res){
      res = tmp;
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{ int a;
  int b;
  int s;
  int l;
  
  scanf("%d",&a);
  scanf("%d",&b);
  
  s=a*b;
  l=2*(a+b);

  printf("%d %d\n",s,l );

  return 0;




}

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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if

int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  
  int n;
  cin>>n;
  int a[n];
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  int sum=0;
  rep(i,n-1){
    sum+=a[i];  
  }
  cout<<(a[n-1]<sum?"Yes":"No")<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int l=1;
	int r=n;
	int li,ri;
	for(int i=0;i<m;i++){
		scanf("%d %d",&li,&ri);
		if(l<li&&li<=r){
			l=li;
		}
		if(l<=ri&&ri<r){
			r=ri;
		}
		if(r<li||ri<l){
			r=l-1;
			break;
		}
	}
	printf("%d",r-l+1);
	return 0;
}

Measured memory_bytes: 128