akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    int H, W, i, j, k, l, judge, count1=0, count2=0, retu[100], gyou[100], judge2;
    string a[100];

    cin >> H >> W;

    for(i=0; i<H; i++){
        cin >> a[i];
    }

    // 行
    for(i=0; i<H; i++){
        judge = 1;

        for(j=0; j<W; j++){
            if(a[i][j] == '#'){
                judge = 0;
            }
        }

        if(judge == 1){
            gyou[count1] = i;
            count1++;
        }
    }

    // 列
    for(i=0; i<W; i++){
        judge = 1;

        for(j=0; j<H; j++){
            if(a[j][i] == '#'){
                judge = 0;
            }
        }

        if(judge == 1){
            retu[count2] = i;
            count2++;
        }
    }

    for(i=0; i<H; i++){
        judge2 = 0;
        for(j=0; j<W; j++){
            judge = 1;
            
            for(k=0; k<=count1-1; k++){
                if(i == gyou[k]){
                    judge = 0;
                }
            }
            
            for(l=0; l<=count2-1; l++){
                if(j == retu[l]){
                    judge = 0;
                }
            }

            if(judge == 1){
                cout << a[i][j];

                judge2 = 1;
            }
        }

        if(judge2 == 1){
            cout << endl;
        }
    }

    return 0;
}  

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define IN freopen("perimetric_chapter_1_input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)

#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define xx first
#define yy second
#define ln 17
#define off 2002

#define sq(x) ((x)*(x))

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define log 20
#define mod 1000000007LL
#define INF 1000000000000000000LL
#define maxn 300005

const long double eps = 1e-9 ;

class numberTheory{

public:
    numberTheory(){}

    pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)

        if(b == 0) return pii( a >= 0 ? 1 : -1 , 0LL);
        else {
            pii d = extendedEuclid(b, a % b);
            return pii(d.yy, d.xx - d.yy * (a / b));
        }

    }

    i64 modularInverse(i64 a, i64 n) {
        pair<i64,i64> ret = extendedEuclid(a, n);
        return ((ret.xx % n) + n) % n;
    }


    i64 bigMod(i64 a, i64 n , i64 m)
    {
        if(n==0) return 1 ;
        i64 ret = bigMod(a,n/2,m) ;
        ret = (ret*ret)%m ;
        if(n%2) ret = (ret*a)%m ;
        return ret ;
    }
};

const i64 N = 700000 ;

i64 fact[N+5] , invFact[N+5] ;

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || r>n ) return 0 ;
  //  if(n<=50) return cc[n][r] ;
    i64 ret = (fact[n]*invFact[r])%mod ;
    return (ret*invFact[n-r])%mod ;
}

void preprocess()
{
    numberTheory nt ;

    fact[0] = 1 ;
    for(i64 x=1 ; x<=N ; x++) fact[x] = (fact[x-1]*x)%mod ;

    invFact[N] = nt.modularInverse(fact[N],mod) ;

    for(i64 x=N-1 ; x>=0 ; x--) invFact[x] = (invFact[x+1]*(x+1) )%mod ;
}

pair<int,int> ara[maxn] ;

int dp[4015][4015] ;

int main()
{
    preprocess() ;

    int n ;

    scanf("%d",&n) ;

    for(int i=1 ; i<=n ; i++) scanf("%d %d",&ara[i].xx,&ara[i].yy) ;

    for(int i=1 ; i<=n ; i++)
    {
        dp[ -ara[i].xx + off ][ -ara[i].yy+off ]++ ;
    }

    for(int i=-2000 ; i<=2000; i++)
    {
        for(int j=-2000 ; j<=2000 ; j++)
        {
            dp[ i+off ][ j+off ] = ( dp[i+off][j+off] + dp[i-1+off][j+off] + dp[i+off][j-1+off] )%mod ;
        }
    }

    int ans = 0 ;

    for(int i=1 ; i<=n ; i++)
    {
        ans = ( ans + dp[ ara[i].xx+off ][ ara[i].yy+off ] )%mod ;
        ans = ( ans - C( 2*(ara[i].xx+ara[i].yy) , 2*ara[i].xx ) )%mod ;
        ans = ( ans%mod + mod )%mod ;
    }

    if(ans%2) ans += mod ;

    ans /= 2 ;

    ans = (ans%mod + mod)%mod ;

    printf("%d\n",ans) ;

    return 0 ;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


pair<ll, ll> ps[4];

int main2() {
  ll Q, H, S, D; cin >> Q >> H >> S >> D;
  ll N; cin >> N;  
  N *= 4;
  ps[0] = make_pair(1, Q);
  ps[1] = make_pair(2, H);
  ps[2] = make_pair(4, S);
  ps[3] = make_pair(8, D);
  sort(ps, ps + 4, [](const pair<ll, ll>& a, const pair<ll, ll>& b) -> bool {
    return a.second * b.first < b.second * a.first;
  });
  ll ans = 0;
  REP(i, 4) {
    ll buy = N / ps[i].first;
    ans += buy * ps[i].second;
    N -= buy * ps[i].first;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector> 
#define mk make_pair
#define pk push_back 
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;
int main(){
	ios::sync_with_stdio(false);
	LL a,b,c,d;
	cin>>a>>b>>c>>d;
	LL ans=-1e18;
	if(a<=0&&b>=0) ans=max(ans,0ll);
	if(c<=0&&d>=0) ans=max(ans,0ll);
	ans=max(ans,a*c);
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout<<ans<<endl;
	return 0;
}

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

constexpr int INF = 1 << 30;

void solve() {
    int d, n;
    std::cin >> d >> n;

    std::vector<int> ts(d);
    for (auto& t : ts) std::cin >> t;

    std::vector<int> ls(n), rs(n), cs(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> ls[i] >> rs[i] >> cs[i];
    }

    std::vector<int> dp(n, -INF);
    {
        for (int i = 0; i < n; ++i) {
            if (ls[i] <= ts[0] && ts[0] <= rs[i]) dp[i] = 0;
        }
    }

    auto ndp = dp;
    for (int j = 1; j < d; ++j) {
        std::fill(ndp.begin(), ndp.end(), -INF);

        for (int i = 0; i < n; ++i) {
            if (ts[j] < ls[i] || rs[i] < ts[j]) continue;
            for (int pi = 0; pi < n; ++pi) {
                ndp[i] = std::max(ndp[i], dp[pi] + std::abs(cs[i] - cs[pi]));
            }
        }

        std::swap(dp, ndp);
    }

    std::cout << *std::max_element(dp.begin(), dp.end()) << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3224
/*
 * Matheus Oliveira
 * 09:45:08 21/09/2019
 * b.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXL 21
#define MAXN 200020
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, ini, fim) printf("%s: ", #x); for(int i = ini; i <= fim; i++) printf("%d%c", x[i], (i == fim) ? '\n' : ' ');

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int p[MAXN], lg[MAXN], sptMax[MAXL][MAXN], n, sptMin[MAXL][MAXN]; //sptMaxSort[MAXL][MAXN];

set<int> dae;
set<int>::iterator it;

void build() {
	int aux, val;

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

		while(aux/2 > 0) val++, aux /= 2;
		lg[i] = val;
	}

	for(int i = 0; i < n; i++) sptMax[0][i] = p[i], sptMin[0][i] = p[i];// sptMaxSort[0][i] = dae[i];

	for(int j = 1; j <= lg[n]; j++) {
		for(int i = 0; (i + (1 << (j-1)) ) < n; i++) {
			sptMax[j][i] = max(sptMax[j-1][i], sptMax[j-1][i + (1 << (j-1))]);
			//sptMaxSort[j][i] = max(sptMaxSort[j-1][i], sptMaxSort[j-1][i + (1 << (j-1))]);
			sptMin[j][i] = min(sptMin[j-1][i], sptMin[j-1][i + (1 << (j-1))]);
		}
	}
}

int queryMax(int l, int r) {
	int qtdElements = r-l+1;
	return max( sptMax[ lg[qtdElements] ][l], sptMax[ lg[qtdElements] ][ r - (1 << lg[qtdElements]) + 1 ] );
}

int queryMin(int l, int r) {
	int qtdElements = r-l+1;
	return min( sptMin[ lg[qtdElements] ][l], sptMin[ lg[qtdElements] ][ r - (1 << lg[qtdElements]) + 1 ] );
}

bool sorted(int l, int r) {
	//printf("checando (%d, %d)\n", l, r);

	it = dae.lower_bound(l);
	if(it != dae.end()) {
		if( (*it) - 1 >= l and (*it) - 1 <= r and (*it) >= l and (*it) <= r ) return false;
		++it;
		if(it != dae.end()) {
			if( (*it) - 1 >= l and (*it) - 1 <= r and (*it) >= l and (*it) <= r ) return false;
		}
	}
	return true;
}

int main() {
	bool flagSort = false;
	
	int k, ans = 0;
	scanf("%d %d", &n, &k);
	
	for(int i = 0; i < n; i++) scanf("%d", &p[i]);

	for(int i = 1; i < n; i++) {
		if(p[i] < p[i-1]) dae.insert(i); //printf("inserido %d\n", i);
	}

	build();
	for(int i = 0; i < n; i++) {
		if(i + k - 1 >= n) break;
		if( sorted(i, i + k - 1) ) flagSort = true; //printf("i: %d\n", i);
		else {
			if(i > 0) {
				//printf("queryMin(%d, %d) = %d, queryMin(%d, %d) = %d\n", i-1, i + k - 2, queryMin(i-1, i + k - 2), 
				//	i, i + k - 1, queryMax(i, i + k - 1));
				if( queryMin(i-1, i + k - 2) == p[i-1] and queryMax(i, i + k - 1) == p[i + k - 1] ) continue;
				else ans++; //printf("i: %d\n", i);
			}
			else ans++; //printf("i: %d\n", i);
		}
	}

	printf("%d\n", flagSort ? ans + 1 : ans);
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
#define endl "\n";
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef unordered_map<ll, ll> ump;

int32_t main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    vll a;
    for (int i = 0; i < n; i++)
    {
        ll num;
        cin >> num;
        a.push_back(num);
    }
    //s(a);
    ll ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i - 1] > a[i])
        {

            ans += (a[i - 1] - a[i]);
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long  S,W;
    cin >> S >> W;
 
    if (W >= S) {
            cout << "unsafe"  << endl;
    } else {
        cout << "safe" << endl;
    }

 
    return 0;
}
 


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

int main(){
    ll n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(3*n);
    rep(i,3*n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    rep(i,n){
        sum += a[2*i+1];
    }
    cout << sum << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
lli mod = 1e9 + 7;
int main()
{
    int n;
    string s1, s2;
    cin >> n;
    cin >> s1 >> s2;
    lli ans = 3;
    bool flag = false;
    rep(i, n)
    {
        //cout << ans << endl;
        if (s1[i] == s2[i]) {
            if (!flag and i != 0)
                ans *= 2;
            flag = false;
            /*if (i + 1 < n) {
                ans *= 2;
                if (s1[i + 1] == s2[i + 1]) {
                    continue;
                } else {
                }
            }
            */
        } else {
            i++;
            ans *= (flag ? 3 : 2);
            flag = true;
        }
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
count = {}
("a".."z").to_a.each do |elem|
  count[elem] = 0
end
while line = gets
  line.chomp!
  line.downcase!
  line.split(//).map{ |e|
    count[e] += 1 if count.key?(e)
  }
end
count.each do |key,value|
  puts "#{key} : #{value}"
end

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, k;
string s;

int num[MAX_N];

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  cin >> s;

  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      if (i == 0 || s[i - 1] == '1') {
        num[i] = 1;
      }
    }
  }

  for (int i = 1; i < n; ++i) {
    num[i] += num[i - 1];
  }

  num[n] = num[n - 1] + 1;

  int cnt = num[n - 1];

  if (k >= cnt) {
    printf("%d\n", n);
    return 0;
  }

  ans = -1;

  for (int i = 0; i < n; ++i) {
    int add = (s[i] == '0') ? k - 1 : k; // already using 0 part

    auto itr = upper_bound(num + i, num + n, num[i] + add);

    int ind = (itr - num) - 1;

    if (num[ind] - num[i] != add) continue;

    int score = ind - i + 1;

    ans = max(ans, score);
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,c,s;
    scanf("%d%d%d",&a,&b,&c);
    int x=b/a;
    if(x>=c)
        printf("%d\n",c);
    else
        printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string str;
    cin >> str;
    transform(str.begin(),str.end(),str.begin(),::tolower);
       
    int count=0;
    while(1){
        string tmp;
        cin>>tmp;
        if(tmp=="END_OF_TEXT") break;
        transform(tmp.begin(),tmp.end(),tmp.begin(),::tolower);
        if(str==tmp) count++;
    }
    cout <<count<<endl;
      
}


Measured memory_bytes: 3184
//Forever... Check size - Reading order - Use scanf - Clear structures
#pragma GCC optimize ("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff first
#define ss second
#define REP(i,a,b) for(int i = int(a); i < int(b); ++ i)
typedef long long ll;
typedef pair<int, int> ii;

const int N = 2e5 + 2;

int l[N], r[N];
vector<ll> vec, psum;

ll getsum(int l, int r){
	ll res = psum[r - 1];
	if(l) res -= psum[l - 1];
	return res;
}

int main(){
	fastio;
	int n; cin >> n;
	vec.resize(n); psum.resize(n);
	ll sum = 0;
	REP(i,0,n){
		cin >> vec[i];
		psum[i] += vec[i];
		if(i) psum[i] += psum[i-1];
	}
	int ptr = 1;
	REP(i,2,n){
		while(ptr + 1 < i && llabs(getsum(0,ptr) - getsum(ptr, i)) > llabs(getsum(0,ptr+1) - getsum(ptr+1,i))) ptr ++;
		l[i] = ptr;
	}
	ptr = n - 1;
	for(int i = n - 2; i >= 0; -- i){
		while(ptr - 1 > i && llabs(getsum(i,ptr) - getsum(ptr,n)) > llabs(getsum(i,ptr-1) - getsum(ptr-1,n))) ptr --;
		r[i] = ptr;
	}
	ll ans = 1e18;
	REP(i,2,n-1){
		int x = l[i], y = i, z = r[i];
		ll b = getsum(0, x), c = getsum(x, y), d = getsum(y, z), e = getsum(z, n);
		ll low = min(b, min(c, min(d, e)));
		ll high = max(b, max(c, max(d, e)));
		ans = min(ans, high - low);
	}
	cout << ans << endl;
	return 0;
}


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

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

    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];
    sort(L.begin(), L.end());
    int a, b, c;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        a = L[i];
        for (int j = i + 1; j < N; j++) {
            b = L[j];
            auto it = lower_bound(L.begin(), L.end(), a + b);
            cnt += (int) (it - L.begin()) - j - 1;
        }

    } 
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = input().split()
ans = 1
T = True
for i in range(n):
    if l[i] == '0':
        ans = 0
        break
if ans != 0:
    for i in range(n):
        if ans <= 10**18:
            ans = ans * int(l[i])
        else:
            T = False
            break
if False:
    print(-1)
elif ans > 10**18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 19388
#include<bits/stdc++.h>
using namespace std;
bool compare(pair<string,int> a,pair<string,int> b)
{
	if(a.first==b.first)
	{
		if(a.second>b.second)
			return true;
		else
			return false;
	}
	if(a.first<b.first)
		return true;
	return false;
}
int main()
{
	string str;
	int n,u;
	cin>>n;
	vector<pair<string,int> > p;
	unordered_map<int,int> hash;
	for(int i=0;i<n;i++)
	{
		cin>>str>>u;
		p.push_back(make_pair(str,u));
		hash[u]=i+1;
	}
	// for(auto u:)
	sort(p.begin(),p.end(),compare);
	for(int i=0;i<n;i++)cout<<hash[p[i].second]<<"\n";
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
prv = "*"
ans = 0
for i,c in enumerate(s):
    if c!=prv:
        ans += 1
    prv = c
print(ans)

Measured memory_bytes: 70768
n = int(input())
a = list(map(int,input().split()))

currentmoney = 1000
stock = 0

for i in range(n-1):
    if a[i] <= a[i+1]:
        stock += currentmoney // a[i]
        currentmoney -= a[i] * (currentmoney // a[i])
        currentmoney += stock * a[i+1]
        stock = 0

print(currentmoney)

Measured memory_bytes: 9128
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
int f[maxn],a[maxn],h[maxn],go[maxn],nxt[maxn];
int i,j,k,l,t,n,m,tot,top;
void add(int x,int y){
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
void dfs(int x){
    int t=h[x];
    if (!t) return;
    while (t){
        dfs(go[t]);
        t=nxt[t];
    }
    top=0;
    t=h[x];
    while (t){
        a[++top]=f[go[t]];
        t=nxt[t];
    }
    sort(a+1,a+top+1);
    int i;
    fo(i,2,top)
        if (a[i]<=a[i-1]) a[i]=a[i-1]+1;
    f[x]=a[top]+1;
}
int main(){
    scanf("%d",&n);
    fo(i,2,n){
        scanf("%d",&j);
        add(j,i);
    }
    dfs(1);
    printf("%d\n",f[1]);
}

Measured memory_bytes: 4864
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
A = LI()
A = A + sorted(A, reverse = True)[1 : ]
A.sort(reverse = True)
ans = 0

for i in range(N - 1):
    ans += A[i]
    
print(ans)

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

int main(void){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    int cnt[26] = {0};
    bool ok = 0;
    for (int i = 0; i < s.length(); i++)
    {
        cnt[s[i] - 97]++;
    }
    
    for (int i = 0; i < 26; i++)
    {
        if(cnt[i] > 1){
            cout << "no";
            ok = 1;
            break;
        }
    }
    if(!ok){
        cout << "yes";
    }
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = [input() for i in range(h)]

tmp = ""
for i in range(w+2):
    tmp += "#"

ans = []
ans.append(tmp)
for c in a:
    ans.append("#"+c+"#")
ans.append(tmp)

for c in ans:
    print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    const int INF = INT_MAX;
    vector<vector<int>> d(h,vector<int>(w,INF));
    queue<pair<int,int>> q;
    rep(i,h) {
        string s;
        cin >> s;
        rep(j,w) {
            if(s[j] == '#') {
                d[i][j] = 0;
                q.push(make_pair(i,j));
            }
        }
    }
    const int dx[4] = {0,0,-1,1};
    const int dy[4] = {1,-1,0,0};
    int ans = 0;
    while(!q.empty()) {
        auto v = q.front();
        int x = v.second;
        int y = v.first;
        q.pop();
        rep(i,4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
            if(d[ny][nx] != INF) continue;
            d[ny][nx] = d[y][x]+1;
            chmax(ans,d[ny][nx]);
            q.push(make_pair(ny,nx));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12432
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int abc[3];
	int ma=0;
	rep(i,3){
		cin>>abc[i];
		ma=max(ma,abc[i]);
	}

	int dis=0;
	rep(i,3){
		dis+=ma-abc[i];
	}
	if(dis%2==0){
		dis/=2;	
	}else{
		dis=(dis+3)/2;
	}
	cout<<dis<<endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
}


Measured memory_bytes: 3752
#include <stdio.h>
#define MAX 101

int main() {

  int n, u, k, v;
  int A[MAX][MAX];

  scanf("%d", &n);

  // 行列の初期化
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      A[i][j] = 0;
    }
  }

  // 入力
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &u, &k);
    for (int j = 0; j < k; j++) {
      scanf("%d", &v);
      A[u][v] = 1;
    }
  }

  // 出力
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == n) {
        printf("%d", A[i][j]);
      } else {
        printf("%d ", A[i][j]);
      }
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int main()
{
	int s, t, d, n;
	cin >> n;
	
	while(n--){
		cin >> s >> t;
		d = (t < s && s <= 5)? -1 : 1;
		while(t != s){
			cout << s << " ";
			s += d;
			if(s == 10){
				d = -1;
				s = 5;
			} else if(s == -1){
				d = 1;
				s = 1;
			}
		}
		cout << t << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
A,B,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_min=min(a)
b_min=min(b)
discount_m=10000000
for i in range(m):
    x,y,c=map(int,input().split())
    p=a[x-1]+b[y-1]-c
    if p<discount_m:
        discount_m=p
print(min(a_min+b_min,discount_m))


Measured memory_bytes: 18736
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin.tie(0);
#define F first
#define S second
using namespace std;
typedef long long ll;
ll a,b,c,d;
const ll maxn=200005;
const ll mod=1e9+7;
typedef pair<ll,ll> pii;
ll num[100005];
ll n,k,x,y,t;
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;

		b>>=1;
	}
	return res;
}

int main()
{
    //IOS
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    while(cin>>n>>d)
    {
        ll sum=n/(2*d+1);
        if(n%(2*d+1)) sum+=1;
        cout<<sum<<"\n";
    }



}


Measured memory_bytes: 256
N, K = map(int, input().split())
h = [None] * N
for _ in range(N):
    h[_] = int(input())

h.sort()
ans = 10000000000
tmp = sum(h[:K])
for i in range(N - K + 1):
    ans = min(ans, h[i + K - 1] - h[i])
print(ans)


Measured memory_bytes: 48088
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;
char s[N];
int three[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    int n = strlen(s);
    three[0] = 1;
    int mod = 1e9 + 7, res = 0, cur = 1;
    rep(i, 1, (int)N) {
        three[i] = (three[i - 1] * 3LL) % mod;
    }
    rep(i, 0, n) {
        if(s[i] == '1') {
            res = int((res + cur * (ll)three[n - 1 - i]) % mod);
            cur = (cur * 2LL) % mod;
        }
    }
    res += cur;
    res %= mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 768
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
   int a,b,c,d;
   cin>>a>>b;
   string s;
   cin>>s;
   vector<int> vec(a);
   vec.at(0)=0;
   rep(i,s.size()-1){
      if(s.at(i)=='A'&&s.at(i+1)=='C'){
         vec.at(i+1)=vec.at(i)+1;
      }
      else{
         vec.at(i+1)=vec.at(i);
      }
   }
   /*rep(i,s.size()-1){
      cout<<vec.at(i)<<endl;
   }*/
   rep(i,b){
     cin>>c>>d;
     cout<<vec.at(d-1)-vec.at(c-1)<<endl;
   }
   /*rep(i,b){
      cin>>c>>d;
      string tes;
      vec.at(i)=s.substr(c-1,d-c+1);
   } 
   */
}



Measured memory_bytes: 1408
N, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

s = 0
cnt = 0
for i in range(N - 1):
    s += a[i]
    if s > x:
        break
    else:
        cnt += 1
s += a[N - 1]
if s == x:
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define el cout<<endl
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int q; cin >> q;
    lint a, b;
    repeat (i, q) {
        cin >> a >> b;
        lint p = a * b;
        lint m = sqrt(p);
        lint ans;
        //dump(m); el;
        if (m * m == p) {
            ans = (m - 1) * 2;
            if (a != m) --ans;
        }
        else if (m * (m+1) < p) {
            ans = m * 2 - 1;
        }
        else {
            ans = m * 2 - 2;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstring>

int main(){
    char s;
    std::cin >> s;
    if(isupper(s)){
        std::cout << "A" << std::endl;
    }
    else if(islower(s)){
        std::cout << "a" << std::endl;
    }
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<bitset>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll dp[100][2];

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
	    cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = a[0];
	for (int i = 0; i < n; i++) {
	    ans = gcd(a[i], ans);
	}
	cout << ans << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;
  if (left < right) {
    cout << "Right" << endl;
  } else if(left > right){
    cout << "Left" << endl;
  } else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int a = tx - sx;
    int b = ty - sy;
    rep(i, a){cout << "R";}
    rep(i, b){cout << "U";}
    rep(i, a){cout << "L";}
    rep(i, b){cout << "D";}
    cout << "D";
    rep(i, a+1){cout << "R";}
    rep(i, b+1){cout << "U";}
    cout << "LU";
    rep(i, a+1){cout << "L";}
    rep(i, b+1){cout << "D";}
    cout << "R";


}

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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

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

    ll N, L, T;
    cin>>N>>L>>T;
    vector<pair<ll, bool>> XW(N);
    for (int n = 0; n < N; n++) {
        cin>>XW[n].first;
        int w;
        cin>>w;
        XW[n].second = (w == 1 ? false : true);
    }

    // XW[0]がT秒までに他の蟻とすれ違う回数
    ll count = 0;
    for (int n = 1; n < N; n++) {
        if (XW[n].second == XW[0].second) continue;
        if (XW[n].second == false) {    // XW[0]は反時計回り、XW[n]は時計回り
            ll dst = XW[0].first + L - XW[n].first;
            if (dst / 2 <= T) count -= 1 + (T * 2 - dst) / L;
        } else {    // XW[0]は時計回り、XW[n]は反時計回り
            ll dst = XW[n].first - XW[0].first;
            if (dst / 2 <= T) count += 1 + (T * 2 - dst) / L;
        }
    }
    if (XW[0].second == false) count %= N;
    else count = count - (ll)floor((double)count / N) * N;

    vector<ll> pos(N);
    for (int n = 0; n < N; n++) {
        if (XW[n].second == false) pos[n] = (XW[n].first + T) % L;
        else pos[n] = (L - (T - XW[n].first) % L) % L;
    }
    ll p0 = pos[0];     // count番目のアリはp0にいる

    vector<ll> ans(N);
    sort(begin(pos), end(pos));
    auto it = lower_bound(begin(pos), end(pos), p0);
    if (next(it) != end(pos) && *next(it) == p0 && !XW[0].second) it = next(it);

    ans[count] = p0;
    it++;
    for (int n = count+1; n % N != count; n++) {
        if (it == end(pos)) it = begin(pos);
        ans[n%N] = *it;
        it++;
    }
    for (int a : ans) cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 4352
n = int(input())
lisA = list(map(int,input().split()))
dic  = {}
for item in lisA:
    if item in dic:
        dic[item] += 1
    else:
        dic[item] = 1
q = int(input())
ans = sum(lisA)
for i in range(q):
    b,c = map(int,input().split())
    if b not in dic:
        print(ans)
    else:
        tmp = dic[b]
        if c in dic:
            dic[c] += dic[b]
        else:
            dic[c] = dic[b]
        dic[b] = 0
        if b > c:
            ans -= (b-c) * tmp
        else:
            ans += (c-b) * tmp
        print(ans)



Measured memory_bytes: 20972
#include <bits/stdc++.h>
using namespace std;
int main(){
  string t[4] = {"dream","dreamer","erase","eraser"};
  for(int i=0 ; i<4 ; i++){
    reverse(t[i].begin(),t[i].end());
  }
  string s; cin >> s;
  reverse(s.begin(),s.end());
  int now = 0;
  while(true){
    if(now==s.size()) break;
    int k = -1;
    for(int i=0 ; i<4 ; i++){
      if(now+t[i].size()-1<s.size()){
      string st = s.substr(now, t[i].size());
      if(st==t[i]) k = i;
      }
    }
    if(k!=-1){
      now += t[k].size();
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
int sum,cnt;
using namespace std;
int main(){
    int n,tmp;
    while(cin>>n,n){
        cnt=0;
        for(int i=1;i<n;i++){
            sum=0;
            tmp=i;
            while(sum<n){
                sum+=tmp;
                tmp++;
            }
            if(sum==n){
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include<stdio.h>
#define MAX 20
#define TRUE 1
#define FALSE 0

int num[MAX];
int a;

int judge(int,int);

int main() {

  int i,b,N;

  scanf("%d",&a);
  for(i=0;i<a;i++) scanf("%d",&num[i]);
  scanf("%d",&b);
  for(i=0;i<b;i++) {
    scanf("%d",&N);

    if( (judge(0,N)) == TRUE ) printf("yes\n");
    else printf("no\n");

  }

  return 0;

}

int judge(int i,int n) {

  int res;
  
  if( n == 0 ) return TRUE;
  if( i >= a ) return FALSE;

  res = judge(i+1,n) || judge(i+1,n-num[i]);

  return res;

}


Measured memory_bytes: 2108
N, M = map(int, input().split())
l_max = -1
r_min = N + 1
for m in range(M):
    l, r = map(int, input().split())
    if l > l_max:
        l_max = l
    if r < r_min:
        r_min = r
print(max(r_min - l_max + 1, 0))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int h,m,s,t;
	while (~fscanf(stdin, "%d%d%d",&h,&m,&s)) {
		t = (m + h * 60) * 60 + s;
		fscanf(stdin, "%d%d%d", &h, &m, &s);
		s += (m + h * 60) * 60;
		s -= t;
		h = s / 3600,s %= 3600;
		m = s / 60,	s %= 60;
		fprintf(stdout, "%d %d %d\n", h, m, s);
	}
	return 0;
}

Measured memory_bytes: 604
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;
constexpr char newl = '\n';

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define debug(x) cout << #x << ": " << x << '\n';

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  set<string> us;
  F0R(i, N) {
    string s;
    cin >> s;
    us.insert(s);
  }
  cout << us.size();
}


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

int main()
{
  int a, b, c;
  cin>>a>>b;
  
  a+=b;
  c=a%2;
  a/=2;
  
  if(c==1)
  {
    cout<<a+1<<endl;
  }
  else
  {
    cout<<a<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	ll N,K,Q;
	cin>>N>>K>>Q;
	K-=Q;
	vector<ll> A(N+1,0);
	for(int i=0;i<Q;i++){
		int tmp;
		cin>>tmp;
		A[tmp]++;
	}
	for(int i=1;i<=N;i++){
		if(A[i]+K>0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int l = int.Parse(Console.ReadLine());
            double d = (double)l /3;
            
            Console.WriteLine(Math.Pow(d,3));
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    p(x * x * x);
}



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

#print('-----')
max = -1
ans = -1

for i in range(n):
	count = 0
	k = i+1
	#print('-------')
	#print(k)
	while k%2 == 0:
		count = count+1
		k = k/2
		#print(count)
	if count >= max:
		max = count
		ans = i+1

print(ans)
		


Measured memory_bytes: 3316
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    string s, t, u;
    cin >> s >> t;
    cin >> A >> B;
    cin >> u;
    if(s == u){
        cout << A-1 << " " << B;
    }else{
        cout << A << " " << B-1;
    }
}


Measured memory_bytes: 256
// AOJ 1261: Mobile Computing
// 2018.1.21 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { double l, r; } T;
T tbl[128][20000];
int sz[128];

double R;
int w[7], sum[128];
char mk[128];
      
void dfs(int n)
{
	int i, j, f, l, r;
	double ll, rr, x;
	T t;

	if (mk[n]) return;
	mk[n] = 1;
    
	f = 0;
	for (l = (n-1) & n; l > 0; l = (l-1) & n) {
		f = 1;
        r = l ^ n;
        ll = (double)sum[r] / sum[n];
		rr = (double)sum[l] / sum[n];
         
		dfs(l), dfs(r);
              
		for (i = 0; i < sz[l]; i++) for (j = 0; j < sz[r]; j++) {
			x = tbl[l][i].l + ll;
			if (x < tbl[r][j].l - rr) x = tbl[r][j].l - rr;
			t.l = x;

			x = tbl[r][j].r + rr;
			if (x < tbl[l][i].r - ll) x = tbl[l][i].r - ll;
			t.r = x;

			if (t.l + t.r < R) tbl[n][sz[n]++] = t;
		}
    }
	if (!f) tbl[n][sz[n]].l = tbl[n][sz[n]].r = 0, sz[n]++;
}
      
int main()
{
	int cno, n, i, j, lim;
	double ans, t;

	scanf("%d", &cno);
	while (cno--) {
		scanf("%lf%d", &R, &n);
		for (i = 0; i < n; i++) scanf("%d", w+i);
		lim = (1 << n) - 1;
		memset(sz, 0, sizeof(sz));
		memset(mk, 0, sizeof(mk));

		for (i = 0; i <= lim; i++) {
			sum[i] = 0;
            for (j = 0; j < n; j++) if (i & (1<<j)) sum[i] += w[j];
		}

		ans = -1;
		dfs(lim);
		for (i = 0; i < sz[lim]; i++) {
			if (ans < (t = tbl[lim][i].l + tbl[lim][i].r)) ans = t;
		}
		if (ans < 0) puts("-1");
		else printf("%.16lf\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int N = scanner.nextInt();
		    int x = scanner.nextInt();
		    int[] array = new int[N];
		    for(int i = 0; i < N; i++) 
		    {
		    	array[i]  =scanner.nextInt();
		    }
		    Arrays.sort(array);
		    
		    int count = 0;
		    int sum = 0;
		    for(int i = 0; i < N; i++) 
		    {
		    	sum = sum + array[i];
		    	count++;
		    	if(sum >= x) 
		    	{
		    		break;
		    	}
		    }
		    if(sum == x) 
		    {
		    	System.out.println(count);
		    }
		    else if (count != 0)
		    {
		    	System.out.println(count - 1);
		    }
		    else 
		    {
		    	System.out.println(0);
		    }
		    scanner.close(); }
		  }

Measured memory_bytes: 22612
///
// File:  alds1_3_d.cpp
// Author: ymiyamoto
//
// Created on Sat Oct  7 16:10:09 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct area_t {
  int32_t start_pos;
  int32_t area;
};

static vector<int32_t> poss;
static vector<area_t> areas;

int32_t main()
{
  string str;
  cin >> str;

  for (int32_t i = 0; i < str.size(); i++) {
    if (str[i] == '\\') {
      poss.push_back(i);
    } else if (str[i] == '/') {
      if (!poss.empty()) {
        int32_t pos = poss.back();
        poss.pop_back();
        int32_t under_area = 0;
        while (!areas.empty()) {
          area_t area = areas.back();
          if (pos < area.start_pos) {
            under_area += area.area;
            areas.pop_back();
          } else {
            break;
          }
        }
        areas.push_back({pos, under_area + i - pos});
      }
    }
  }

  int32_t total = 0;
  for (uint32_t i = 0; i < areas.size(); i++) {
    total += areas[i].area;
  }

  cout << total << endl;
  cout << areas.size();

  for (uint32_t i = 0; i < areas.size(); i++) {
    cout << " ";
    cout << areas[i].area;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3312
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char s[4];
int ans;
int main()
{
	scanf("%s",s+1);
	if(s[1]=='M')
		ans=6;
	else if(s[1]=='T')
	{
		if(s[2]=='U')
			ans=5;
		else
			ans=3;
	}
	else if(s[1]=='W')
		ans=4;
	else if(s[1]=='F')
		ans=2;
	else
	{
		if(s[2]=='A')
			ans=1;
		else
			ans=7;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
using namespace std;

int main()
{
    char s[3][11];
    for(int i=0; i<3; i++){
        cin >> s[i];
    }
    for(int i=0; i<3; i++){
        s[i][0] = toupper(s[i][0]);
        cout << s[i][0];
    }
    
    return 0;
}

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

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

using namespace std;

int main(){
	int N;
	cin>>N;
	double xa,ya,ra,xb,yb,rb;
	REP(i,N){
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		double d=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
		if (d>ra+rb){
			cout<<0<<endl;
		}
		else if (fabs(ra-rb)<=d){
			cout<<1<<endl;
		}
		else if (ra>rb){
			cout<<2<<endl;
		}
		else{
			cout<<-2<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

int h, w, x, N, D;
ll ans;
int dis[11][11], d[11];
pq<pii> q;
int main(){
    flood(d);
    cin >> h >> w;
    fox(l, 10){
        fox(l2, 10){
            cin >> dis[l][l2];
        }
    }
    q.push(mp(0, 1));
    while(!q.empty()){
        N=q.top().y; D=-q.top().x; q.pop();
        if (d[N]<=D) continue;
        d[N]=D;
        fox(l, 10){
            q.push(mp(-D-dis[l][N], l));
        }
    }
    fox(l, h*w){
        scanf("%i", &x);
        ans+=d[x];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String st = sc.next();
        String st2 = st.replace("/", "");
        int a = Integer.parseInt(st2);
        if (a <= 20190430) System.out.println("Heisei");
        else System.out.println("TBD");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int dp[4001][4001];

int main(){
  string a,b;

  while(cin >> a >> b){

    memset(dp,0,sizeof(dp));
    int mx = 0;
    for(int i = 0 ; i < a.size() ; i++ ){
      for(int j = 0 ; j < b.size() ; j++ ){
	if(a[i] == b[j]){
	  dp[i+1][j+1] = dp[i][j] + 1;
	  if(mx < dp[i+1][j+1])mx = max(mx,dp[i+1][j+1]);
	} else {
	  dp[i+1][j+1] = 0;
	}
      }
    }
    cout << mx << endl;
  }
  return 0;
}

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


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

    if(n%2==0) cout<<n<<endl;
    else cout<<2*n<<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;
typedef long long ll;
const int INF = 1e9;

int main() {
  int h, w, d, q;
  cin >> h >> w >> d;
  ll A[h + 1][w + 1] = {};
  vector<pair<int, int>> a((h * w + h + w + 2));
  map<pair<int, int>, int> mp;
  rep(i, h) rep(j, w) {
    cin >> A[i + 1][j + 1];
    a[A[i + 1][j + 1]] = make_pair(i + 1, j + 1);
    mp[make_pair(i + 1, j + 1)] = A[i + 1][j + 1];
  }

  ll calc[h * w + 1] = {};
  for (int i = d + 1; i <= h * w; i++)
    calc[i] = calc[i - d] + abs(a[i - d].first - a[i].first) +
              abs(a[i - d].second - a[i].second);

  cin >> q;
  ll l, r, cnt, cur, next;

  rep(i, q) {
    cin >> l >> r;
    cout << calc[r] - calc[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 8832
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  map<string, int> mp;
  mp["SUN"] = 0;
  mp["MON"] = 1;
  mp["TUE"] = 2;
  mp["WED"] = 3;
  mp["THU"] = 4;
  mp["FRI"] = 5;
  mp["SAT"] = 6;

  string s; cin >> s;
  cout << 7-mp[s] << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val n = scala.io.StdIn.readInt
  val a = Array.tabulate(n)(i => scala.io.StdIn.readInt)
  var b = a.sorted.reverse
  var m0 = b(0)
  var m1 = b(1)
  for(i <- 0 until n) {
    if(a(i) == m0) {
      println(m1)
    } else {
      println(m0)
    }
  }
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string s;
    string mae;
    string ushiro;
    cin >> s;
    int q;
    cin >> q;
    bool frip = false;
    rep(i, q)
    {
        int t;
        cin >> t;
        if (t == 1)
            frip = !frip;
        if (t == 2)
        {
            int f;
            cin >> f;
            string aaa;
            cin >> aaa;
            if (f == 1)
            {
                if (frip) //最初と逆順
                    ushiro += aaa;
                else
                    mae = aaa + mae;
            }
            if (f == 2)
            {
                if (frip) //最初と逆順
                    mae = aaa + mae;
                else
                    ushiro += aaa;
            }
        }
    }
    if (frip)
    {
        for (auto itr = ushiro.end() - 1; itr != ushiro.begin() - 1; itr--)
        {
            cout << *itr;
        }
        for (auto itr = s.end() - 1; itr != s.begin() - 1; itr--)
        {
            cout << *itr;
        }
        for (auto itr = mae.end() - 1; itr != mae.begin() - 1; itr--)
        {
            cout << *itr;
        }
        cout << endl;
    }
    else
    {
        cout << mae + s << ushiro << endl;
    }
    return 0;
}


Measured memory_bytes: 1360
N,D=map(int,input().split())
X=[list(map(int,input().split())) for _ in range(N)]
ans=0
for i in range(N):
    for j in range(i+1,N):
        d=0
        for k in range(D):
            d+=(X[i][k]-X[j][k])**2
        for l in range(1000):
            if l**2==d:
                ans+=1
                break
print(ans)


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	string s, t;
	cin >> s >> t;

	cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]) << endl;

	return 0;
}

Measured memory_bytes: 256