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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n, k;
    cin>> n >> k;

    ll ans = 0;
    while(n > 0)n /= k, ans++;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, A, B, C, l[8];
//4^N全探索
int search() {
    int res = INF;

    for(int i = 0; i < pow(4, N); ++i) {
        int cur = i;
        int cost = 0;

        int a_len = 0;
        int b_len = 0;
        int c_len = 0;

        for(int j = 0; j < N; ++j) {
            int bit = cur % 4;

            switch (bit)
            {
                case 0:
                    //使わない
                    break;
                case 1:
                    if(a_len > 0)
                        cost += 10;
                        
                    a_len += l[j];
                    break;
                case 2:
                    if(b_len > 0)
                        cost += 10;
                        
                    b_len += l[j];
                    break;
                case 3:
                    if(c_len > 0)
                        cost += 10;
                        
                    c_len += l[j];
                    break;
            }

            cur /= 4;
        }

        if(a_len > 0 && b_len > 0 && c_len > 0) {
            cost += abs(A - a_len) + abs(B - b_len) + abs(C - c_len);
            res = min(res, cost);
        }
    }

    return res;
}

int main(int argc, char **argv) {
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; ++i)
        cin >> l[i];
    
    cout << search() << endl;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1

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

friends = []
for _ in range(M):
    a,b = map(int, input().split())
    friends.append((a-1,b-1))

blocks = []
for _ in range(K):
    c,d = map(int, input().split())
    blocks.append((c-1,d-1))

uf = UnionFind(N)

for a,b in friends:
    if not uf.is_same(a,b):
        uf.unite(a,b)

ans = [0] * N


# i番目のUnionの人数
members = [0] * N
for i in range(N):
    members[uf.root(i)] += 1

for i in range(N):
    # iの人が所属するUnionの人数（i本人を除く）
    ans[i] = members[uf.root(i)] - 1

# 友達関係にある人は同じUnionかつ、友達候補になりえないから除く
for a,b in friends:
    ans[a] -= 1
    ans[b] -= 1

# ブロック関係にあるc,dが、もし同じUnionであれば友達候補になりえないので除く
for c,d in blocks:
    if uf.is_same(c,d):
        ans[c] -= 1
        ans[d] -= 1


print(*ans)


Measured memory_bytes: 38792
#include <stdio.h>

int main(void)
{
    int L;
    long double edgeSize;
    long double result;
    // input
    scanf("%d", &L);

    edgeSize = (long double)L / 3;
    result = edgeSize * edgeSize * edgeSize;
    // output
    printf("%Lf\n", result);

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n+1);
    REP(i,n) cin >> a[i];
    b[0] = a[0];
    FOR(i,1,n) b[i] = b[i-1] + a[i];
    b[n] = 0;
    sort(b.begin(),b.end());
    ll ans=0;
    ll kpa=b[0],cnt=0;
    //REP(i,n+1) cout << b[i] << " ";

    for(int i=1;i<=n;++i){
        if(kpa==b[i]) ++cnt;
        else{
            ans += (cnt+1)*cnt/2;
            kpa = b[i];
            cnt = 0;
        }
    }
    ans += (cnt+1)*cnt/2;
    cout << ans << endl;
    return 0;
}


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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>

const int N = 2e5 + 1;

ll a[N];

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    ll ans = 0, mx = a[0];
    for (int i = 1; i < n; i++) {
        ans += max(0ll, mx - a[i]);
        mx = max(mx, a[i]);
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 5124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] nums = new int[m];

        for (int i = 0; i < m; i++) {
            nums[i] = sc.nextInt();
        }
        sc.close();

        int num = 0;

        for (int i = 0; i < m; i++) {
            if (nums[i] >= x) {
                num++;
            }
        }
        int ans = Math.min(m - num, num);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int n;
char buf[1000000];

int main() {
  scanf("%d ", &n);
  while (n--) {
    fgets(buf, sizeof(buf), stdin);
    
    string ans(buf);
    while (1) {
      int pos = ans.find("Hoshino");
      if (pos == string::npos) break;
      ans = ans.replace(pos, strlen("Hoshino"), "Hoshina");
    }
    printf("%s", ans.c_str());
  }
}

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

int main(){
    string str;
    cin >> str;
    if((int)str[0] + (int)str[1] + (int)str[2] == 294){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int A,B,C,K;
scanf("%d %d %d %d",&A,&B,&C,&K);
if(K<=A){
printf("%d",K);
}else if(K<=A+B){
printf("%d",A);
}else{
printf("%d",2*A+B-K);
}
return 0;
}

Measured memory_bytes: 1712
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 3
		// 7 6 8
		int n = sc.nextInt();
		int N = 1000000;
		int[] arr = new int[N];
		for (int i = 1; i <= n; i++) {
			arr[i] = sc.nextInt();
		}
		int[] left = new int[N];
		int[] right = new int[N];
		for (int i = 1; i <= n; i++) {
			left[i] = gcd(left[i - 1], arr[i]);
		}
		for (int i = n; i >= 1; i--) {
			right[i] = gcd(right[i + 1], arr[i]);
		}
		int ans = 1;
		for (int i = 1; i <= n; i++) {
			int t = gcd(left[i - 1], right[i + 1]);
			ans = Math.max(ans, t);
		}
		System.out.println(ans);
	}

	private static int gcd(int a, int b) {
		if (b <= 0) {
			return a;
		} else {
			return gcd(b, a % b);
		}
	}
}

 
 

 
 
 
 


Measured memory_bytes: 62396
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int h,w,k;
    cin>>h>>w>>k;
    string grid[h];
    for(int i=0;i<h;i++) cin>>grid[i];
    int res=0;
    for(int mask=0;mask<(1<<(h+w));mask++) {
        int cnt=0;
        for(int col=0;col<w;col++) {
            for(int row=0;row<h;row++) {
                if(grid[row][col]!='#') continue;
                if((mask&(1<<col)) or (mask&(1<<(w+row)))) continue;
                cnt++;
            }
        }
        if(cnt==k) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3648
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a//gcd(a, b)*b

def lcms(a):
    l = a[0]
    for num in a[1:]:
        l = lcm(l, num)
    return l

n, m = map(int, input().split())
a = list(map(int, input().split()))
# a2 = [num//2 for num in a]
acount = [None]*n # aを2で割れる回数
anum = [None]*n # 割ったあとの残り(=奇数)
for i,num in enumerate(a):
    c = 0
    while num%2==0 and num>1:
        num //=2
        c += 1
    acount[i] = c
    anum[i] = num
if all(item==acount[0] for item in acount):
    l = lcms(anum)
    num0 = l * (pow(2, (acount[0]-1)))
    span = num0*2
    if m<num0:
        print(0)
    else:
        print(int((m-num0)//span + 1))
else:
    print(0)

Measured memory_bytes: 64228
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,hitachi="";
   cin>>s;
	for (register int i=1;i<=5;i++)
    {
		hitachi+="hi";
		if (hitachi==s)
			return cout<< "Yes\n",0;
	}
	return cout<<"No\n",0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;
  
  std::vector<ll> p(n+1);
  rep(i,0,n){
    ll a;
    std::cin>>a;
    a--;
    p[a]=i;
  }
  p[n]=-1;

  ll prev=MOD,cnt=0,ans=0;

  rep(i,0,n+1){
    if(p[i]<prev){
      ans=std::max(ans,cnt);
      cnt=1;
      prev=p[i];
    }else{
      cnt++;
      prev=p[i];
    }
  }

  std::cout<<n-ans;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll power(ll r, ll n) {
	ll a;
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		a=power(r, n / 2);
		return (a * a)%MOD;
	}
	else {
		return (r * power(r, n - 1))%MOD;
	}
}

ll parm(ll n, ll r) {
	ll res = 1;
	rep(i, r) {
		res = (res*(n - i))%MOD;
	}
	return res;
}

ll comb(ll n, ll r) {
	ll res = parm(n, r);
	rep(i, r) {
		res = (res*power(i + 1, MOD - 2))%MOD;
	}
	return res;
}
int main(void) {
	ll n, a, b; cin >> n >> a >> b;
	ll ans;
	ans = power(2, n) - comb(n, a) - comb(n, b) - 1;
	while (ans < 0) {
		ans += MOD;
	}
	cout << ans%MOD << endl;
	return 0;
}



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


int main() {
    int a;
    cin >> a;
    int d = a % 10;
    if(d == 3){
        cout << "bon" << endl;
        return 0;
    }
    if(d == 0 || d==1||d==6||d==8){
        cout << "pon" << endl;
        return 0;
    }

    cout << "hon" << endl;
    return 0;
}



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

int main()
{
    // your code goes here
    int n, k;
    cin >> n;
    cin >> k;
    int *arr = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum = sum + arr[i];
    }
    cout << sum << endl;
    delete[] arr;

    return 0;
}


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

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  for (int i=0; i < n; ++i)
    if (s[i] != s[k-1])
      s[i] = '*';
  cout << s << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n;
    cin>>n;
    vector<pii> v;
    ll temp1=-inf, temp2=-inf, temp3=-inf, temp4=-inf;
    pii meow1, meow2, meow3, meow4;
    rep(i, 0, n) {
        ll x, y;
        cin>>x>>y;
        v.pb({x, y});
        if (x+y>temp1) {
            meow1={x, y};
            temp1=x+y;
        }
        if (-x+y>temp2) {
            meow2={x, y};
            temp2=-x+y;
        }
        if (x-y>temp3) {
            meow3={x, y};
            temp3=x-y;
        }
        if (-x-y>temp4) {
            meow4={x, y};
            temp4=-x-y;
        }
    }
    //cout<<meow1.F<<" "<<meow1.S<<endl;
    ll ans=-inf;
    rep(i, 0, n) {
        ans=max(ans, abs(v[i].F-meow1.F)+abs(v[i].S-meow1.S));
        ans=max(ans, abs(v[i].F-meow2.F)+abs(v[i].S-meow2.S));
        ans=max(ans, abs(v[i].F-meow3.F)+abs(v[i].S-meow3.S));
        ans=max(ans, abs(v[i].F-meow4.F)+abs(v[i].S-meow4.S));
    }
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 7396
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

const int INF = 1000000000;

int main() {

  int N;
  cin>>N;
  string a[505];
  REP(i,0,N) cin>>a[i];

  int tc = 0;
  REP(i,0,N)REP(j,0,N) if(a[i][j] == '#') tc++;
  if(tc == 0){
    cout<<-1<<endl;
    return 0;
  }

  int ans = INF;
  REP(r,0,N){
    int cnt = 0;
    int tmp = 0;
    REP(i,0,N) if(a[i][r] == '#') tmp++;
    if(tmp==0) cnt++;
    tmp=0;
    REP(j,0,N) if(a[r][j] == '.')tmp++;
    cnt += tmp;
    tmp=0;
    REP(j,0,N){
      int t = 0;
      REP(i,0,N){
        if(a[i][j] == '.') t++;
      }
      if(t != 0) tmp++;
    }
    cnt += tmp;
    ans = min(ans, cnt);
  }

  if(ans==INF) cout<<-1<<endl;
  else cout<<ans<<endl;

  return 0;
}


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

int main() {
    int a, b;cin >> a >> b;
    if (a > b) {
        for (int i = 0; i < a; i++) {
            cout << b;
        }
        cout << endl;
    } else {
        for (int i = 0; i < b; i++) {
            cout << a;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
// ==============================================
// Library
// ==============================================
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

// If you use this function, "cin" speeds up.
// However, you can not mix "cin" and "scanf", "cout" and "printf".
void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ==============================================
// ==============================================

int main()
{
	fastIOS();

	int a, b, h;
	cin >> a;
	cin >> b;
	cin >> h;

	LL ans = (a + b) * h / 2;
	cout << ans << "\n";
}

Measured memory_bytes: 256
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]

lst=deque([])
for w,v in WV:
    nlst=deque([[w,v]])
    for i in range(len(lst)):
        w1,v1=lst[i]
        if w1+w<=W:
            if w1:
                nlst.append([w1+w,v1+v])
    if not lst:
        lst=copy.copy(nlst)
        continue
    Xlst=lst
    lst=deque()

    if Xlst or nlst:
        w1,v1=nlst[0]
        w2,v2=Xlst[0]
        if w1<w2:
            lst.append(nlst.popleft())
        else:
            lst.append(Xlst.popleft())
    while Xlst or nlst:
        w,v=lst[-1]
        if Xlst and nlst:
            w1,v1=nlst[0]
            w2,v2=Xlst[0]

            if w==w1:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.pop()
                    lst.append(nlst.popleft())
            elif w==w2:
                if v>=v2:
                    Xlst.popleft()
                else:
                    lst.pop()
                    lst.append(Xlst.popleft())
            else:
                if w1<w2:
                    if v>=v1:
                        nlst.popleft()
                    else:
                        lst.append(nlst.popleft())
                else:
                    if v>=v2:
                        Xlst.popleft()
                    else:
                        lst.append(Xlst.popleft())
        elif nlst:
            w1,v1=nlst[0]
            if w==w1:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.pop()
                    lst.append(nlst.popleft())
            else:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.append(nlst.popleft())
        elif Xlst:
            nlst=Xlst
            Xlst=deque()



lst.append([0,0])
print(max([v for w,v in lst if w<=W]))


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    static int a[200000], b[200000], aa[200000], bb[200000], c[600000], z[600000];
    cin >> n;
    for(int i=0;i<n;++i) cin >> a[i];
    for(int i=0;i<n;++i) cin >> b[i];
    for(int i=0;i<n;++i) aa[i] = a[i] ^ a[(i+1)%n];
    for(int i=0;i<n;++i) bb[i] = b[i] ^ b[(i+1)%n];
    
    for(int i=0;i<n;++i){ c[i] = bb[i]; c[i+n] = c[i+2*n] = aa[i]; }
    z[0] = 3 * n;
    int i = 1, j = 0;
    while(i < 3 * n){
        while(i + j < 3 * n && c[0+j] == c[i+j]) ++j;
        z[i] = j;
        if(j == 0){ ++i; continue; }
        int k = 1;
        while(i + k < 3 * n && k + z[0+k] < j){ z[i+k] = z[0+k]; ++k; }
        i += k; j -= k;
    }
    for(int k=0;k<n;++k){
        if(z[n+k] >= n) cout << k << " " << (a[k] ^ b[0]) << endl;
    }
        
    return 0;
}

Measured memory_bytes: 11264
from itertools import *
g=lambda a,x,b:a+b if x=='+'else a-b if x=='-'else a*b
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('-*+',repeat=3):
   if g(g(a,x,b),y,g(c,z,d))==10:return f"(({a} {x} {b}) {y} ({c} {z} {d}))"
   if g(g(a,x,g(b,y,c)),z,d)==10:return f"(({a} {x} ({b} {y} {c})) {z} {d})"
 return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll d[100005],vis[100005];
vector<set<ll>> g(100005);
vector<p2> res;
void dfs(ll i,vector<vector<ll>> &v){
    vis[i]=1;
    for(ll j=0;j<v[i].size();j++)
    if(!vis[v[i][j]]){
        g[i].insert(v[i][j]);
        dfs(v[i][j],v);
    }
}
void func(ll i){
    for(auto it=g[i].begin();it!=g[i].end();it++){
        func(*it);
        if(d[*it]%2==0){
            res.push_back({i,*it});
            d[i]++;
        }
        else{
            res.push_back({*it,i});
            d[*it]++;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    if(m%2){
        cout<<"-1";
        exit(0);
    }
    vector<vector<ll>> v(n+1);
    for(ll i=0;i<m;i++){
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1,v);
    for(ll i=1;i<=n;i++)
    for(ll j=0;j<v[i].size();j++)
    if(v[i][j]>i&&g[i].find(v[i][j])==g[i].end()&&g[v[i][j]].find(i)==g[v[i][j]].end()){
        res.push_back({i,v[i][j]});
        d[i]++;
    }
    func(1);
    for(ll i=0;i<res.size();i++)
    cout<<res[i].first<<" "<<res[i].second<<endl;
}

Measured memory_bytes: 30452
#include<bits/stdc++.h>
using namespace std;
//typedef long long int ll;
//typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n;
	cin>>n;
	vector<int> a(n),bb(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>bb[i];
	}
	bool r=false;
	bool l=false;
	int rr=inf,ll=inf;

	for(int i=0;i<n;i++){
		//int b,c;
		//cin>>b>>c;
		int b = a[i],c = bb[i];
		if(b==0){
			r = true;
			rr = min(rr,c);
		}else{
			l = true;
			ll = min(ll,c);
		}
	}
	if(l&&r){
		cout<<rr+ll<<endl;
	}else{
		cout<<0<<endl;
	}


	return 0;
}



Measured memory_bytes: 3104
package main

import "fmt"

var moduler = 2019

func main() {
	var l, r int
	fmt.Scan(&l, &r)
	if r-l >= 2019 {
		fmt.Println(0)
		return
	}
	ans := l * (l + 1) % moduler
	for i := l; i < r; i++ {
		for j := l + 1; j <= r; j++ {
			mod := i * j % moduler
			if mod < ans {
				ans = mod
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

fn main() {
  let n = get::val::<usize>();
  let mut xs = get::list::<isize>();

  let mut flag = true;
  let xmax = *xs.iter().max().unwrap();
  let xmin = *xs.iter().min().unwrap();

  if xmin.abs() > xmax.abs() {
    for i in 0 .. xs.len() {xs[i] = -xs[i]}
    xs.reverse();
    flag = false
  }

  let mut xmax = *xs.iter().max().unwrap();

  let mut imax = xs.iter().position(|&x|x==xmax).unwrap() + 1;
  let len = xs.len();

  let mut ans = vec![];
  for i in 0 .. len-1 {
    if xs[i] > xs[i+1] {
      while xs[i] > xs[i+1] {
        xs[i+1] += xmax;
        ans.push((imax, i+2));
      }
      if xmax < xs[i+1] {
        xmax = xs[i+1];
        imax = xs.iter().position(|&x|x==xmax).unwrap() + 1;
      }
    }
  }

  println!("{}", ans.len());
  for (x,y) in ans {
    if flag {
      println!("{} {}", x, y)
    } else {
      println!("{} {}", n-x+1, n-y+1)
    }
  }
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


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

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}
int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> nums(N);
    int a=0,b=0,j=0;
    for(int i=0;i<N;i++) {
        cin >> P.at(i);
    }
    for(int i=0;i<N;i++) {
        cin >> Q.at(i);
    }
    for(int i=0;i<N;i++) {
        nums.at(i) = i+1;
    }
    do{
        j++;
        if(nums == P) {
            a = j;
        }
        if(nums == Q) {
            b = j;
        }
    }while(next_permutation(nums.begin(), nums.end()));
    cout << abs(b-a) << endl;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	string s;
	cin>>s;
	ll n=s.size();
	ll ans=n;
	REP(i,n-1){
		if(s[i]!=s[i+1]){
			chmin(ans,max((ll)i+1,n-i-1));
		}
	}
	
	cout<<ans<<en;
}

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

    solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
	int n;
	int i;
	int a[10000],b[10000];
	int ap=0,bp=0;
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
			if(a[i]>b[i]){
				ap=ap+a[i]+b[i];
			}else if(a[i]<b[i]){
				bp=bp+a[i]+b[i];
			}else{
				ap+=a[i];
				bp+=b[i];
			}
		}
		printf("%d %d\n",ap,bp);
		ap=0;
		bp=0;
	}

	return 0;
}

Measured memory_bytes: 676
import std.stdio : write, writeln;
import std.array;
import std.range;
import std.algorithm : filter;

int bs(int[] arr, int trg){
	int l = 0;
	int r = cast(int)(arr.length-1);
	
	while(true){
		int idx = (l+r)/2;
		
		if(trg<arr[idx]){
			r = idx-1;
		}else if(arr[idx]<trg){
			l = idx+1;
		}else{
			return idx;
		}
		
		if(r<l){ return -1; }
	}
}

void main(){
	while(true){
		int n = next!int();
		int m = next!int();
		
		if((n | m) == 0x00){
			return;
		}
		
		bool[int] set;
		foreach(i; n.iota){
			set[i] = true;
		}
		
		int buf=0;
		int trg=m-1;
		while(set.length>1){
			int[] d = set.keys;
			int idx = bs(d.sort, trg);
			assert(idx!=-1);
			int nei = d[(idx+1)%d.length];
			set.remove(trg);
			
			d = set.keys;
			idx = bs(d.sort, nei);

			idx+=m-1;
			idx%=d.length;
			
			debug(1){
				dbg(d[idx]+1, trg+1, set.keys.sort);
				readln;
			}
			
			trg = d[idx];
		}
		
		(set.keys[0]+1).writeln;
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

Measured memory_bytes: 2872
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

bool check(ll x, ll n, ll a, ll b, v64 &h)
{
	ll cnt = 0, c = a - b;
	for (int i = 0; i < n; i++)
		cnt += (max(0ll, h[i] - x * b) + c - 1) / c;
	return (cnt <= x);
}

void solve()
{
	ll n, a, b;
	cin >> n >> a >> b;
	v64 h(n, 0);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	ll lo = 0, hi = 1e9 + 1, ans = 0;
	while (hi - lo > 1)
	{
		ll mid = (lo + hi) / 2;
		if (check(mid, n, a, b, h))
			hi = ans = mid;
		else
			lo = mid;
	}
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

int main()
{
	int N, M;
	std::string S;
	std::cin >> N >> M >> S;
	std::vector<int> ans;
	std::vector<bool> visited(N + 1);
	ans.push_back(N);
	visited[N] = true;
	while (ans.back() > 0)
	{
		int now{ans.back()};
		for (int next{std::max(0, now - M)}; next <= now; next++)
			if (visited[next]) break;
			else if (S[next] == '0')
			{
				ans.push_back(next);
				visited[next] = true;
				break;
			}
			else
				visited[next] = true;
		if (ans.back() == now)
			break;
	}
	if (ans.back() != 0)
		puts("-1");
	else
	{
		for (int i{(int)ans.size() - 1}; i > 0; i--)
			printf("%d%c", ans[i - 1] - ans[i], i == 1? '\n': ' ');
	}

	return 0;
}

Measured memory_bytes: 1144
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 200005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int X = 1000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(12);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

void solve()
{
    int n;
    cin>>n;
    int money = (n/1000)+((n%1000)>=1);
    cout<<(money*1000-n);
    return;
}

Measured memory_bytes: 3648
//https://ei1333.github.io/luzhiled/snippets/graph/lowlink.html

#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<math.h>

using namespace std;

struct Graph{
  vector< vector<int> > edge;
  vector<bool> visited;
  vector<int> lowest, parent, prenum;
  int timer;

  Graph(int n) : edge(n), visited(n, false), lowest(n), parent(n, -1), prenum(n){
    timer = 1;
  }

  void dfs(int now, int prev){
    prenum[now] = lowest[now] = timer;
    timer++;
    visited[now] = true;

    for(auto next:edge[now]){
      if(!visited[next]){
        parent[next] = now;
        dfs(next, now);
        lowest[now] = min(lowest[now], lowest[next]);
      }
      else if(next != prev){
        lowest[now] = min(lowest[now], prenum[next]);
      }
    }
  }

  void art_points(){
    dfs(0, -1);

    set<int> ap;
    int np = 0; //number of root's children
    for(int i = 0; i < parent.size(); i++){
      if(i == 0) continue;
      int p = parent[i];
      if(p == 0) np++;
      else if(prenum[p] <= lowest[i]) ap.insert(p);
    }
    if(np > 1) ap.insert(0);
    for(auto ans:ap){
      cout << ans << endl;
    }
  }
};


int main(){
  int v, e;
  cin >> v >> e;
  Graph G = (v);
  for(int i = 0; i < e; i++){
    int s,t;
    cin >> s >> t;
    G.edge[s].push_back(t);
    G.edge[t].push_back(s);
  }
  G.art_points();

  return 0;
}



Measured memory_bytes: 4288
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int a,b;
      cin >> a >> b;
      if(a+b<=9) cout << a+b << endl;
      else cout << "error" << endl;
      return 0;}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		long longest = 0;
		long longer = 0;
		int i = n-1;
		for(;i>=1;i--) {
			if(a[i]==a[i-1]) {
				longest = a[i];
				i -= 2;
				break;
			}
		}
		for(;i>=1;i--) {
			if(a[i]==a[i-1]) {
				longer = a[i];
				i--;
				break;
			}
		}
		System.out.println(longer*longest);
		in.close();
	}

}


Measured memory_bytes: 50408
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    H = list(map(int, lines.pop(0).split(' ')))
    maxh = 0
    res = 0
    for r in H:
        if maxh <= r:
            res += 1
            maxh = r
    print(res)

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);

int odd = sc.nextInt();
int even = sc.nextInt();
  int numodd = nCombination(odd);
  int numeven = nCombination(even);
System.out.println(numodd + numeven);
}
  
  private static int nCombination(int count) {
        int num = 0;
        for (int i = 0; i < count - 1; i++) {
            for (int j = i + 1; j < count; j++) {
                num++;
            }
        }
    return num;
    }
  
}


Measured memory_bytes: 21844
W,H,N = (int(i) for i in input().split())

upright = [W,H]
downleft = [0,0]

for i in range(N):
    x,y,a = (int(k) for k in input().split())
    if a == 1:
        if x >= downleft[0]:
            downleft[0] = x
    elif a == 2:
        if x <= upright[0]:
            upright[0] = x
    elif a == 3:
        if y >= downleft[1]:
            downleft[1] = y
    else:
        if y <= upright[1]:
            upright[1] = y

height = upright[1]-downleft[1]
width = upright[0]-downleft[0]

if height >= 0 and width >= 0:
    area = height*width
else:
    area = 0

print(area)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, a;
	cin >> h >> a;
	int cnt = 0;
	vector<int> l(a);
	rep(i, a) {
		cin >> l[i];
		cnt += l[i];
	}
	if (cnt >= h) cout << "Yes";
	else cout << "No";
}



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

int main()
{
  int a, b, c ;
  cin >>a >>b >>c ;
  
  if(a==5 && b==5 && c==7){
    cout <<"YES"<<endl ;
  }
  else if(a==5 && b==7 && c==5){
    cout <<"YES"<<endl ;
  }
  else if(a==7 && b==5 && c==5){
    cout <<"YES"<<endl ;
  }
  else {
    cout <<"NO"<<endl ;
  }
  
  return 0 ;
}

Measured memory_bytes: 256
// ITP1_8_C putcharは出力しちゃう。
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
  std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
  }
}

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

    map<char,int> kind;
    for(int i=0;i<26;i++){
        char a=char(97+i);
        kind[a]=0;
    }
    char ch;
    while(cin>>ch){
        if('A'<=ch and ch<='Z')ch+='a'-'A';
        if(kind.count(ch)==1){
            kind[ch]+=1;
        }else continue;
    }
    for (auto p : kind) {
        cout << p.first << " : " << p.second << endl;
    }   
    return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int t[200005];
struct ff{
    int l,r;
    bool operator<(const ff &b)const{
        return l!=b.l?l<b.l:r>b.r;
    }
}a[200005];
priority_queue<int,vector<int>,greater<int> >q;
int main(){
    int n,m;
    cin>>n>>m;
    int i;
    for(i=1;i<=n;i++) cin>>a[i].l>>a[i].r;
    sort(a+1,a+n+1);
    int h=1,tt=m;
    for(i=1;i<=n;i++){
        q.push(a[i].r);
        if(h<=tt&&h<=a[i].l) h++;
        else{
            t[++t[0]]=q.top();
            q.pop();
        }
    }
    sort(t+1,t+t[0]+1);
    int ans=0;
    for(i=t[0];i>=1;i--){
        if(h<=tt&&t[i]<=tt)tt--;
        else ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define fast_cin() ios_base::sync_with_stdio(0)
#define smid ((i + j) >> 1)
#define lc (sidx * 2)
#define rc (lc + 1)

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

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

bool bit(int n, int i) { return (n >> i) & 1; }
int ceil(int a, int b) { return ceil(((ld)a) / b); }

int faltu;

const int mod = 1e9+7;
const ll inf = 4e18;
const ll ninf = -inf;
const int imax = 2e9 + 100;

ll check(ll a[], ll mid, ll k)
{
	for(int i = 1; i <= k; i++) {
		mid = (mid / a[i]) * a[i];
	}
	return mid;
}

int main()
{
	time_t t1, t2;
	t1 = clock();
	fast_cin();
	ll k;
	cin >> k;

	ll a[k + 1];
	for(int i = 1; i <= k; i++) {
		cin >> a[i];
	}

	ll lo = 1, hi = 1e14, mid, ans = -1;
	while(lo <= hi) {
		mid = (lo + hi) >> 1;
		ll rem = check(a, mid, k);
		if(rem >= 2) {
			ans = mid;
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}
	if(check(a, ans, k) != 2) {
		ans = -1;
	}
	ll low_ans = ans;

	lo = 1, hi = 1e14;
	ans = -1;
	while(lo <= hi) {
		mid = (lo + hi) >> 1;
		ll rem = check(a, mid, k);
		// trace(mid, rem);
		if(rem <= 2) {
			ans = mid;
			lo = mid + 1;
		} else {
			hi = mid - 1;
		}
	}

	if(check(a, ans, k) != 2) {
		ans = -1;
	}

	ll high_ans = ans;

	if(low_ans == -1) {
		cout << -1 << endl;
	} else {
		cout << low_ans << ' ' << high_ans << endl;
	}

	t2 = clock();
	cerr << "time taken: " << t2 - t1 << endl;
	return 0;
}

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

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

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

    int len = s.length() / 2 - 1;
    while (true)
    {
        bool f = true;
        for (int i = 0; i < len; i++)
        {
            if (s[i] != s[i + len])
            {
                f = false;
                len--;
                break;
            }
        }
        if (f)
        {
            cout << (len * 2) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<double, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int a[202020][61];

int main() {

	int n;
	ll k;
	cin >> n >> k;
	rep(i, n){
		cin >> a[i][0];
		a[i][0]--;
	}
	rep(i, 60)rep(j, n)a[j][i + 1] = a[a[j][i]][i];
	int town = 0;
	rep(i, 61)if ((k >> i) & 1)town = a[town][i];
	cout << town + 1 << endl;

}

Measured memory_bytes: 51296
S = gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
T = gets.chomp              # 文字列。chompを付けないと改行文字がついてくる

S.freeze
T.freeze

wk = T[0...T.length-1]

if S == wk then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14288