akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

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


Measured memory_bytes: 4844
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op =='?':
        break
    elif op =='+':
        print('%d'%(a+b))
    elif op =='-':
        print('%d'%(a-b))
    elif op =='*':
        print('%d'%(a*b))
    elif op =='/':
        print('%d'%(a/b))



Measured memory_bytes: 5596
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = raw_input()
K = input()
K_ = K

DP = [[0] * 110 for i in range(110)]
DP[0][0] = 1

for i in range(1, 110):
    DP[i][0] = 1
    for j in range(1, 110):
        DP[i][j] = DP[i - 1][j] + DP[i - 1][j - 1] * 9

ans = 0
for i in range(len(N)):
    if N[i] != '0':
        ans += DP[len(N) - i - 1][K]
        ans += (int(N[i]) - 1) * DP[len(N) - i - 1][K - 1]
    if N[i] != '0':
        K -= 1
        if K < 1:
            ans += 1
            break

print ans

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


int main() {
  int N;
  cin >> N;
  
  int S=N%1000;
  
  if(S==0){
    cout << 0 <<endl;
  }
  else{
    cout << 1000-S <<endl;
  }
}


Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;


int main()
{
	int x, y, z = 0;

	cin >> x >> y;

	if (x < y)
		swap(x, y);

	while (true)
	{
		z = x % y;
		if (z == 0)
			break;
		x = y;
		y = z;
	}

	cout << y << endl;
}

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

#define INF 2147483647

signed main()
{
    int N, W, w, v;
    long long ans, dp[100001] = {};

    cin >> N >> W;
    ans = 0;
    for(int i=0 ;i<N ;i++ ){
        cin >> w >> v;
        
        for(int j=W-w; j>0 ;j-- ){
            if(dp[j] > 0){
                dp[j + w] = max(dp[j + w], dp[j] + v); 
                
                ans = max(ans, dp[j + w]);
            }
        }

        if(w <= W){
            dp[w] = max(dp[w], dp[0] + v);
            
            ans = max(ans, dp[w]);
        }
    }

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

Measured memory_bytes: 4384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll x=0;while(x<n) x+=1000;
  print(x-n);
  return 0;
}

Measured memory_bytes: 3652
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int a,b,c,d,f;
    double e;
    cin >> a >> b >> c >> d >> e >> f;

    vector<double> water, suger;

    for (int i = 0; i <= f; i++){
        for (int k = 0; k <= f; k++){
            int sum = 100 * a * i + 100 * b * k;
            if (sum <= f){
                water.push_back(sum);
            }
        }
    }

    for (int i = 0; i <= f; i++){
        for (int k = 0; k <= f; k++){
            int sum = c * i + d * k;
            if (sum <= f){
                suger.push_back(sum);
            }
        }
    }


    int max_suger = 0;
    int max_sw = 0;
    int max_water = 100 * a;
    double max_rate = 0;
    double limrate = e / (100 + e);

    for (int i = 0; i < water.size(); i++){
        for (int k = 0; k < suger.size(); k++){
            if (water[i] + suger[k] == 0 || water[i] + suger[k] > f){
                continue;
            }
            double rate = suger[k] /(water[i] + suger[k]);
            if (max_rate < rate && rate <= limrate){
                max_rate = rate;
                max_suger = suger[k];
                max_water = water[i];
                //max_sw = water[i] + suger[k];
            }
        }
    }
    cout << max_suger + max_water << ' ' << max_suger << endl;
}



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

int main() {
  int N, M, A;
  cin >> N >> M;
  vector<int> city(N + 10);
  for (int i = 1; i <= M; i++) { 
    cin >> A;
    city.at(A)++;
    cin >> A;
    city.at(A)++;
  }
  for (int i = 1; i <= N; i++) cout << city.at(i) << endl;
}

Measured memory_bytes: 256
n = int(input())
w = []
f = True
for i in range(n):
    wcur = input()
    if wcur in w:
        f = False
    if i >= 1 and w[i-1][-1] != wcur[0]:
        f = False
    w.append(wcur)
if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
<?php
fscanf(STDIN, '%d', $length);
$dictionary = array();

for($i=0; $i<$length; ++$i){
    fscanf(STDIN, '%s %s', $action, $str);
    switch ($action) {
    case 'insert':
        $dictionary[$str] = 1;
        break;
    case 'find':
        if(isset($dictionary[$str])){
            echo 'yes'.PHP_EOL;
        } else {
            echo 'no'.PHP_EOL;
        }
        break;
    }
}



Measured memory_bytes: 54640
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define lli long long int
#define ld long double
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define printv(a) {\
    for (auto y : a) cout << y << ' ';\
    cout << '\n';\
}
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define pii pair<int,int> 
#define pll pair<lli,lli>
#define tiii tuple<int,int,int>
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
#define readfile freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int mod = 998244353, x = 864197532, N = 20, logN = 18, K = 350, all = (1 << N) - 1;

int main () {
	int n;
	lli d;
	cin >> n >> d;
	lli x, y, ans = 0;
	fop (i,0,n) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n, m;
    cin >> n >> m;
    vector<vector<string>>v;
    v.resize(n + 5);
    for(int i = 0; i < m; i++)
    {
        int idx;
        string s;
        cin >> idx >> s;
        v[idx].push_back(s);
    }
    int ac = 0, wa = 0;
    for(int i = 1; i <= n; i++)
    {
        int WAs = 0;
        bool acc = false;
        for(int j = 0; j < v[i].size(); j++)
        {
            if(v[i][j] == "WA")
                WAs++;
            else if(v[i][j] == "AC")
            {
                acc = true;
                break;
            }
        }
        if(acc)
        {
            ac++;
            wa += WAs;
        }
    }
    cout << ac << " " << wa;
    return 0;
}


Measured memory_bytes: 10368
<?php
	$input = trim(fgets(STDIN));
	$array = explode(" ",$input);
	$a = ($array[0]) + ($array[1]);
	$b = ($array[0]) - ($array[1]);
	$c = ($array[0]) * ($array[1]);
	$array1 = [$a,$b,$c];
	echo max($array1);
  
?>


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int N, M;
bool g[55][55];
bool seen[55];

void bfs(){
    queue<int> q;
    seen[0] = true;
    q.push(0);

    while(!q.empty()){
        int now = q.front(); q.pop();
        for(int to=0; to<N; ++to){
            if(g[now][to] == true && seen[to] == false){
                seen[to] = true;
                q.push(to);
            }
        }
    }
}

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

    vector<int> a(M), b(M);
    for(int i=0; i<M; ++i){
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }

    int res = 0;
    for(int i=0; i<M; ++i){
        for(int i=0; i<N; ++i) seen[i] = false;
        
        g[a[i]][b[i]] = g[b[i]][a[i]] = false;
        bfs();
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;

        bool all_visited = true;
        for(int i=0; i<N; ++i) if(seen[i] == false) all_visited = false;
        if(all_visited == false) ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int X, tmpX, sum = 0;
  cin >> X;
  tmpX = X;
  while (tmpX > 0) {
    sum += tmpX % 10;
    tmpX /= 10;
  }
  if (X % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c;
    int z=0;
    
    cin>>a>>b>>c;
    
    for(int i=a;i<=b;i++){
        
        if(c%i==0){
            z++;
        }
    }
    cout<<z<<endl;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int INF = 100000000;

template <typename T>
struct Edge
{
    int to;
    T cost;
};

template <typename T>
struct WeightedGraph
{
    int n;
    vector<vector<Edge<T>>> g;
    
    WeightedGraph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to, T cost){
        g[from].push_back((Edge<T>){to, cost});
    }
};

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    Graph g(n);
    Graph rg(n);
    for(int i = 0; i < n + m - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        rg.add_edge(b, a);
    }
    int r = -1;
    for(int i = 0; i < n; i++) if((int)rg.g[i].size() == 0) r = i;
    int d[100002];
    int pa[100002] {0};
    fill(d, d + n, INF);
    d[r] = 0;
    queue<int> que;
    que.push(r);
    while(que.size()){
        int u = que.front();
        que.pop();
        for(int v : g.g[u]){
            bool f = true;
            for(int w : rg.g[v]){
                if(w == u) continue;
                if(d[w] >= d[u]) f = false;
            }
            if(f){
                d[v] = d[u] + 1;
                pa[v] = u + 1;
                que.push(v);
            }
        }
    }
    for(int i = 0; i < n; i++) cout << pa[i] << endl;
}

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

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<vector<ll>> kazu(10);
    rep(i,n){
        ll num=s[i]-'0';
        kazu[num].push_back(i);
    }
    ll ans=0;
    rep(i,10){
        if(kazu[i].size()==0)continue;
        rep(j,10){
            if(kazu[j].size()==0)continue;
            rep(k,10){
                if(kazu[k].size()==0)continue;
                ll l=kazu[i].front();
                ll r=kazu[j].back();
                auto itr1=upper_bound(kazu[k].begin(),kazu[k].end(),l);
                if(itr1!=kazu[k].end() && *itr1<r && l<*itr1){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
n = int(input())
if n==2:print(1);exit()
a = [n]
for i in range(2,int(n**0.5+1)):
    if n%i==0:
        a.append(i)
        if i!=n//i:
            a.append(n//i)
cnt =0
for v in a:
    s = n
    while v<=s and s%v==0:
        s = s//v
    if s%v==1: cnt += 1
b = [n-1]
m = n-1
for i in range(2,int(m**0.5+1)):
    if m%i==0:
        b.append(i)
        if i!=m//i:
            b.append(m//i)
print(cnt + len(b))

Measured memory_bytes: 67140
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    string S,T;
    cin >> S >> T;
    ll ans = 0;
    ll n = S.size();
    rep(i,0,n){
        if(S[i] != T[i]) ans++;
    }
    print(ans);
    

}

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

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (auto &i:p) {
        cin >> i;
    }
    int ans = 0;
    set<int> s;
    for (int i = 0; i < k; ++i) {
        s.insert(p[i]);
    }
    vector<int> otv(n);
    otv[0] = 1;
    for (int i = 1; i <= n - k; ++i) {
        if (p[i + k - 1] != max(p[i + k - 1], *prev(end(s))) || p[i - 1] != *begin(s)) {
            otv[i]++;
        }
        s.erase(p[i - 1]);
        s.insert(p[i + k - 1]);
    }
    vector<bool> a(n);
    int cur_i = 0;
    while (cur_i < n) {
        int cur_j = cur_i + 1;
        while (cur_j < n && p[cur_j] >= p[cur_j - 1]) {
            cur_j++;
        }
        for (int i = cur_i; i <= cur_j - k; ++i) {
            a[i] = true;
        }
        cur_i = cur_j;
    }
    bool flag = false;
    for (int i = 0; i < n; ++i) {
        if (!flag && a[i]) {
            ans++;
            flag = true;
        } else if (!a[i]) {
            ans += otv[i];
        }
    }
    cout << ans;
}


Measured memory_bytes: 11264
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int num[35];
int main(){
	int n,m;scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		int k;scanf("%d",&k);
		for(int j=0,o;j<k;j++)
			scanf("%d",&o),
			num[o]++;
	}
	int ans=0;
	for(int i=1;i<=m;i++) ans+=(num[i]==n);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
def main():
    n = int(input())
    from collections import Counter
    ls = Counter(map(int, input().split()))
    print('YNeos'[not check(n, ls)::2])

def check(n, ls):
    key = list(ls.keys())
    val = list(ls.values())
    l = len(key)
    if key[0] == 0 and val[0] == n:
        return True
    elif l in [2, 3] and n % 3 == 0:
        if l == 2:
            if key[0] ^ key[1] in key and (val[0] == val[1]*2 or val[0]*2 == val[1]): return True
        elif l == 3:
            for v in val:
                if v != n / 3: return False
            if key[0] ^ key[1] == key[2] or key[1] ^ key[2] == key[0] or key[2] ^ key[0] == key[1]: return True
        return False
    else:
        return False

if __name__ == '__main__':
    main()

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

long long a[100006];
__int128 N=1e18;

int main()
{
	int n;
	__int128 tmp=1;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+n+1); 
	for(int i=1;i<=n;++i) {
		if(a[i]==0) {puts("0");return 0;}
		if(tmp*a[i]<=N) tmp*=a[i];
		else {puts("-1");return 0;}
	}
	cout<<(long long)tmp;
}

Measured memory_bytes: 4436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const N=1e3;
ll INF=0x3f3f3f3f;
int main()
{
    ll n,k,s=0;
    cin>>n>>k;
    while(n)
    {
        n/=k;s++;
    }
    if(s==0)s++;
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int maxn = 1e6+7;
int n;
long long seed;
inline long long rand(long long l, long long r) {
    static long long mo=1e9+7, g=78125;
    return l+((seed*=g)%=mo)%(r-l+1);
}
long long Max[10];
long long Min[10];
int main()
{
	ios::sync_with_stdio(false);
    int t;
    t=1;
    for(int cas=1;cas<=t;cas++)
    {
        cin >> n ;
        for(int i=0;i<10;i++)
            Max[i]=-1e15,Min[i]=1e15;
        long long x,y;
        for (int i = 0; i < n; i++)
        {
            cin>>x>>y;
            Max[0]=max(Max[0],x+y);
            Max[1]=max(Max[1],-x+y);
            Max[2]=max(Max[2],x-y);
            Max[3]=max(Max[3],-x-y);
            Min[0]=min(Min[0],x+y);
            Min[1]=min(Min[1],-x+y);
            Min[2]=min(Min[2],x-y);
            Min[3]=min(Min[3],-x-y);
        }
        long long ans =0;
        for(int i=0;i<4;i++)
            ans=max(Max[i]-Min[i],ans);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int k = 0;
  FOR(i, 0, sz(s)) if(s[i]=='x') k++;
  cout << (k>=8 ? "NO" : "YES") << endl;
}

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

char field[500][501];
int ax[26][2], ay[26][2];

bool ok(char a, int bx, int by, int ex, int ey) {
	if (bx == ex) {
		if (by > ey) by ^= ey, ey ^= by, by ^= ey;
		for (int y = by; y <= ey; y++)
			if (field[y][bx] != '.' && field[y][bx] != a) return false;
	} else /* if (by == ey) */ {
		if (bx > ex) bx ^= ex, ex ^= bx, bx ^= ex;
		for (int x = bx; x <= ex; x++)
			if (field[by][x] != '.' && field[by][x] != a) return false;
	}
	return true;
}

int main() {
	int h, w;
	int total = 0;
	cin >> h >> w;
	for (int i = 0; i < 26; i++)
		ax[i][0] = -1;
	for (int y = 0; y < h; y++) {
		cin >> field[y];
		for (int x = 0; x < w; x++) {
			if (field[y][x] != '.') {
				char a = field[y][x] - 'A';
				if (ax[a][0] == -1)
					ax[a][0] = x, ay[a][0] = y, total++;
				else
					ax[a][1] = x, ay[a][1] = y;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		if (ax[i][0] == ax[i][1] && (ay[i][0] == ay[i][1]+1 || ay[i][0]+1 == ay[i][1]))
			ax[i][0] = -1;
		else if (ay[i][0] == ay[i][1] && (ax[i][0] == ax[i][1]+1 || ax[i][0]+1 == ax[i][1]))
			ax[i][0] = -1;
	}

	int n = total, now;
	do {
		now = n;
		for (int i = 0; i < 26; i++) {
			if (ax[i][0] == -1) continue;
			char a = (char)('A'+i);
			if (
					ok(a, ax[i][0], ay[i][0], ax[i][1], ay[i][0]) &&
					ok(a, ax[i][1], ay[i][0], ax[i][1], ay[i][1])) {
				field[ay[i][0]][ax[i][0]] = field[ay[i][1]][ax[i][1]] = '.';
				ax[i][0] = -1;
				n--;
			} else if (
					ok(a, ax[i][0], ay[i][0], ax[i][0], ay[i][1]) &&
					ok(a, ax[i][0], ay[i][1], ax[i][1], ay[i][1])) {
				field[ay[i][0]][ax[i][0]] = field[ay[i][1]][ax[i][1]] = '.';
				ax[i][0] = -1;
				n--;
			}
		}
	} while (n < now);

	cout << (2*(total-now)) << endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    string s;
    cin >> n;
    cin >> s;
    set<string> st;
    vector<vector<bool>> existleft(n+2,vector<bool>(10));
    vector<vector<bool>> exist(n+2,vector<bool>(10));

    for(int i=0;i<n;i++){
        int c = s[i] - '0';
        existleft[i][c] = true;
        for(int j=0;j<10;j++){
            if(i-1>=0 && existleft[i-1][j])existleft[i][j] = true;
        }
    }

    for(int i=n-1;i>=0;i--){
        int c = s[i] - '0';
        exist[i][c] = true;
        for(int j=0;j<10;j++){
            if(exist[i+1][j]){
                exist[i][j] = true;
            }
        }
    }
    for(int i=1;i<n-1;i++){
        //　真ん中をiとする
        
        rep(k,10){
            if(existleft[i-1][k]){
                rep(j,10){
                    if(exist[i+1][j]){
                        string tmp;
                        tmp.push_back(k+'0');
                        tmp.push_back(s[i]);
                        tmp.push_back(j+'0');
                        st.insert(tmp);
                    }
                }
            }
        }
    }
    cout << st.size() << endl;
}

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

int main(){
  int n,h;cin>>n>>h;
  vector<int>a(n);
  vector<int>b(n);
  int max_a=0;
  for(int i=0;i<n;++i){
    cin>>a[i]>>b[i];
    max_a=max(max_a,a[i]);
  }
  sort(b.begin(),b.end(),greater<int>());
  int ans=0;
  for(int i=0;i<n;++i){
  	if(b[i]>max_a){
      h-=b[i];
      ++ans;
    }
    if(h<=0)break;
  }
  if(h>0)ans+=h/max_a+bool(h%max_a);
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
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 (b<a) { a=b; return 1; } return 0; }

int main(){
  string s; cin >> s;
  cout << s.substr(0,3);
  cout << "\n";
  return 0;
}


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

int main(int argc, const char * argv[])
{
    int snum = 0;
    int stuck = 0;
    string slit;
    while(cin >> slit){
        for (int i = 0; i < (int)slit.length(); i++) {
            if (isdigit(slit[i])) {
                stuck *= 10;
                stuck += slit[i] - '0';
            }
            if (!isdigit(slit[i + 1])) {
                snum += stuck;
                stuck = 0;
            }
        }
    }
    cout << snum << endl;
    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll n,h,w;
    cin>>n>>h>>w;
    ll small=min(h,w);
    cout<<(n-h+1)*(n-w+1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int> xx(n),yy(m);
  REP(i,n) cin >> xx[i];
  REP(i,m) cin >> yy[i];
  sort(ALL(xx));
  sort(ALL(yy));
  if(xx[n-1] < yy[0] && x < yy[0] && xx[n-1] < y) cout << "No War" << endl;
  else cout << "War" << endl; 
  
  return 0;
}

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	while (t--) {
		string s;
		cin >> s;
		int n = s.length();
		if (s[n - 1] == 's')
			cout << s << "es" << endl;
		else
			cout << s << "s" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
n=int(input())
a=[int(input()) for _ in range(n)]

if len(a)==1:
    print(1)
    exit(0)

a.sort()
ans=0

prev=a[0]
tmp=0

for i in range(n):
    if a[i]!=prev:
        if tmp%2==1:
            ans+=1
        tmp=1
    else:
        tmp+=1
    
    prev=a[i]

if tmp%2==1:
    ans+=1

print(ans)

Measured memory_bytes: 7388
a,b = map(int, input().split())
c = [1,3,5,7,8,10,12]
d = [4,6,9,11]
if a in c:
  if b in c:
    print('Yes')
  else:
    print('No')
elif a in d:
  if b in d:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3060
/*
      author : nishi5451
      created: 11.08.2020 21:54:00
*/

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


int main(){
    int x,a;
    cin >> x >> a;
    if(x<a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 3644
import sys

K = int(input())

if K < 10:
    print(K)
    sys.exit(0)

runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
count = 9
while True:
    new_runrun = []
    for run in runrun:
        run_str = str(run)
        last_num = int(run_str[-1])
        for i in range(3):
            diff = i - 1
            if (last_num == 9 and diff == 1) or (last_num == 0 and diff == -1):
                continue
            ans = int(run_str + str(last_num + diff))
            new_runrun.append(ans)
            count += 1
            if count == K:
                print(ans)
                sys.exit(0)
    runrun = new_runrun


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
HohleFeuerwerke;
unsigned long long a,b;
int main()
{
	ios::sync_with_stdio(false);
	cout.tie(0);cin.tie(0);
	cin>>a>>b;
	if(a==1) cout<<1<<endl;
	else if(b==1) cout<<1<<endl;
	else if(a*b%2==0) cout<<a*b/2<<endl;
	else cout<<a*b/2+1<<endl;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
s = input()

l = Counter()
for i in range(2 ** n):
    r, b = [], []
    for j in range(n):
        if (i >> j) & 1:
            r.append(s[j])
        else:
            b.append(s[j])
    r = ''.join(r)
    b = ''.join(b)
    l[(r[::-1], b[::-1])] += 1

ans = 0
for i in range(2 ** n):
    r, b = [], []
    for j in range(n):
        if (i >> j) & 1:
            r.append(s[n + j])
        else:
            b.append(s[n + j])
    
    r = ''.join(r)
    b = ''.join(b)
    ans += l[(b, r)]

print(ans)

Measured memory_bytes: 175396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    int ans[h][w];
    memset(ans,-1,sizeof(ans));
    int id=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                ans[i][j]=id;
                while(j+1<w&&s[i][j+1]!='#'){
                    j++;
                    ans[i][j]=id;
                }
                id++;
            }
        }
    }
    int cnt[h]={};
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ans[i][j]==-1){
                cnt[i]++;
            }
        }
    }
    for(int i=1;i<h;i++){
        if(cnt[i]==w){
            if(cnt[i-1]!=w){
                for(int j=0;j<w;j++){
                    ans[i][j]=ans[i-1][j];
                }
                cnt[i]=0;
            }
        }
    }
    for(int i=h-1;i>=0;i--){
        if(cnt[i]==w){
            if(cnt[i+1]!=w){
                for(int j=0;j<w;j++){
                    ans[i][j]=ans[i+1][j];
                }
                cnt[i]=0;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=w-1;j>=0;j--){
            if(ans[i][j]==-1){
                ans[i][j]=ans[i][j+1];
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j)cout<<" ";
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
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; }
using namespace std;

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

    vector<double> x(3),y(3);
    rep(i,3)cin>>x[i]>>y[i];
    
    vector<double> edge(3);
    rep(i,3)edge[i]=hypot(x[(i+1)%3]-x[i],y[(i+1)%3]-y[i]);
    double sum=(edge[0]+edge[1]+edge[2])/2.0;
    double area=sqrt(sum*(sum-edge[0])*(sum-edge[1])*(sum-edge[2]));
    double radius=area/sum;

    double left=0,right=1000;
    rep(i,100){
        double mid=(left+right)/2.0;
        if(mid<=radius and max<double>({edge[0],edge[1],edge[2]})/radius*(radius-mid)>=2*mid)left=mid;
        else right=mid;
    }
    cout<<setprecision(30)<<left<<endl;
    return 0;

}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include<iostream>
using namespace std;
#define ll long long
int cmd(int a ,int b){
    return abs(a)>abs(b);
}
ll arr[100000]={0};
int main() {
    double w,h,x,y;
    cin >>w>>h>>x>>y;
    double xx,yy;
    xx = w*h;
    xx/=2;
    if(w/2.0==x&&h/2.0==y)printf("%.6f %d\n",xx,1);
    else printf("%.6f %d\n",xx,0);
    return 0;
}

 /*long long  n,k;
   long long sum=0;
   for(ll i=0;i<n;i++){
    cin >>arr[i];
    sum+=arr[i];
   }
   if(sum<k)return cout<<0<<endl,0;
   else {
     ll cnt=0;
     sum=0;
     ll i = n-1;
     for(i=n-1;i>0;i--)
     {
         for(ll j = i-1;j>0;j--)
         if(sum>=k)break;
     }*/


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

int main(){
    string s, ans="";
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'B' && ans != "") ans.pop_back();
        else if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

long long arr[100];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    string s; cin >> n >> s;

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

    cout << tot;

    return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using namespace atcoder;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int op(int a, int b) { return max(a, b); }
int e() { return -1; }

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    segtree<int, op, e> seg(a);

    while (q--) {
        int t;
        cin >> t;
        if (t == 1 || t == 3) {
            int x, v;
            cin >> x >> v;
            x--;
            if (t == 1) {
                seg.set(x, v);
            } else {
                auto f = [&](int a) { return a < v; };
                cout << seg.max_right<decltype(f)>(x, f) + 1 << '\n';
            }
        } else {
            int l, r;
            cin >> l >> r;
            l--; r--;
            cout << seg.prod(l, r+1) << '\n';
        }
    }
}


Measured memory_bytes: 6180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384
 
std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}
 
int main() {
	int a,b;
	cin>>a>>b;
	cout<<ceil((a+b)/2.0)<<endl;
 
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>

#pragma GCC optimize(2)

#define ll long long
#define ull unsigned long long

#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)

#define pi(x) printf("%d\n", x)
#define pr(x) return !(printf("%lld\n", (long long)(x)))
#define pcs(ch, cs, x) printf("Case %s%d: %d\n", ch, cs, x)
#define pllcs(ch, cs, x) printf("Case %s%d: %lld\n", ch, cs, x)
#define pyncs(cs, st) printf("Case %s%d: %s\n", ch, cs, (st) ? "YES" : "NO")
#define pyn(st) printf("%s\n", (st) ? "yes" : "no")
#define pryn(st) return !(printf("%s\n", (st) ? "YES" : "NO"))
#define pll(x) printf("%lld\n", x)

#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi(x) freopen("in.txt", "r", stdin)
#define fo(x) freopen("out.txt", "w", stdout)

inline ll abs(ll x) { return x > 0 ? x : -x; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
inline ll min(ll x, ll y) { return x > y ? y : x; }
inline ll gcd(ll x, ll y) { return y == 0 ? x : gcd(y, x % y); }

int main(){
    long long a,b;
    glld(a,b);
    std::cout << max(a+b,max(a * b, a - b)) << std::endl;
}

Measured memory_bytes: 256
s = input().strip()[::-1]

valid = True
while len(s) > 0:
    if s[:6] == 'eraser'[::-1]:
        s = s[6:]
    elif s[:5] == 'erase'[::-1]:
        s = s[5:]
    elif s[:7] == 'dreamer'[::-1]:
        s = s[7:]
    elif s[:5] == 'dream'[::-1]:
        s = s[5:]
    else:
        valid = False
        break


print('YES' if valid else 'NO')

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; string s; cin >> n >> s;
    int ans = 0;
    rep(i,n-2) {
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define PB push_back

int main(int argc,char* argv[]){
  std::ios_base::sync_with_stdio(false);
  int n,q,x,ans=0,i;
  vector<int> vis,vit;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>x;
    vis.PB(x);
  }
  cin>>q;
  for(i=0;i<q;i++){
    cin>>x;
    vit.PB(x);
  }

  sort(vis.begin(),vis.end());sort(vit.begin(),vit.end());

  vector<int>::iterator itvis,itvit;
  itvis=vis.begin();itvit=vit.begin();

  while(itvis!=vis.end() && itvit!=vit.end()){
    if(*itvis==*itvit){
      ans++;
      itvis++;
      itvit++;
    }
    else if(*itvis>*itvit){
      itvit++;
    }
    else if(*itvis<*itvit){
      itvis++;
    }
  }

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

Measured memory_bytes: 1820
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if (a <= b) {
      System.out.println(a);
    } else {
      System.out.println(a - 1);
    }

  }
}

Measured memory_bytes: 22612
import numpy as np
N, Limit = map(int, input().split())

dp = np.zeros(10 ** 5 + 1) + 10 ** 10
dp[0] = 0

for _ in range(N):
    w, v = map(int, input().split())
    np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])

dp_meet_index = [i for i, v in enumerate(dp) if v <= Limit]

print(dp_meet_index[-1])


Measured memory_bytes: 16868
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		int q = stdIn.nextInt();
		LinkedList list = new LinkedList(n);
		for(int i = 0; i < m; i++) {
			int a = stdIn.nextInt();
			if(a%2 == 0) {
				for(int j = 0; j < a; j++) {
					
					list.now = list.now.next;
				}
			}
			else {
				for(int j = 0; j < a; j++) {
					
					list.now = list.now.prev;
				}
			}
			
			list.remove();
			
		}
		for(int i = 0; i < q; i++) {
			int qx = stdIn.nextInt();
			if(list.isntalive[qx]) {
				System.out.println("0");
			}
			else {
				System.out.println("1");
			}
		}
	}
	
	
}
class LinkedList {
	boolean[] isntalive;
	Data now;
	
	LinkedList(int n) {
		isntalive = new boolean[n];
		now = new Data();
		Data tmp = now;
		now.id = 0;
		now.next = new Data();
		now.next.id = 1;
		now.next.next = now;
		now.next.prev = now;
		now.prev = now.next;
		now = now.next;
		for(int i = 2; i < n; i++) {
			add();
		}
		now = tmp;
	}
	
	void add() {
		Data tmp = now.next;
		now.next = new Data();
		
		now.next.id = now.id+1;
		now.next.next = tmp;
		now.next.next.prev = now.next;
		now.next.prev = now;
		
		now = now.next;
	}
	void remove() {
		isntalive[now.id] = true;
		now.prev.next = now.next;
		now.next.prev = now.prev;
		now = now.next;
	}
}

class Data {
	Data prev;
	Data next;
	int id;
	
}

Measured memory_bytes: 99012
#include <bits/stdc++.h>
using namespace std;
int n;
int dp[2010];
int main(){
	memset(dp,0,sizeof(dp));
	cin>>n;
	dp[0]=1;
	for(int i=0;i<n;i++){
		for(int j=3;j<=n-i;j++){
			dp[i+j]+=dp[i];
			dp[i+j]%=1000000007;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 3640
//22:43
#include <stdio.h>
#include <string.h>

int N,M;
char graph[50][50];
//path[i][j][m] : 
char visited[50];

void dfs(int s){
	visited[s] = 1;
	for(int g = 0; g < N; g++){
		if(graph[s][g] == 1 && !visited[g]){
			dfs(g);
		}
	}
}

void printgraph(){
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			printf("%d,",graph[i][j]);
		}puts("");
	}
}
int main(){
	scanf("%d %d",&N,&M);
	for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) graph[i][j] = 0;

	for(int i = 0; i < M; i++){
		int a, b;
		scanf("%d %d",&a,&b);
		graph[a-1][b-1] = graph[b-1][a-1] = 1;
	}
	int ans = 0;
	for(int rmi = 0; rmi < N-1; rmi++){
		for(int rmj = rmi+1; rmj < N; rmj++){
			if(graph[rmi][rmj] == 0) continue;
			graph[rmi][rmj] = 0;	
			graph[rmj][rmi] = 0;	
			memset(visited,0,sizeof(visited));
			dfs(0);
			int cnt = 0;
			for(int i = 0; i < N; i++){
			 	cnt+=visited[i];
			}
			if(cnt != N) ans++;
			graph[rmi][rmj] = 1;	
			graph[rmj][rmi] = 1;	
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }

    bool flag = false;
    int sum=0;
    for(int i=0; i<n; i++){
        sum += a.at(i);
        if(sum>=h){
            flag=true;
            break;
        }
    }
    if(flag==true) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int h, w;
char c[410][410];
int num[410][410] = {};
bool used[410][410] = {};

long long b[250000] = {};
long long wh[250000] = {};

char t[300];
int x_move[4] = {1, -1, 0, 0};
int y_move[4] = {0, 0, 1, -1};


void dfs(int i, int j, int nu, char cc){
  if(i < 0 || i >= h || j < 0 || j >= w || c[i][j] != cc || used[i][j]){
    return;
  }

  num[i][j] = nu;
  used[i][j] = true;

  for(int x = 0;x < 4;x++){
    dfs(i+y_move[x], j+x_move[x], nu, cc == '#' ? '.' : '#');
  }
}



int main(){
  cin >> h >> w;

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

  t['#'] = '.';
  t['.'] = '#';

  int nums = 1;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(!used[i][j]){
        dfs(i, j, nums, c[i][j]);
        nums++;
      }
    }
  }

  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(c[i][j] == '#'){
        b[num[i][j]]++;
      }else{
        wh[num[i][j]]++;
      }
    }
  }

  long long ans = 0;

  for(int i = 0;i < nums;i++){
    ans += b[i] * wh[i];
  }

  cout << ans << endl;

  return 0;
}








Measured memory_bytes: 10624
s = input()
dp = [[0 for _ in range(len(s) + 1)] for _ in range(4)]
# 0文字目までで0個の照合が住んだ数
dp[0][0] = 1
for i in range(0,4):
  for j in range(1, len(s) + 1):
    # ABCを進めない道
    if s[j-1] == '?':
      dp[i][j] += dp[i][j - 1] * 3
    else:
      dp[i][j] += dp[i][j - 1]
    # ABCを進める道
    if 0 < i and (s[j - 1] == '?' or s[j - 1] == 'ABC'[i - 1]):
      dp[i][j] += dp[i - 1][j - 1]
    dp[i][j] %= 1000000007

print(dp[3][len(s)])


Measured memory_bytes: 19052
n = int(input())
D = list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))

p = {}
for d in D:
    if d not in p:
        p[d] = 1
    else:
        p[d] += 1

for t in T:
    if t not in p:
        print('NO')
        exit()
    if p[t] == 0:
        print('NO')
        exit()
    p[t] -= 1
    
print('YES')

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

int main() {

    string S, T;
    cin >> S >> T;

    if (S.length() + 1 != T.length()) {
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < S.length(); ++i) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3628
function Main(input){
    input = input.split("\n");
    var k = 0;
    while(1){
        input[k] = input[k].split(" ");
        var n = parseInt(input[k][0],10);
        var m = parseInt(input[k++][1],10);
        if(n == 0 && m == 0)
            break;

        var h = [],w = [];

        h[0] = 0;w[0] = 0;
        for(var i = 1;i <= n;i++)
            h[i] = parseInt(input[k++],10) + h[i - 1];
        for(var i = 1;i <= m;i++)
            w[i] = parseInt(input[k++],10) + w[i - 1];

        var edgeh = [],edgew = [];

        var max = h[n] > w[m] ? h[n] : w[m];

        for(var i = 0;i <= max;i++)
            edgeh[i] = edgew[i] = 0;

        for(var i = 0;i <= n;i++)
            for(var j = i + 1;j <= n;j++)
                edgeh[h[j] - h[i]]++;
        for(var i = 0;i <= m;i++)
            for(var j = i + 1;j <= m;j++)
                edgew[w[j] - w[i]]++;

        var ans = 0;

        for(var i = 1;i <= max;i++)
            ans += edgeh[i] * edgew[i];

        console.log(ans);
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 77368
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#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 rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)(v).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);



int main(void) {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3620