akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cassert>
#include<climits>
#include<set>
#include<vector>
#include<algorithm>
#include<map>
#include<bitset>
#include<deque>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 35
 
using namespace std;
 
int N,M,dex,limit;
deque<int> ans;
vector<string> LG;
map<string,int> Index;
vector<int> G[MAX];
vector<int> bitG;
set<int> input[MAX];
string country;
bool used[MAX];
 
void cdfs(int cur,deque<int>& selected){
  if(used[cur])return;
  used[cur] = true;
  //cout << "cur = " << cur << endl;
  for(int i=0;i<G[cur].size();i++){
    int next = G[cur][i];
 
    if(used[next])continue;
 
    bool ok = false;
    for(int j=0;j<selected.size();j++){
      int one = selected[j];
      if( ( (bitG[one]>>cur) & 1 ) && ( (bitG[one]>>next) & 1 ) ){
    ok = true;
    break;
      }
    }

    if(ok){
      //cout << "from " << cur << " to " << next << endl;
      cdfs(next,selected);
    }
  }
}
 
 
bool check(deque<int>& selected){
  for(int i=0;i<M;i++)used[i] = false;
 
  int OK = bitG[selected[0]];
  while(OK){
    int use = OK & -OK;
    int cur = log2(use);
    OK -= use;
    cdfs(cur,selected);
  }
 
  for(int i=0;i<M;i++)if(!used[i])return false;
  return true;
}
 
void dfs(int cur,int language,int student,deque<int>& selected){
 
  if(language >= limit || language >= 6){
    return;
  }
 
  if(student == (1<<M)-1){
    if(!check(selected))return;
    if(limit > language){
      limit = language;
      ans = selected;
    }
    return;
  }
 
  for(int i=cur;i<N;i++){
    selected.push_back(i);
    dfs(i+1,language+1,student|bitG[i],selected);
    selected.pop_back();
  }
 
}
 
 
int main(){
 
  bool first = true;
  while(cin >> N >> M,N|M){
 
    if(!first)puts("");
    first = false;
 
    //init
    LG.clear();
    dex = 0;
    Index.clear();
    bitG.clear();
    ans.clear();
    for(int i=0;i<max(N,M);i++){
      G[i].clear();
      input[i].clear();
    }
      
    bitG.resize(N,0);
 
    for(int i=0;i<N;i++){
      cin >> country;
      LG.push_back(country);
      Index[country] = dex++;
    }
 
    int k;
    for(int i=0;i<M;i++){
      cin >> k;
      for(int j=0;j<k;j++){
    cin >> country;
    int index = Index[country];
    input[i].insert(index);
    bitG[index] |= (1<<i);
      }
    }
 
    //make graph
    for(int i=0;i<M;i++){
      for(int j=i+1;j<M;j++){
    for(set<int>::iterator it = input[i].begin(); it != input[i].end(); it++){
      int value = *it;
      if(input[j].find(value) != input[j].end()){
        G[i].push_back(j);
        G[j].push_back(i);
      }
    }
      }
    }
   
    limit = IINF;
    deque<int> deq;
    dfs(0,0,0,deq);
 
    if(limit == IINF){
      cout << "Impossible" << endl;
    } else {
      cout << limit << endl;
      for(int i=0;i<limit;i++){
    cout << LG[ans[i]] << endl;
      }
    }
 
 
  }
  return 0;
}

Measured memory_bytes: 1320
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    r = n % i
    p = (n - r) // i
    ans += p * max(0, i - k) + max(0, r - k + 1)
if k == 0:
    print(ans - n)
else:
    print(ans)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int N, M, n, m;
int Matrix[505][505];
void fillMatrix()
{
    int sum = -4000;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            Matrix[i][j] = 4000, sum += 4000;
    Matrix[n][m] = -sum - 1;
    for(int j = m + 1; j <= M; j++)
    {
        for(int i = 1; i <= n; i++)
            Matrix[i][j] = Matrix[i][j - m];
    }
    for(int i = n + 1; i <= N; i++)
        for(int j = 1; j <= M; j++)
            Matrix[i][j] = Matrix[i - n][j];
    long long s = 0;
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= M; j++)
            s += Matrix[i][j];
    if(s >= 0)
    {
        cout << "Yes\n";
        for(int i = 1; i <= N; i++)
        {
            for(int j = 1; j <= M; j++)
            {
                cout << Matrix[i][j] << " ";
            }
            cout << "\n";
        }
    }
    else
    cout << "No\n";
}
int main()
{
    cin >> N >> M >> n >> m;
    fillMatrix();
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> h(n); rep(i,n) cin >> h[i];

    int ans = 0;
    while(true){
        int min_high = inf;
        int start = 0, end = -1;
        bool isgrow = false;
        rep(i,n){
            if(h[i] == 0){
                if(i == start){
                    start++;
                }
                else{
                    ans += min_high;
                    end = i+1;
                    repm(j,start,end){
                        if(h[j] != 0) h[j] -= min_high;
                    }
                    start = end;
                    end = -1;
                    min_high = inf;
                }
            }
            else{
                min_high = min(min_high,h[i]);
                isgrow = true;
            }
        }

        if(!isgrow) break;
        else if(min_high != inf){
            repm(i,start,n) h[i] -= min_high;
            ans += min_high;
        }
    }

    cout << ans << endl;
}


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

int main() {
	string S;
	cin >> S;
	bool f = false;
	for (int i = 1; i < 4; i++) {
		if (S[i] == S[i-1]) {
			f = true;
			break;
		}
	}
	if (f) 
		cout << "Bad\n";
	else
		cout << "Good\n";
}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

N, M, K = map(int, input().split())
md = 998244353

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % md )
    inverse.append( ( -inverse[md % i] * (md//i) ) % md )
    g2.append( (g2[-1] * inverse[-1]) % md )

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % md

def cnt(k):
    ret = pow(M-1, N-1-k, md)
    ret *= cmb(N-1,k)
    ret %= md
    ret *= M
    ret %= md
    return ret

def main():
    rt = 0
    for k in range(K+1):
        rt += cnt(k)
        rt %= md
    print(rt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32932
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 10007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*-----Library-----*/
signed main(){
    int m,d,mm,dd;
    cin>>m>>d>>mm>>dd;
    if(m!=mm)cout<<1<<endl;
    else cout<<0<<endl;
}


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

int main(){
  int n, m; cin >> n >> m;
  vector<int> s(m), c(m);
  FOR(i, m) cin >> s[i] >> c[i];
  vector<int> num(n, -1);
  FOR(i, m){
    if(num[s[i]-1] != -1 && num[s[i]-1] != c[i]){
      cout << -1 << endl;
      return 0;
    }
    num[s[i]-1] = c[i];
  }
  if(n != 1 && num[0] == 0){
    cout << -1 << endl;
    return 0;
  }
  FOR(i, n){
    if(num[i] == -1){
      num[i] = i==0&&n!=1 ? 1 : 0;
    }
    cout << num[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int n, k;
    cin >> n >> k;

    vector<int> L;
    vector<int> R;
    REP(i, n) {
        int x;
        cin >> x;
        if (x < 0)
        {
            L.push_back(x);
        } else
        {
            R.push_back(x);
        }
    }
    sort(L.begin(), L.end(), greater<int>());
    sort(R.begin(), R.end());

    // left
    int ans = INF;
    FOR(i, 1, k) {
        if (i > L.size()) break;
        int lans = 0;
        lans += abs(L[i-1]);
        if (i < k) {
            if (k - i - 1 >= R.size()) continue;
            lans += 2 * R[k - i - 1];
        }
        ans = min(ans, lans);
    }

    FOR(i, 1, k) {
        if (i > R.size()) break;
        int rans = 0;
        rans += abs(R[i-1]);
        if (i < k) {
            if (k - i - 1 >= L.size()) continue;
            rans += 2 * abs(L[k - i - 1]);
        }
        ans = min(ans, rans);
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;

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

    int N;
    ll W;
    cin >> N >> W;

    vector<ll> w(N);
    vector<ll> v(N);

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

    vector<map<ll, ll> > dp(N);

    dp[0][0] = 0;
    dp[0][w[0]] = v[0];

    for(int i = 1; i < N; i++) {
        for(auto j = begin(dp[i - 1]); j != dp[i - 1].end(); j++) {
            ll x = j -> first;
            ll y = j -> second;
            dp[i][x] = max(dp[i][x], y);
            dp[i][x + w[i]] = max(dp[i][x + w[i]], y + v[i]);
        }
    }

    ll ans = 0;

    for(auto i = begin(dp[N - 1]); i != dp[N - 1].end(); i++) {
        if(i -> first > W) continue;
        ans = max(ans, i -> second);
        cerr << i -> first << " " << i -> second << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 13952
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		String S = sc.next();
		String T = sc.next();

		Map<Character, Integer> mapS = new HashMap<>();
		Map<Character, Integer> mapT = new HashMap<>();

		int index = 0;
		for (int i = 0; i < S.length(); i++) {
			char charS = S.charAt(i);
			char charT = T.charAt(i);

			if (mapS.containsKey(charS)) {
				if (mapT.containsKey(charT)) {
					if (!mapS.get(charS).equals(mapT.get(charT))) {
						System.out.println("No");
						return;
					}
				} else {
					System.out.println("No");
					return;
				}
			} else {
				if (mapT.containsKey(charT)) {
					System.out.println("No");
					return;
				}
			}
			index++;
			mapS.put(charS, index);
			mapT.put(charT, index);
		}
		System.out.println("Yes");
	}
}


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

int main() {
  int a,b;
  cin>>a>>b;
  int ans;
  bool t=false;
  for(int i=10*b;i<10*b+10;i++){
    if(25*a<=2*i&&2*i<25*a+25){
      ans=i;
      t=true;
      break;
    }
  }
  if(t)cout<<ans<<endl;
  else cout<<"-1"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define SL(x) scanf("%lld",&x)
#define PL(x) printf("%lld\n",x)
#define N 2000
#define CLR(x) memset(x,0,sizeof(x))
#define nl printf("\n")
#define tll tuple<ll,ll,ll>
#define N 2000
using namespace std;
bitset<N*N+1> b;
int main()
{
    ll n,i,x,y;
    b[0]=1;
    SL(n);
    y=0;
    for(i=0;i<n;i++)
        SL(x),y+=x,b|=b<<x;
    y=(y+1)/2;
    while(1)
    {
        if(b[y])break;
        y++;
    }
    PL(y);
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
#AGC33 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,w,n = LI()
sr,sc = LI()
sr -= 1
sc -= 1
h -= 1
w -= 1
s = input()
t = input()
l,r,d,u = 0,w,h,0
for i in range(n)[::-1]:
    if t[i] == 'R':
        if l > 0:
            l -= 1
    elif t[i] == 'L':
        if r < w:
            r += 1
    elif t[i] == 'U':
        if d < h:
            d += 1
    elif t[i] == 'D':
        if u > 0:
            u -= 1
    if s[i] == 'R':
        r -= 1
        if r < 0:
            print('NO')
            quit()
    elif s[i] == 'L':
        l += 1
        if l > w:
            print('NO')
            quit()
    elif s[i] == 'U':
        u += 1
        if u > h:
            print('NO')
            quit()
    elif s[i] == 'D':
        d -= 1
        if d < 0:
            print('NO')
            quit()
    
if l <= sc <= r and u <= sr <= d:
    print('YES')
else:
    print('NO')
            

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

int main() {
	int n,m;cin>>n>>m;
  n==1?n=0:n= n*(n-1)/2;
  m==1?m=0:m=m*(m-1)/2;

    cout << n+m;
  
  
}

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

using namespace std;

struct edge {
	int to;
	edge(const int& _to) :to(_to) {}
	edge(const edge& e) :to(e.to) {}
};

constexpr int MAX_N = 100000;
vector<int> pre_order(MAX_N, -1);//pre_order[i]:=??±???????????¢?´¢??§???????????????i????????£?????¨??????timer
vector<int> post_order(MAX_N, -1);//post_order[i]:=??±???????????¢?´¢??§???????????????i????????£?????¨??????timer
vector<int> parent(MAX_N, -1);//parent[i]:=??±???????????¢?´¢??§??¨????§????????????¨???????????????i??????
vector<bool> visited(MAX_N, false);//??±???????????¢?´¢???????????§????¨?????????????????????°???????´?????????????

vector<vector<edge>> G(MAX_N);

void add_edge(int s, int t) {
	G[s].emplace_back(edge(t));
	G[t].emplace_back(edge(s));
}

void dfs(const vector<vector<edge>>& G, int u = 0, int prev_u = -1, int timer = 1) {
	pre_order[u] = timer;
	post_order[u] = timer;
	++timer;

	//u????¨????????????¨????????¢
	visited[u] = true;
	

	for (int i = 0; i < G[u].size(); ++i) {

		int v = G[u][i].to;

		//u?????£??\??????????????????v == G[u][i].to ???????¨?
		if (!visited[v]) {

			//v?????????u??§?¢??????????
			parent[v] = u;

			//v??\????????±???????????¢?´¢????????????
			dfs(G, v, u, timer);

			//u???post_order?????´??°??????
			post_order[u] = min(post_order[u], post_order[v]);
		}

		//u?????£??\??????????????????v?????¢?¨?????????¢?´¢??§??´????????§????????£??????????????¨?????????
		else if (v != prev_u) {
			post_order[u] = min(post_order[u], pre_order[v]);
		}
	}
}

vector<int> articulation_points(const vector<vector<edge>>& G, int G_sz, int root = 0) {
	dfs(G,root);
	vector<int> ans;
	vector<bool> used(G_sz, false);
	for (int i = 0; i < G_sz; ++i) {

		//??±???????????¢?´¢??§?§????????????¨??????????????????????????????2?????\????????????????????\????¢????
		if (i == root) {
			int root_child = 0;
			for (int j = 0; j < G_sz; ++j) {
				if (parent[j] == root)++root_child;
				if (root_child == 2) {
					ans.emplace_back(root);
					break;
				}
			}
		}

		else if (parent[i] != root
				&&pre_order[parent[i]] <= post_order[i]
				&& !used[parent[i]]) {

			ans.emplace_back(parent[i]);
			used[parent[i]] = true;
		}
	}
	sort(ans.begin(), ans.end());
	return ans;
}

int main()
{
	int N, E;
	cin >> N >> E;
	int s, t;

	for (int i = 0; i < E; ++i) {
		cin >> s >> t;
		add_edge(s, t);
	}
	vector<int>ans = articulation_points(G, N);
	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << endl;
	}
}

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

int main() {
  int n;
  vector<int> a;
  vector<int> diff;

  while(cin >> n, n) {
    for(int i = 0; i < n; i++) {
      int A;
      cin >> A;
      a.push_back(A);
    }

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

    for(int i = 0; i < n-1; i++) {
      diff.push_back(a[i+1]-a[i]);
    }

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

    cout << diff[0] << endl;
    a.clear();
    diff.clear();
  }
  return 0;
}


Measured memory_bytes: 3156
#include<stdio.h>

int heap[1000];

void output(int k, int n){
	printf("node %d: key = %d, ", k, heap[k]);
	if( k/2 > 0 ){ printf("parent key = %d, ", heap[k/2]); }
	if( k*2 <= n ){ printf("left key = %d, ", heap[k*2]); }
	if( k*2 + 1 <= n ){ printf("right key = %d, ", heap[k*2+1]); }
	printf("\n");
	return;
}

int main(){
	int n, i;
	scanf("%d", &n);
	for( i = 1; i <= n; i++ ){ scanf("%d", &heap[i]); }
	for( i = 1; i <= n; i++ ){ output(i, n); }
	return 0;
}

Measured memory_bytes: 600
S = input()
y = int(S[0:4])
m = int(S[5:7])
d = int(S[8:10])

isH = True
if y > 2019:
    isH = False
elif y == 2019:
    if m > 4:
        isH = False
    elif m == 4:
        if d > 30:
            isH = False
if isH:
    print("Heisei")
else:
    print("TBD")



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

using namespace std;

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


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

int main() {
  int n, h, maxA = 1;
  cin >> n >> h;
  int b[n];
  for (int a, i = 0; cin >> a >> b[i]; ++i) {
    maxA = max(maxA, a);
  }
  sort(b, b + n);
  for (int i = 0; i < n; ++i) {
    if (b[i] >= maxA) {
      int result = 0;
      for (int j = n - 1; j >= i && h > 0; --j) {
        h -= b[j];
        ++result;
      }
      if (h > 0) {
        result += (h - 1) / maxA + 1;
      }
      cout << result;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  vector<long long> a(n);
  long long s = 0;
  REP(i, n) cin>>a[i];
  sort(ALL(a), greater<long long>());
  long long ans = a[0];
  int now = 1;
  int cnt = 0;
  REP(_, n - 2){
    ans += a[now];
    cnt++;
    if(cnt == 2){
      now++;
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4904
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

int main(void){
    int n,ans;
    ans = 0;
    cin >> n;
    int a[n];
    int b[n];
    int sub[n];
    rep(i,n)cin >> a[i];
    rep(i,n){
        cin >> b[i];
        sub[i] = a[i]-b[i];
    }
    sort(sub,sub+n);
    int count = n-1;
    int point = 0;
    rep(i,n){
        int need = -sub[i];
        if(need<=0){
            ans+=n-1-count;
            break;
        }
        if(ans==0)ans++;
        ans++;
        while(1){
            if(sub[count] < 0){ans=-1;break;}
            if(sub[count] >= need){
                sub[count] -=need;
                break;
            }
            else{
                need -= sub[count];
                count--;
            }
        }
        if(ans==-1)break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
string s;
cin >> s;
int a=ctoi(s.at(0)),b=ctoi(s.at(1)),c=ctoi(s.at(2)),d=ctoi(s.at(3));
if(a+b+c+d==7){cout << a <<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;return 0;}
if(a+b+c-d==7){cout << a <<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;return 0;}
if(a+b-c+d==7){cout << a <<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;return 0;}
if(a-b+c+d==7){cout << a <<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;return 0;}
if(a+b-c-d==7){cout << a <<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;return 0;}
if(a-b-c+d==7){cout << a <<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;return 0;}
if(a-b+c-d==7){cout << a <<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;return 0;}

if(a-b-c-d==7){cout << a <<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;return 0;}



}





Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int H, W;
    while (1)
    {
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if((i+j)%2  == 0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
//ifstream cin();
//ofstream cout();
char c;
int main(){
	c=getchar();
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout<<"vowel\n";
    else cout<<"consonant\n";
	ios::sync_with_stdio(false);
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <iostream>
#define MODD 1000000007
#define ll long long
using namespace std;


int main() {
    map<int,int> counts;
    int L;
    cin>>L;
    string S;
    cin>>S;
    for(char c : S) {
        counts[c-'a']++;
    }
    
    ll ans = 1;
    for(auto x : counts) {
        ans = (ans * (x.second+1))%MODD;
    }
    ans = (ans+MODD-1)%MODD;
    cout << ans << endl;
    
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>


#define	ll_int	long long int
#define	BUCKET_SIZE	100000


int ELEMENT_N;


typedef struct data_t{
	ll_int num;
	int n;
	struct data_t *next;
} DATA_T;

DATA_T *S[BUCKET_SIZE];


// ハッシュテーブルの初期化
void Init()
{
	int i;

	for(i = 0; i < BUCKET_SIZE; i++)
		S[i] = NULL;
}


ll_int Hash(ll_int num)
{
	return num % BUCKET_SIZE;
}


DATA_T *Find(ll_int num)
{
	ll_int h;
	DATA_T *p;


	h = Hash(num);

	for(p = S[h]; p != NULL; p = p->next)
		if(num == p->num)
			return p;

	return NULL;
}


void Insert(ll_int num)
{
	ll_int h;
	DATA_T *p;


	if(( p = Find(num) )){
		p->n++;
		return;
	}


	if( ( p = (DATA_T *)malloc(sizeof(DATA_T)) ) == NULL){
		printf("malloc error\n");
		exit(1);
	}

	h = Hash(num);
	p->num = num;
	p->n = 1;
	p->next = S[h];
	S[h] = p;
	ELEMENT_N++;
}


int main()
{
	int q;
	int query;
	ll_int num;
	DATA_T *p;
	int i;


	ELEMENT_N = 0;

	scanf("%d", &q);

	for(i = 0; i < q; i++){
		scanf("%d", &query);

		if(query){
		// find
			scanf("%lld", &num);
			if(( p = Find(num) ))
				printf("1\n");
			else
				printf("0\n");
		}else{
		// insert
			scanf("%lld", &num);
			Insert(num);
			printf("%d\n", ELEMENT_N);
		}
	}

	return 0;
}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  string S;
  cin >> S;
  rep(i, S.size()) { cout << (S[i] == ',' ? ' ' : S[i]); }
  cout << endl;

  return 0;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 10;

int N[2]; char Ns[2][MAX_N];
int As[2][MAX_N], Bs[2][MAX_N];
int main() {
	scanf("%s%s", Ns[0]+1, Ns[1]+1);
	for(int k=0; k<2; k++) {
		N[k] = strlen(Ns[k]+1);
		for(int i=1; i<=N[k]; i++) {
			As[k][i] = As[k][i-1] + (Ns[k][i] == 'A');
			Bs[k][i] = Bs[k][i-1] + (Ns[k][i] == 'B');
		}
	}

	int Q; cin >> Q;
	while(Q--) {
		int l[2], r[2]; scanf("%d%d%d%d", &l[0], &r[0], &l[1], &r[1]);
		int cnt[2];
		for(int k=0; k<2; k++) {
			cnt[k] = 0;
			cnt[k] += (As[k][r[k]] - As[k][l[k]-1]);
			cnt[k] += (Bs[k][r[k]] - Bs[k][l[k]-1]) * 2;
			cnt[k] %= 3;
		}
		if(cnt[0] == cnt[1]) puts("YES"); else puts("NO");
	}
	return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main() {
  size_t N;  // 文字列の長さ
  std::string S;  // 文字列
  std::cin >> N >> S;

  // 一致する部分文字列の最大長を求める
  size_t result = 0;  // 一致する部分文字列の最大長
  std::vector<size_t> z;  // [0, z[i])と[i, i+z[i])が一致するときの長さ
  for (size_t l1 = 0; l1 < N - 1; ++l1) {
    // バッファをクリアする
    z.clear();
    z.resize(N - l1, 0);

    // Z-Algorithm
    size_t beg = 0, end = 0;  // [l1, l1+(end-beg))と一致する[beg, end)
    for (size_t i = 1; i < z.size(); ++i) {
      if (i + z[i - beg] < end) {
        // 一致を確認した範囲の中であれば、以前に計算した値を再利用できる
        z[i] = z[i - beg];
      } else {
        // 一致を確認した範囲を外れる場合、改めて一致する部分を探す
        const size_t l2 = l1 + i;
        size_t len = i < end ? (end - i) : 0;  // 一致することが分かっている部分を長さに含める
        for (; l2 + len < N; ++len) {
          if (S[l1 + len] != S[l2 + len]) break;
        }
        z[i] = len;
        beg = i;
        end = i + len;
      }

      // 文字列同士が重ならないような長さ（l2-l1=i）を考慮しつつ最大長を求める
      result = std::max(result, std::min(i, z[i]));
    }
  }

  // 結果発表
  std::cout << result;
  return 0;
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    d, t, s = inl()
    return s * t >= d


print("Yes" if solve() else "No")


Measured memory_bytes: 9096
/**
 * Author RDP
 * 
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <assert.h>
using namespace std;
#define endl '\n'
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0);
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
/* **************************************************************************************** */

void test_case()
{
	FAST_IO 
	ll a, b;
	cin >> a >> b;
	cout << a * b << endl;
 	return ;
}
int main()
{
	FAST_IO
    int t = 1;
    //cin >> t;
    while(t--)
        test_case();
	return 0;
}

Measured memory_bytes: 3648
n = int(input())
v = list(map(int, input().split()))
d = [[0 for _ in range(10**5+9)] for _ in range(2)]
for i in range(n):
    d[i%2][v[i]] += 1
s = sum(d[0])+sum(d[1])
d1,d2 = max(d[0]),max(d[1])
i1,i2 = d[0].index(max(d[0])),d[1].index(max(d[1]))

if i1 == i2:
    d[0][i1] = 0; d[1][i2] = 0
    dd1 = max(d[0]); dd2 = max(d[1])
    print(min(s-d1-dd2, s-dd1-d2))
else:
    print(s-d1-d2)


Measured memory_bytes: 14404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void){
    int X,A;
    cin>>X>>A;
    if(X<A) cout<<0<<endl;
    else if(X>=A ) cout<<10<<endl;
}

Measured memory_bytes: 256
w, h, x, y = map(int, input().split())

# 面積の最大値は常に長方形の半分
# (x, y)がど真ん中の時だけ縦にも横にも切れる
ans = 0
if ((w / 2) == x) & ((h / 2) == y):
    ans = 1

print(w * h / 2, ans)

Measured memory_bytes: 9148
n = int(input())
R = len(str(n))
def topend(i):
  return [int(str(i)[0]),int(str(i)[len(str(i))-1])]
cnt = [[0]*10 for i in range(10)]

for i in range(1,n+1):
  l = topend(i)
  if l[0]*l[1]:
    cnt[l[0]][l[1]] += 1
ans = 0
for i in range(1,10):
  ans += cnt[i][i]*cnt[i][i]
for i in range(1,9):
  for j in range(i+1,10):
    ans += cnt[i][j]*cnt[j][i]*2
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;

int main()
{
    int n;
    string s;
    map<string,int> p;
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> s;
        p[s]++;
    }
    int m = 1;
    for (std::map<string,int>::iterator it = p.begin();it != p.end();it++){
        if (it->second > m){
            m = it->second;
        }
    }
    
    for (std::map<string,int>::iterator it = p.begin();it != p.end();it++){
        if (it->second == m){
            cout << it->first << endl;
        }
    }
}


Measured memory_bytes: 25216
from collections import deque
import sys

H, W = map(int, input().split())
xs, ys = map(int, input().split())
xt, yt = map(int, input().split())
xs -= 1
ys -= 1
xt -= 1
yt -= 1
G = [input() for _ in range(H)]

D_wk = [[1,0], [0,1], [-1,0], [0,-1]]
D_tl = 2

#cost = [[-1  for _ in range(W)] for _ in range(H)]

possible = set()
for i in range(H):
  for j in range(W):
    if G[i][j] == ".":
      possible.add(i * W + j)

# 01-BFS
def append_walk(c, x, y):
  for dx, dy in D_wk:
    if 0 <= x+dx <= H-1 and 0 <= y+dy <= W-1 and ((x+dx)*W+(y+dy)) in possible and ((x+dx)*W+(y+dy)) not in visited:
      task.appendleft([c, x+dx, y+dy])
def append_tele(c, x, y):
  for dx in range(-D_tl, D_tl+1):
    for dy in range(-D_tl, D_tl+1):
      if 0 <= x+dx <= H-1 and 0 <= y+dy <= W-1 and ((x+dx)*W+(y+dy)) in possible and ((x+dx)*W+(y+dy)) not in visited:
        task.append([c+1, x+dx, y+dy])

task = deque([[0, xs, ys]])
visited = set()
while task:
  while True:
    c, x, y = task.popleft()
    if x*W+y not in visited:
      break
    if not task:
      print(-1)
      sys.exit()    
  if x == xt and y == yt:
    print(c)
    #print(*cost, sep="\n")
    sys.exit()  
  visited.add(x*W+y)
  #cost[x][y] = c
  append_walk(c, x, y)
  append_tele(c, x, y)
  
print(-1)

Measured memory_bytes: 237652
#include <bits/stdc++.h>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define NMAX 100013
using namespace std;
ifstream f("puzzle2.in");
ofstream g("puzzle2.out");
int N, M, R, C, x, y, start;
long double sol, factorial = 1;
pii Puncte[9];
long double dist(pii pe1, pii pe2) {
    return sqrt((double) (pe1.first - pe2.first) * (pe1.first - pe2.first) + (pe1.second - pe2.second) * (pe1.second - pe2.second));
}
pii operator +(pii pe1, pii pe2) {
    return {pe1.first + pe2.first, pe1.second + pe2.second};
}




int main() {
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        factorial *= i;
        cin >> Puncte[i].first >> Puncte[i].second;
    }
    for (int i = 1; i <= N; ++i) {
        for (int j = i + 1; j <= N; ++j)
            sol = sol + dist(Puncte[i], Puncte[j]);
    }
    cout << fixed << setprecision(10) <<  sol * 2 / N;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int n,t;
    cin>>n>>t;
    vector<pair<int,int>> p(n);
    int amax=0;
    rep(i,n){
        //cin>>a[i]>>b[i];
        cin>>p[i].first>>p[i].second;
        amax = max(amax,p[i].first);
    }
    all(p);
    vector<vector<int>> dp(n+1,vector<int> (t+amax ,-big));
    rep(i,n+1){
        dp[i][0]=0;
    }
    for(int i=1;i<=n;i++){

        rep(j,t+amax){
            if(j-p[i-1].first>=0 &&j-p[i-1].first<t){
                dp[i][j] = max(dp[i-1][j-p[i-1].first]+p[i-1].second,dp[i-1][j]); 
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    /*
    rep(i,n+1){
        rep(j,t+amax+1){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    int ans=0;
    for(int j =0;j<t+amax;j++){
        ans = max(ans,dp[n][j]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 73720
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;

int N;
int A[100010];
bool b;
LL ans;

int main(){
	scanf("%d" , &N);
	for(int i = 0 ; i < N ; ++i){
		scanf("%d" , A + i);
	}
	for(int i = 0 ; i < N ; ++i){
		ans += (LL)A[i] / (LL)2;
		if(A[i] % 2 == 1){
			if(b){
				++ans;
				b = 0;
			} else {
				b = 1;
			}
		}
		if(A[i] == 0) b = 0;
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 512
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    S,W = parseMap(split(readline())) 
    if S<=W
        println("unsafe")
    else
        println("safe")
    end
end
main()





Measured memory_bytes: 160088
#include <stdio.h>

int main(void) {
  int n,m,i,g,p,ans;
  ans=0;
  g=0;
  int a[10000];
  
  scanf("%d",&n);
  scanf("%d",&m);
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    g+=a[i];
  }
  for(i=0;i<n;i++)
  {
    if(a[i]*(4*m)>=g)
    {
      ans++;
    }
  }
  if(ans>=m)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  

  return 0;
}


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

typedef long long ll;
const ll INF = 1e12;

//価値に対する最小の重さでDPする
int main(){
    int n,w;
    cin >> n >> w;

    ll dp[101][10101];

    for(int i=0;i<101;i++){
        for(int j=0;j<10101;j++){
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

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

    int ans = 0;
    for(int i=0;i<10101;i++){
        if(dp[n][i]<=w){
            ans = max(ans,i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11056
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        int A = NextInt();
        int B = NextInt();
        string s = NextString();
        int fin = 0;
        int bc = 0;
        foreach (char c in s)
        {
            if (c == 'b') bc++;
            if (c == 'a' && fin < A + B) { Console.WriteLine("Yes"); fin++; }
            else if (c == 'b' && fin < A + B && bc <= B) { Console.WriteLine("Yes"); fin++; }
            else Console.WriteLine("No");
        }
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

int main() {
  long a,b,c;
  cin >> a >> b >> c;
  if(4*a*b<(c-a-b)*(c-a-b)&&c-a-b>=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define pll pair<ll,ll>
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
#define sq(X) ((X)*(X))
#define PI 3.141592653589
const ll INF = 1e18l+10,N = 1e5+10,MAX = 2e5+10;

// A B C D H F E I G K L M N P S O Q R J U Z Y X T V W
int dp[3001][3001];
int main()
{
    SPEED
    string s,t;
    cin>>s>>t;
    int n = s.length(),m = t.length();
    for(int i=1;i<=n;i++)
    {
        for(int j = 1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
            dp[i][j] = dp[i-1][j-1] +1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }        
    }
    int i = n,j = m;
    vector<char>v;
    while(i>0 && j>0) {
        if(s[i-1]==t[j-1]) v.push_back(s[i-1]),i--,j--;
        else if(dp[i][j-1] > dp[i-1][j]) j--;
        else i--;
    }
    reverse(v.begin(),v.end());
    for(i=0;i<v.size();i++)cout<<v[i];
}

Measured memory_bytes: 35584
n = int(input())

dp = [0]*100001
dp[100],dp[101],dp[102],dp[103],dp[104],dp[105] = 1,1,1,1,1,1

for i in range(99896):
    if dp[i] == 1:
        dp[i+100],dp[i+101],dp[i+102],dp[i+103],dp[i+104],dp[i+105] = 1,1,1,1,1,1
print(dp[n])

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

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

    int n, m;
    cin >> n>> m;
    vector<int> a(n);
    for (auto &&ai : a)
    {
        cin >> ai;
    }

    priority_queue<int> pq(a.begin(), a.end());

    for (int i = 0; i < m; i++)
    {
        int discountee = pq.top();
        pq.pop();
        pq.push(discountee / 2);
    }

    long long ans = 0;
    while (!pq.empty())
    {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int H, N;
    cin >> H >> N;
    FOR(i, 0, N){
        int a;
        cin >> a;
        H -= a;
    }

    cout << (H <= 0 ? "Yes" : "No") << endl;
    return 0;
};


Measured memory_bytes: 256
object Main extends App {
  import scala.annotation.tailrec
  
  @tailrec
  def solve(a:List[Int],x:Int,ans:Int):Int = {
    a match {
      case h::Nil if x > 0 => if (h==x) ans+1 else ans
      case h::t if h <= x => solve(t,x-h,ans+1)
      case _ => ans
    }
  }
  
  val Array(n,x) = readLine.split(" ").map{_.toInt}
  val a = readLine.split(" ").map{_.toInt}.sorted.toList
  
  println(solve(a,x,0))
}

Measured memory_bytes: 27324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+10;
int x,y,z,k;
ll x1[maxn];
ll w[maxn];
ll z1[maxn];
ll ks=0;
ll xpy[maxn*maxn];
vector<ll>ans;
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()

{
    cin>>x>>y>>z>>k;
    for(int i=0; i<x; i++)
        cin>>x1[i];
    for(int i=0; i<y; i++)
        cin>>w[i];
    for(int i=0; i<z; i++)
        cin>>z1[i];
    sort(x1,x1+x,cmp);
    sort(w,w+y,cmp);
    sort(z1,z1+z,cmp);
    for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
    for(int s=0;s<z;s++){
     if((i+1)*(j+1)*(s+1)<=k)
        ans.push_back(x1[i]+w[j]+z1[s]);
    }
    }
    }
        sort(ans.begin(),ans.end(),cmp);
        for(int i=0;i<k;i++)
        printf("%lld\n",ans[i]);




    return 0;
}


Measured memory_bytes: 1400
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v, j = A[i], i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v

# shellSort
cnt = 0
n = int(input())
G = [(3 ** i - 1) // 2 for i in range(11, 0, -1) if (3 ** i - 1) // 2 <= n]
m = len(G)
A = [int(input()) for _ in range(n)]
for i in range(m):
    insertionSort(A, n, G[i])
print(m)
print(" ".join(list(map(str, G))))
print(cnt)
for i in range(n):
    print(A[i])

Measured memory_bytes: 47600
N = int(input())

S = input()

mod = 10**9+7

count_l = 0
count_r = 0
ans = 1
for i in range(2*N):
        if count_l-count_r==0:
                if S[i]=="W":
                        ans=0
                        break
                else:
                        count_l+=1
        else:
                if S[i]=="W":
                        if (count_l-count_r)%2==1:
                                count_l+=1
                        else:
                                ans*=(count_l-count_r)
                                ans%=mod
                                count_r+=1
                else:
                        if (count_l-count_r)%2==1:
                                ans*=(count_l-count_r)
                                ans%=mod
                                count_r+=1
                        else:
                                count_l+=1

if count_l-count_r!=0:
        print(0)
else:
        for i in range(1,N+1):
                ans*=i
                ans%=mod


        print(ans)

Measured memory_bytes: 40544