akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define int long long
 
#define Vanya Unstoppable
 
using namespace std;

const int N = 2e5 + 7, M = 1e9 + 7;

int add(int a, int b) {
    a += b;
    if (a >= M) a -= M;
    if (a <= 0) a += M;
    return a;
}

int mul(int a, int b) {
    return a * (long long)b % M;
}

int binPow(int a, int n) {
    if (!n) return 1;
    if (n % 2 == 1) {
        return mul(a, binPow(a, n - 1));
    } else {
        int val = binPow(a, n / 2);
        return mul(val, val);
    }
}

int inv(int n) {
    return binPow(n, M - 2);
}

int fac[N];

int C(int n, int k) {
    return mul(fac[n], inv(mul(fac[k], fac[n - k])));
}

int f(int n, int m) {
    return C(n + m - 2, n - 1);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    fac[0] = 1;
    for (int i = 1; i < N; ++i) {
        fac[i] = mul(fac[i - 1], i);
    }
    
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    
    int ans = 0;
    for (int i = b + 1; i <= m; ++i) {
        int x = f(n - a, i), y = f(a, m - i + 1);
        int val = mul(x, y);
        ans = add(ans, val);
    }
    
    cout << ans;
}


Measured memory_bytes: 5192
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
#include<unordered_map>
#define MAXN 100010
#define ll long long

using namespace std;

int N, M, K;


int cnt[4*MAXN][26];

int color[MAXN];
int color_num[MAXN];

vector<int> neigh[MAXN];
vector<int> block[MAXN]; 
int A, B, C, D;
map<pair<int, int>, bool> neigh_map;
map<pair<int, int>, bool> block_map; 
int nxt_color;

void dfs(int u)
{
	color[u] = nxt_color;
	for(int v: neigh[u])
	{
		if(color[v] == -1)
			dfs(v);
	}
}

int main()
{
	cin>>N>>M>>K;
	nxt_color = 1;
	for(int i = 0; i < M; ++i)
	{
		cin>>A>>B;
		neigh[A].push_back(B);
		neigh[B].push_back(A);
		neigh_map[make_pair(A, B)] = true;
		neigh_map[make_pair(B, A)] = true;
	}
	for(int i = 0; i < K; ++i)
	{
		cin>>C>>D;
		block[C].push_back(D);
		block[D].push_back(C);
		block_map[make_pair(C, D)] = true;
		block_map[make_pair(D, C)] = true;
	}
	for(int i = 1; i <= N; ++i)
		color[i] = -1;
	for(int u = 1; u <= N; ++u)
	{
		if(color[u] == -1)
		{
			dfs(u);
			++nxt_color;
		}
	}
	memset(color_num, 0, sizeof(color_num));
	for(int u = 1; u <= N; ++u)
	{
		color_num[color[u]]++;
	}
	for(int u = 1; u <= N; ++u)
	{
		int ans = color_num[color[u]] - 1 - (int)neigh[u].size();
		for(int v: block[u])
		{
			if(color[u] == color[v])
				--ans;
		}
		cout<<ans<<" ";
	}
} 

Measured memory_bytes: 38272
import sys

N = int(input())
A = [0] + list(map(int, sys.stdin.readline().rsplit()))

res = []
M = 0
tmp = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    cnt = 0
    for j in range(i, N + 1, i):
        cnt += tmp[j]
    if cnt % 2 != A[i]:
        tmp[i] = 1
        M += 1
        res.append(i)

print(M)
if M != 0:
    print(*res[::-1])


Measured memory_bytes: 18792
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+5;
char s[N];
int main()
{
    int n;
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=2;i<=n;i++){
        if(s[i-1]==s[i]){
            printf("%d %d\n",i-1,i);
            return 0;
        }
        if(i>=3&&s[i-2]==s[i]){
            printf("%d %d\n",i-2,i);
            return 0;
        }
    }
    printf("-1 -1\n");
}


Measured memory_bytes: 256
// new day,new strength,new thougts
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) int((c).size())
#define REP(i,n)  for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=int(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FORD(i,a,b) for(int i=int(a);i>=int(b);i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;
const ll mod=1e9+7;

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

int main(){
    ll q;cin>>q;
    while(q--){
	ll a,b,c,d;cin>>a>>b>>c>>d;
	bool ans=0;
	if(a>=b && d>=b && c>=b){
	    ans=1;
	}
	if(a>=b && d>=b && c<b){
	    ll rem=d%b;
	    ll g=gcd(rem,b);
	    ll x=a%g;
	    ll mx=(x-g+b)%b;
	    if(mx<=c)
		ans=1;
	}
	cout<<(ans?"Yes":"No")<<endl;
    }
}


Measured memory_bytes: 256
s = gets.chomp.split("")
arr = Array.new()
s.size.times do |i|
  if s[i] == "0"
    arr.push("0")
  elsif s[i] == "1"
    arr.push("1")
  else
    arr.delete_at(-1)
  end
end
ans = arr.join("")
puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int a,b;cin >> a >> b;

    if(a<= 8 && b <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    } 

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int MOD = 1000000007;

ll pow(ll a, ll b) {
    ll ans = 1;

    for(int i=0;i<b;i++) { 
        ans *= a;
        ans %= MOD;
    }

    return ans;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    vector<int> A(N);
    for(int i=0;i<N;i++) {
        cin >> A.at(i);
    }

    int p=1e6+5;
    vector<int> P(p);
    int tmp, cnt;
    for(int i=0;i<N;i++) {
        tmp = A.at(i);
        for(int j=2;j*j<=tmp;j++) {
            cnt = 0;
            while(tmp%j==0) {
                tmp /= j;
                cnt++;
            }
            P.at(j) = max(cnt, P.at(j));
        }
        if(tmp>1) {
            P.at(tmp) = max(1, P.at(tmp));
        }
    }

    ll L=1;
    for(int i=0;i<p;i++) {
        L *= pow(i, P.at(i));
        L %= MOD;
    }

    ll ans=0;
    for(int i=0;i<N;i++) {
        ans += ( (L%MOD) * modinv(A.at(i), MOD) % MOD);
        ans %= MOD;
    }
    ans %= MOD;

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 4224
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  string S=in<string>();
  int e=0,o=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='0') e++;
    else o++;
  }
  
  cout << 2*min(e,o) << endl;
  return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        String s = br.readLine().trim();
        String t = br.readLine().trim();
        char [] tarray = t.toCharArray();
        List<String> sList = new ArrayList<String>();
        List<String> tList = new ArrayList<String>();
        for (int i=0; i<s.length(); i++){
            sList.add(s.substring(i,i+1));
        }
        for (int i=0; i<t.length(); i++){
            tList.add(t.substring(i,i+1));
        }

        Collections.sort(sList);
        Collections.sort(tList);
        Collections.reverse(tList);

        String comps = "";
        String compt = "";


        for (String ss :sList){
            comps += ss;
        }

        for (String st :tList){
            compt += st;
        }

        if (comps.compareTo(compt) < 0){
            System.out.println("Yes");

        }else{
            System.out.println("No");
        }


    }

}



Measured memory_bytes: 37336
#  価値が vi 重さが wi であるような N 個の品物と、容量が W のナップザックがあります。次の条件を満たすように、品物を選んでナップザックに入れます：
#     選んだ品物の価値の合計をできるだけ高くする。
#     選んだ品物の重さの総和は W を超えない。
# 価値の合計の最大値を求めてください。 

N, W = map(int, input().split())

value = [0] * N
weight = [0] * N
for i in range(N):
    value[i], weight[i] = map(int, input().split())

# print(w)


# dpテーブル（縦は個数N, 横は価値Wの最大値（多めに取ればよろし）
# このように、横軸に価値Wを全部とってもとめちゃえとするのがコツと思われる

# dp[i+1][w] = i 番目までの品物の中から重さが w を超えないように選んだときの、価値の総和の最大値
# i番目の品物（value[i], weight[i]）が選ばれるということは、w - weight[i] > 0であるときは選べば良くて、
# dp[i][w - weight[i]] + value[i]
# そうでないときは更新できない。

dp = [[0] * 10010 for _ in range(110)] # 10余分にとった

for i in range(N):
    for w in range(W+1):
        if w >= weight[i]:
            dp[i+1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 42568
#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	intsize ll size = trunc(log10(num)) + 1
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

ll gcd (ll a, ll b) { return b ? gcd (b, a % b) : a; }
ll lcm (ll a, ll b) { return a / gcd(a, b) * b; }

//code start from here 

int main() {
	fast;
	read(a)
	read(b)
	read(c)
	ll m=min(b,c);
	if(m==b)
	m--;
	cout<<floor(a*m/double(b));
	return 0;
}

//ends here

Measured memory_bytes: 3800
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        List<Long> abcde = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            abcde.add(sc.nextLong());
        }
        Long min = Collections.min(abcde);
        System.out.println((long) Math.ceil((double) n / min) + 4);
    }

}


Measured memory_bytes: 23760
al = list("abcdefghij")
n = int(input())
w = [0 for i in range(n)]
w[-1] = -1
la = list(range(n))
while (w != la):
  w[-1] += 1
  for i in range(n-1):
    i = n-i-1
    z = False
    for j in range(n):
      if i != j and w[j] == w[i]:
        z = True
    if (not z) and (not (w[i]-1 in w)):
      w[i] = 0
      w[i-1] += 1
  c = [al[w[i]] for i in range(n)]
  print("".join(c))

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

using namespace std;
typedef long long ll;

int main(){
    int k = 0;
    int temp;
    ll sum = 0;
    cin >> k;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            for(int c = 1; c <= k; c++){
                temp = __gcd(a, b);
                temp = __gcd(temp, c);
                sum += temp;
            }
        }
    } 
    cout << sum << endl;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    ll d = a - b;

    ll ok = 1e9, ng = 0;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        
        ll cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt += (max(h[i] - b * mid, 0LL) + d - 1) / d;
        }
        
        (cnt <= mid ? ok : ng) = mid;
    }
    cout << ok << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int A = 0;
    int B = 0;
    int C = 0;
    int ans = 0;
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d %d %d", &A, &B, &C);
    
    /* 入力を受け付ける部分終わり*/
    
    
    /* 何か処理*/
    ans = A*B;
    
    if(A+B+C >= 22){
      /* 真の場合の処理 */
      printf("bust");
    }else{
      /* 偽の場合の処理 */
      printf("win");
    }
    
    for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    }
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
    
    /* 出力する部分*/
    
    
    
    return 0;
}






Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  char s[2000];
  map<char, ll> ans;
  while (true) {
    cin.getline(s, sizeof(s));
    if (s[0] == 0) break;
    rep (i, 2000) {
      if (s[i] == 0) break;
      char tmp = s[i];
      if ('A' <= tmp and tmp <= 'Z') tmp += 'a' - 'A';
      if ('a' <= tmp and tmp <= 'z') ans[tmp]++;
    }
  }
  for (char i = 'a'; i <= 'z'; i++) {
    cout << i << " : " << ans[i] << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3180
S=input()
S1=int(S[:2])
S2=int(S[2:])

if (S1 == 0 and S2 == 0) or (S1 >12 and S2 > 12):
    print('NA')
elif S1 == 0 or S1 > 12:
  if S2 >=1 and S2 <=12:
    print('YYMM')
  else:
    print('NA')
elif S2 == 0 or S2 > 12:
  if S1 >=1 and S1 <=12:
    print('MMYY')
  else:
    print('NA')
else:
    print('AMBIGUOUS')


Measured memory_bytes: 3060
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArr = br.readLine().split(" ");
        int w = Integer.parseInt(strArr[0]);
        int h = Integer.parseInt(strArr[1]);
        int x = Integer.parseInt(strArr[2]);
        int y = Integer.parseInt(strArr[3]);
        int r = Integer.parseInt(strArr[4]);

        if ( (x - r >= 0 && x + r <= w) && (y - r >= 0 && y + r <= h) ) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

int H,W;
char fi[1010][1010];
mint dp[1010][1010] = {0};

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

int H,W;
cin >> H >> W;
rep(h,H) rep(w,W) cin >> fi[h][w];

dp[0][0] = 1;

for(int h = 0; h < H; ++h) {
    for(int w = 0; w < W; ++w) {
        if(h+1 < H && fi[h+1][w] == '.') dp[h+1][w] += dp[h][w];
        if(w+1 < W && fi[h][w+1] == '.') dp[h][w+1] += dp[h][w];
    }
}
cout << dp[H-1][W-1] << endl;
return 0;
}

Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define debug(x) cout << #x << ": " << x << endl

using ll = long long;
//#define int ll


//**********

int N;

signed main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
   
    cin >> N;
    int a[N];
    REP(i,N) cin >> a[i];
    sort(a, a+N, greater<int>());
    
    int Alice = 0;
    int Bob = 0;
    
    REP(i,N){
        if(i%2==0) Alice += a[i];
        else Bob += a[i];
    }
    int ans = Alice - Bob;
    
    printf("%d\n",ans);
    
    return 0;
}






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

using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    int cnt_lr = 0;
    int cnt_rl = 0;
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        if (S[i] == S[i + 1]) {
            ans++;
        } else if (S[i] == 'L' and S[i + 1] == 'R') {
            cnt_lr++;
        } else if (S[i] == 'R' and S[i + 1] == 'L') {
            cnt_rl++;
        }
    }
    int cnt = 0;
    while (K > 0 and cnt_lr > 0 and cnt_rl > 0) {
        cnt += 2;
        K--;
        cnt_lr--;
        cnt_rl--;
    }
    if (K > 0 and cnt_lr > 0) {
        cnt++;
        K--;
    }
    if (K > 0 and cnt_rl > 0) {
        cnt++;
        K--;
    }
    ans += cnt;
    cout << ans << endl;
    return 0;
}


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

int main() {
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size() <= k){
		cout << s;
	} else {
		for(int i = 0; i < k; i++){
			cout << s[i];
		}
		cout << "...";
	}
}

Measured memory_bytes: 3604
#include<stdio.h>
int n[5],sum=0;
int main()
{
	scanf("%d %d %d",&n[1],&n[2],&n[3]);
	sum=3;
	for(int i=1;i<=3;i++)
	{
		for(int j=0;j<=i-1;j++)

		{
				if(n[i]==n[j]){
				sum--;
				break;
							}
		}
	}
	printf("%d",sum);
	return 0;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=100010;
vi gOut[Nmax],gIn[Nmax];
int type[Nmax];
void dfs(int v,int t,vi&idx){
	if(type[v]!=-1)return;
	idx.PB(v);
	type[v]=t;
	for(auto to:gOut[v])
		dfs(to,(t+1)%3,idx);
	for(auto to:gIn[v])
		dfs(to,(t+2)%3,idx);
}

signed main(){
	ONE(type);
	int n=read(),m=read();
	REP(_,m){
		int a=read()-1,b=read()-1;
		gOut[a].PB(b);
		gIn[b].PB(a);
	}
	int ans=m;
	REP(i,n)if(type[i]==-1)
		if(!gOut[i].empty()&&!gIn[i].empty()){
			vi idx;
			dfs(i,0,idx);
			int cnt[3]{},es=0;
			bool perf=false;
			for(auto j:idx){
				cnt[type[j]]++;
				for(auto to:gOut[j]){
					es++;
					if((type[j]+1)%3!=type[to])
						perf=true;
				}
			}
			ans-=es;
			if(perf){
				ans+=Sq(cnt[0]+cnt[1]+cnt[2]);
			}else{
				REP(k,3)
					ans+=cnt[k]*cnt[(k+1)%3];
			}
		}
	print(ans);
}


Measured memory_bytes: 19832
import sys

def count_combination(n):
    count = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                l = n - (i + j + k)
                if l >= 0 and l < 10:
                    count += 1
    return count

for line in sys.stdin:
    n = int(line)
    print(count_combination(n))

Measured memory_bytes: 7648
R,G,B,N = map(int,input().split())
rmax = N // R
gmax = N // G
bmax = N // B
ans = 0
for r in range(rmax+1):
    for g in range(gmax+1):
        if (N - (R*r + G*g)) % B == 0 and 0 <= (N - (R*r + G*g) )// B <= bmax: 
            ans += 1
print(ans)

Measured memory_bytes: 40556
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, m, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,n) cin >> a[i];
    int s = 0;
    FOR(i,1,n) s += a[i];
    if (s % (4 * m) == 0) s = s / (4 * m) - 1;
    else s = s / (4 * m);
    int cnt = 0;
    FOR(i,1,n)
        if (a[i] > s) cnt++;
    if (cnt >= m) cout << "Yes";
    else cout << "No"; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n;
    cin >> n;
    vector<int> takoyaki(n,0);
    repi(i,n,0){
        cin >> takoyaki[i];
    }
    ll ans = 0;
    repi(i,n,0){
        repi(j,n,i + 1){
            ans += takoyaki[i] * takoyaki[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    for(int i=1;i<=5;i++) {
	    	int k=sc.nextInt();
	    	if(k==0) {
	    		System.out.println(i);
	    		break;
	    	}

	    }
	}
}


Measured memory_bytes: 35676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::vector<long long> X, std::vector<long long> Y, std::vector<long long> Z)
{
    UnionFind uni(N);

    for (int i = 0; i < M; i++)
    {
        uni.Union(X[i] - 1, Y[i] - 1);
    }

    ll cnt = 0;

    for (int i = 0; i < N; i++)
    {
        if (uni.find(i) == i)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> X(M);
    std::vector<long long> Y(M);
    std::vector<long long> Z(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &X[i]);
        scanf("%lld", &Y[i]);
        scanf("%lld", &Z[i]);
    }
    solve(N, M, std::move(X), std::move(Y), std::move(Z));
    return 0;
}


Measured memory_bytes: 3456
L, R = map(int,input().split(' '))


ans = 10 ** 10


for i in range(L, min(L + 2019, R), 1):
  for j in range(L+1, min(L + 2019, R) + 1):
    ans = min(ans, (i * j) % 2019)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    vector<int> A(5);
    REP(i,5)cin >> A[i];
    REP(i,5){
        if(A[i] != i+1){
            cout << i+1 << "\n";
        }
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> a(n+1, 0), b(m+1, 0);
    REP(i, n){
        ll x;   cin >> x;
        a[i+1] = a[i]+x;
    }
    REP(i, m){
        ll x;   cin >> x;
        b[i+1] = b[i]+x;
    }

    ll res=0;
    REP(i, n+1){
        ll times = a[i];
        ll bc = upper_bound(ALL(b), k-times) - b.begin();
        if(0<bc)
            res = max(res, i+bc-1);
    }
    cout << res << endl;
}


Measured memory_bytes: 6380
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;
const ll INF = (ll)1e12;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

    vector<pair<ll,ll>> v;

    REP(i,n) {
        P_ii p;p.second=1;cin >> p.first;;
        v.push_back(p);
    }

    REP(i,m) {
        P_ii p;cin >> p.second >> p.first;
        v.push_back(p);
    }

    sort(all(v),greater<>());

    ll ans=0;
    int count = 0;
    REP(i,v.size()){
        if(count + v[i].second >= n) {
            ans += v[i].first * (n-count);
            break;
        } else {
            ans += v[i].first * v[i].second;
            count += v[i].second;
        }
    }

    pl(ans)

}

Measured memory_bytes: 6512
using System;
class Program
{
	static void Main(string[] args)
	{
		int a = int.Parse(Console.ReadLine());
		int b = 1;
		if(a < 600){
			b = 8;
		}
		else if(a < 800) {
			b = 7;
		}
		else if(a < 1000) {
			b = 6;
		}
		else if(a < 1200) {
			b = 5;
		}
		else if(a < 1400) {
			b = 4;
		}
		else if(a < 1600) {
			b = 3;
		}
		else if(a < 1800) {
			b = 2;
		}
		else {
			b = 1;
		}
		Console.WriteLine(b);
	}
}

Measured memory_bytes: 27516
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define ff first 
#define endl "\n"
#define ss second 
#define li list<int>
#define vi vector<int>
#define ll long long int
#define pii pair<int,int>
#define vii vector<pair<int,int> >
#define mp make_pair
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define custom  pair<int,pair<int,int> >
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; 
#define mod 1000000007
#define inf 1e9 + 1
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll weight;
    cin>>weight;
    ll w[n];
    ll v[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    ll dp[n+1][100001];
    memset(dp,0,sizeof dp);
    for(int j=0;j<100001;j++){
        dp[0][j]=inf;
    }
    for(int i=0;i<=n;i++){
        dp[i][0]=0;
    }
    for(int i=1;i<n+1;i++){
        for(int j=1;j<100001;j++){
            dp[i][j]=dp[i-1][j];
            if(v[i-1]<=j){
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
            }
        }
    }
    int ans;
    for(int j=0;j<=100000;j++){
        if(dp[n][j]<=weight){
            ans=j;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 82524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

void numset()
{

}

int main()
{
    int N, Q,s,t;
    cin >> N >> Q;
    vint a(N), b(N), p(Q + 1), x(Q + 1),num(N+1);//1-indexed
    vector<ull> ans(N + 1);
    vector<set<int>> connect(N + 1); //子

    rep2(i, 1, N)
    {
        cin >> s >> t;
        a[i] = s;
        b[i] = t;
        connect[s].insert(t);
        connect[t].insert(s);
        //      parent[t] = s;
    }
    rep2(i,1,Q+1)
    {
        cin >> p[i] >> x[i];
        ans[p[i]] += x[i];
    }
    vector<bool> arrived(N + 1);
    arrived[1] = true;
    queue<int> q;
    for (int k : connect[1])
    {
        ans[k] += ans[1];
        q.push(k);
    }
    while (!q.empty())
    {
        int j = q.front();
        arrived[j] = true;
        q.pop();
        //       ans[j] += ans[parent[j]];
        for(int k:connect[j])
        {
            if(!arrived[k])
            {
                ans[k] += ans[j];
                q.push(k);
            }
        }
    }
    rep2(i,1,N+1)
    {
        cout << ans[i] << " ";
    }

    return 0;
}

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

int main()
{
  long long a;
  std::cin >> a;
  long takahashi_money = 100;
  int count = 0;
  while(takahashi_money < a)
  {
    takahashi_money = takahashi_money + takahashi_money / 100;
    count++;
  }
  std::cout << count << std::endl;
  
  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k; cin >> n >> k;

    ll ans = n % k;

    ans = min(ans, abs(n % k - k));

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#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(nullptr);
  string s;cin>>s;vector<int> v(2,0);
  rep(i,s.size()) v[s[i]-'0']++;
  if(v[0]==0||v[1]==0) print(0);
  else {ll ans=2*min(v[0],v[1]);print(ans);}
  return 0;
}


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

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


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

  int N, Q;
  cin >> N;
  map<int,int> as;
  i64 sum = 0;
  F0R(i, N) {
    int a;
    cin >> a;
    as[a]++;
    sum += a;
  }

  cin >> Q;
  F0R(i, Q) {
    int b, c;
    cin >> b >> c;
    sum += (i64)(c - b) * as[b];
    as[c] += as[b];
    as[b] = 0;
    cout << sum << newl;
  }
}
#endif


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

int main()
{
	cin.tie(0);
	cout.tie(0);
	int a,b,x,y;
	cin>>x>>y;
	if(y%2!=0||y>4*x)
	cout<<"No"<<endl;
	else
	{
		y/=2;
		b=y-x;
		a=x-b;
		if(b>=0&&a>=0)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
n, k = list(map(int, input().split(' ')))
lens = {0: 1}
for i in range(1, 51):
  lens[i] = lens[i-1] * 2 + 3

memo = {}
def sumP(level, index):
  key = (level, index)
  if key in memo:
    return memo[key]
  if level == 0:                       # |P or P|
      memo[key] = int(index == 1)
  elif index < lens[level] // 2 + 1:   # |Bxxxxxxx|xxxxxPxxxxxxxxxxB
    memo[key] = sumP(level-1, index-1)
  elif index <= lens[level] // 2 + 1:  # |BxxxxxxxxxxxxP|xxxxxxxxxxB
    memo[key] = 1 + sumP(level-1, lens[level-1])
  else:                                # |BxxxxxxxxxxxxPxxxxxxxx|xxB
    memo[key] = sumP(level-1, lens[level-1]) + 1 + sumP(level-1, min(lens[level-1], index-lens[level-1]-2))
  return memo[key]

print(sumP(n, k))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N,P;
    cin>>N>>P;
    int ans=1;
    if(N==1) {
        cout << P << endl;
        return 0;
    }else{
        for(int i=2;i<=P;i++){
            int cou=1;
            for(int j=0;j<N;j++){
                cou*=i;
                if(cou>P) {
                    cout << ans << endl;
                    return 0;
                }
            }
            if(P%cou==0) ans=i;
        }
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)

ab = [list(map(int, input().split())) for _ in range(3)]
for i in range(len(ab)):
    a = ab[i][0]
    b = ab[i][1]
    d[a] += 1
    d[b] += 1
x = []
for v in d.values():
    x.append(v)
if x.count(1) == 2 and x.count(2) == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var A = one[0];
	var B = one[1];
	var C = one[2];
	var D = one[3];
	var list = new Array(101).fill(0);
	for(var i = A; i <= B; i++){
		list[i] += 1;
	}
	for(var i = C; i <= D; i++){
		list[i] += 1;
	}
	var output = 0;
	for(var i = 0; i < 101; i++){
		if(list[i] == 2){
			output++;
		}
	}
	myout(Math.max(output - 1,0));
}


Measured memory_bytes: 11724
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    string s;
    cin >> s;
    int n = (int) s.size();
    if (!(n & 1)) cout << "No\n";
    else {
        string t = s;
        reverse(t.begin(), t.end());
        if (t == s) {
            string s1 = s.substr(0, (n - 1) / 2), s2 = s.substr((n + 1) / 2);
            string t1 = s1, t2 = s2;
            reverse(t1.begin(), t1.end());
            reverse(t2.begin(), t2.end());
            if (s1 == t1 && s2 == t2) cout << "Yes\n";
            else cout << "No\n";
        }  
        else cout << "No\n";
    }
}

Measured memory_bytes: 256
// Problem : A - Poor
// Contest : AtCoder Beginner Contest 155
// URL : https://atcoder.jp/contests/abc155/tasks/abc155_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inf LLONG_MAX
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        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);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0]==a[1] && a[0]!=a[2])
  {
    cout<<"Yes";
  }
  else if(a[1]==a[2] && a[1]!=a[0])
  {
    cout<<"Yes";
  }
  else
    cout<<"No";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
import sys
n = int(input())
task = []
for i in range(n):
    task.append(list(map(int, input().split())))
task = sorted(task, key=lambda x:x[1])
time = 0
for i in range(n):
    time += task[i][0]
    if time > task[i][1]:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 55256