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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N, M;
  ll K;
  std::cin >> N >> M >> K;

  std::vector<ll> A(N), B(M);
  rep(i, N) {
    std::cin >> A[i];
  }
  rep(i, M) {
    std::cin >> B[i];
  }

  std::vector<ll> sumA(N + 1), sumB(M + 1);
  sumA[0] = 0;
  sumB[0] = 0;
  rep(i, N) {
    sumA[i + 1] = sumA[i] + A[i];
  }
  rep(i, M) {
    sumB[i + 1] = sumB[i] + B[i];
  }

  int ans = 0;
  rep(i, N + 1) {
    if(sumA[i] > K) break;
    ans = std::max(ans, i + (int)(std::upper_bound(sumB.begin(), sumB.end(), K - sumA[i]) - sumB.begin()) - 1);
  }
  std::cout << ans << '\n';
}


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

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


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (1e9 + 7);

const int MAX_N = 112345;
ll dp[MAX_N];
bool broken[MAX_N];

int main2() {
  CLR(dp, 0);
  CLR(broken, 0);

  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int a = nextInt();
    broken[a] = true;
  }
  dp[0] = 1;
  for (int i = 1; i <= N; i++) {
    if (broken[i]) continue;
    dp[i] = dp[i-1] + (i-2 >= 0 ? dp[i-2] : 0);
    dp[i] %= MOD;
  }
  cout << dp[N] << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
    int a,b;
    cin >> a >> b;
    if(a >=10 || b >=10)cout << -1 << endl;
    else cout << a * b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 45

int dp[N];

int fib(int n){
  if(n==0 || n==1){
    return dp[n]=1;
  }
  if(dp[n]!=-1){
    return dp[n];
  }
  return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;

  scanf("%d",&n);
  for(i=0;i<N;i++){
    dp[i]=-1;
  }
  printf("%d\n",fib(n));

  return 0;
}


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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
#define R0F(i, a) for (int i = a; i >= 0; i--)
#define GO(i, a) for (auto i : a)

#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
typedef vector<vi64> vvi64;
typedef vector<vpi64> vvpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, +30, +31, +30, +31, +31, +30, +31, +30, +31};
const int rm[] = {+1, +4, +5, +9, +10, +40, +50, +90, +100, +400, +500, +900, +1000};

int Get (int numero) {
  int ans = -1;
  while (numero) {
    ans = numero % 10;
    numero /= 10;
  }
  return ans;
}

int g [10][10];

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  i64 tot = 0;
  FOR (i, 1, n + 1) {
    int primeiro = Get (i);
    int ultimo = i % 10;
    g[primeiro][ultimo]++;
  }
  FOR (i, 1, n + 1) {
    int primeiro = Get (i);
    int ultimo = i % 10;
    tot += g[ultimo][primeiro];
  }
  cout << tot << '\n';
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		if(c.equals("a") || c.equals("i") || c.equals("u") || c.equals("e") || c.equals("o")) {
			System.out.println("vowel");
		}else {
			System.out.println("consonant");
		}
	}
}


Measured memory_bytes: 21716
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;


int main(void) {

    vector<int> a(5);
    for (int i = 0; i < 5; ++i) {
        cin>>a[i];
    }
    int e; cin>>e;

    if(a[4]-a[0]>e){
        cout<<":("<<endl;
    } else{
        cout<<"Yay!"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int n, m, s, i;
    int taro[1000];
    int hana[1000];
    int t_score, h_score, x;
    int t_card, h_card;
 
    while(1){
        // テ」ツつォテ」ツδシテ」ツδ嘉ヲツ楪堙ヲツ閉ーテ」ツ?ョテ・ツ?・テ・ツ環?
        scanf("%d %d", &n, &m);
        if(n==0 && m==0)break;
 
        // テ・ツ青暗ィツィツ暗ァツつケテヲツ閉ーテ」ツ?ィテヲツ個?」ツ?。テ」ツつォテ」ツδシテ」ツδ嘉」ツ?ョテ・ツ按敕ヲツ慊淌・ツ個?
        t_score=0;
        h_score=0;
        for(i=0;i<1000;i++){
            taro[i]=0;
            hana[i]=0;
        }
        // テ・ツ?・テ・ツ環崚」ツ?凝」ツつ嘉」ツ??ヲツ個?」ツ?。テ」ツつォテ」ツδシテ」ツδ嘉」ツ?ィテァツつケテヲツ閉ーテ」ツ?ョテ・ツ青暗ィツィツ暗」ツつ津ヲツアツづ」ツつ?」ツつ?
        for(i=0;i<n;i++){
            scanf("%d", &s);
            taro[s]=1;
            t_score+=s;
        }
        for(i=0;i<m;i++){
            scanf("%d", &s);
            hana[s]=1;
            h_score+=s;
        }
 
        // テァツつケテヲツ閉ーテ」ツ?ョテ・ツキツョ(テ」ツ?ョテ・ツ債甘・ツ按?テ」ツつ津ヲツアツづ」ツつ?」ツ?ヲテ」ツ?甘」ツ??
        x = (h_score - t_score) / 2;
        // テ、ツコツ、テヲツ渉崚・ツ?凖ィツ」ツ愿」ツ?ョテ」ツつォテ」ツδシテ」ツδ嘉」ツ?古ィツヲツ凝」ツ?、テ」ツ?凝」ツつ嘉」ツ?ェテ」ツ?凝」ツ?」テ」ツ?淌・ツ?エテ・ツ青暗」ツ?ッ -1
        t_card=-1;
        h_card=-1;
 
        // テ、ツコツ、テヲツ渉崚・ツ?凖ィツ」ツ愿」ツ?ョテ」ツつォテ」ツδシテ」ツδ嘉」ツつ津ヲツ篠「テ」ツ??0 ~ 100 テ」ツ?セテ」ツ?ァテ」ツ?ョテゥツ鳴?
        for(i=0;i<=100;i++){
            // テァツつケテヲツ閉ーテ」ツ?ョテ・ツキツョテ」ツつ津・ツ按ゥテァツ板ィテ」ツ?療」ツ?ヲテ」ツ??、ツコツ、テヲツ渉崚・ツ?凖ィツ」ツ愿」ツ?ョテ」ツつォテ」ツδシテ」ツδ嘉」ツ?ァテ」ツ?づ」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツつ津・ツ按、テヲツ鳴ュ
            if(0<=i+x && taro[i]==1 && hana[i+x]==1){
                // テヲツ敖。テ、ツサツカテ」ツ?ォテ・ツ青暗」ツ??・ツ?凖ィツ」ツ愿」ツつ津ィツィツュテ・ツョツ堙」ツ?療」ツ?ヲテ」ツ??」ツδォテ」ツδシテ」ツδ療」ツつ津ヲツ環愿」ツ?妥」ツつ凝」ツ??
                t_card=i;
                h_card=i+x;
                break;
            }
        }
        // テァツつケテヲツ閉ーテ」ツ?ョテ・ツキツョテ」ツ?古・ツ・ツ?ヲツ閉ーテ」ツ?ァテ」ツ?づ」ツつ凝」ツ?凝」ツ??テ、ツコツ、テヲツ渉崚・ツ?凖ィツ」ツ愿」ツ?ョテ」ツつォテ」ツδシテ」ツδ嘉」ツ?古ィツヲツ凝」ツ?、テ」ツ?凝」ツつ嘉」ツ?ェテ」ツ?凝」ツ?」テ」ツ?淌・ツ?エテ・ツ青暗」ツ?ッテ」ツ??-1 テ」ツ?ィテ・ツ?コテ・ツ環?
        if((h_score - t_score) % 2!=0 || t_card==-1){
            printf("-1\n");
        // テ、ツコツ、テヲツ渉崚・ツ?凖ィツ」ツ愿」ツ?ョテ」ツつォテ」ツδシテ」ツδ嘉」ツ?古」ツ?づ」ツつ凝・ツ?エテ・ツ青暗」ツ?ッテ」ツ??」ツ?敕」ツつ古」ツつ津・ツ?コテ・ツ環?
        }else{
            printf("%d %d\n", t_card, h_card);
        }
 
    }
    return 0;
}

Measured memory_bytes: 1048
use std::io;
use std::io::prelude::*;

struct UnionFindTree(Vec<usize>);
impl UnionFindTree {
    fn new(n: usize) -> UnionFindTree {
        UnionFindTree((0..n).collect())
    }

    fn find(&mut self, n: usize) -> usize {
        let p = self.0[n];
        if n != p {
            self.0[n] = self.find(p);
        }
        self.0[n]
    }

    fn union(&mut self, x: usize, y: usize) {
        let x = self.find(x);
        let y = self.find(y);
        self.0[x] = y;
    }
}

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();

    let line0 = lines.next().unwrap().unwrap();
    let n = line0.split_whitespace().next().unwrap().parse().unwrap();

    let mut uft = UnionFindTree::new(n);

    for l in lines.map(Result::unwrap) {
        let mut words = l.split_whitespace();
        let com = words.next().unwrap().parse().unwrap();
        let x = words.next().unwrap().parse().unwrap();
        let y = words.next().unwrap().parse().unwrap();
        match com {
            0 => uft.union(x, y),
            1 => println!("{}", if uft.find(x) == uft.find(y) { 1 } else { 0 }),
            _ => ()
        }
    }
}



Measured memory_bytes: 5280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    string s,t; cin >> s >> t;
    int len = s.length();
    int ans = 0;
    for(int i = 0; i < len; i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3848
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))
"""
A,B = nums()
P,Q,R = nums()

first_distance = P * B
pre_runned = (B - A) * Q
time = B + (first_distance - pre_runned) / (R + Q)
print(time)
"""
"""
N = num()
randoms = nums()
ans = 0
for i in range(N):
    today = randoms[i]
    if i == 0:
        continue
    if today > randoms[i-1]:
        ans += 1
print(ans)
"""

N = num()
members = []
for i in range(N):
    members.append(input())

ans = members.count("E869120")
print(ans)


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

int main() {

	long long n;
	cin >> n;

	string dog_name = "";

	while(n > 0) {
		--n;
		dog_name += (char)('a' + (n%26));  
		n /= 26;                       
	}

	reverse(dog_name.begin(), dog_name.end());

	cout << dog_name;

	return 0;
}


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

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  int n, a;
  cin >> n;
  map<int, int> mp;
  rep(i, n) {
    cin >> a;
    mp[a]++;
  }

  bool flag = true;
  for (int i = (n + 1) % 2 + 2; i <= n - 1; i += 2) {
    flag &= (mp[i] == 2);
  }

  if (!flag) {
    cout << 0 << endl;
    return 0;
  }

  mint ans = 1;
  rep(i, n / 2) ans *= 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7376
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N,A,B;
    cin >> N>>A>>B;
    ll P[N];
    ll ans=0;
    ll aa,bb,cc;
    aa=0;
    bb=0;
    cc=0;
    FOR(i,0,N-1){
      cin>>P[i];
      if(P[i]<=A){
        aa++;
      }else if(P[i]>B){
        cc++;
      }else{
        bb++;
      }

    }
    if(aa>bb){
      ans=bb;
    }else{
      ans=aa;
    }

    if(ans>cc){
      ans=cc;
    }

  cout<<ans<<endl;

  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

long long N;
vector<long long> a;

int main(){
    cin >> N;
    a.resize(3*N);
    rep(i,3*N) cin >> a[i];

    vector<ll>  dp1(3*N,0),dp2(3*N,0); // [0,i]での上位/下位N個の和

    {
        ll s = 0;
        rep(i,N) s += a[i];

        priority_queue<ll,vector<ll>,greater<ll>> q;  // 小さい順
        rep(i,N) q.push(a[i]);

        dp1[N-1] = s;
        for(int i=N;i<=2*N;i++){
            ll nxt = a[i];
            ll mn = q.top();
            if(mn < nxt) s = s + nxt - mn;
            dp1[i] = s;
            q.push(nxt);
            q.pop();
        }
    }
    {
        ll s = 0;
        for(int i=3*N-1;i>=2*N;i--) s+=a[i];
        priority_queue<ll> q;
        for(int i=3*N-1;i>=2*N;i--) q.push(a[i]);

        dp2[2*N] = s;
        for(int i=2*N-1;i>=N;i--){
            ll nxt = a[i];
            ll mx = q.top();
            if(mx > nxt) s = s + nxt - mx;
            dp2[i] = s;
            q.push(nxt);
            q.pop();
        }
    }


    ll ans = numeric_limits<long long>::min();
    for(int i=N-1;i<2*N;i++){
        ans = max(ans,dp1[i]-dp2[i+1]);
    }
    cout << ans << endl;
}


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

int solve(string s, ll k) {
    int ans = 1;
    rep(i, k){
        if(s[i] != '1'){
            ans = s[i] - '0';
            break;
        }
    }
    return ans;
}

int main(){
    string s;
    ll k;

    cin >> s >> k;
    cout << solve(s, k) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ; 
#define ll              long int
// #define cini(x)	        scanf("%lld",&x)
// #define cins(s)	        scanf("%s",s)
#define deb(x)          cout << (x) << "  " ;
#define out(x)          cout << (x) << endl ;
#define endl            '\n'
#define pb              push_back
#define mk              make_pair
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define loop(x,n,v)     for(ll v=x; v<n; v++)
#define loopr(n,x,v)     for(ll v=n-1; v>=x; v--)
#define mod             1000000007
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define PI              3.1415926535897932384626
#define setbits(x)      __builtin_popcount(x)
#define zrobits(x)      __builtin_ctz(x)
#define ps(x,y)         fixed << setprecision(y) << (x)
#define w(t)            int t; cin>>t; while(t--) 
#define     vi          vector<ll>
#define     vtt         vector<pair<ll,ll> > 
#define     pii         pair<ll,ll> 
#define  mapp           map<ll,ll> 
#define  sett           set<ll>
ll mpow(ll base, ll exp); 
// =================================
// =================================

// bool great(pair<double,pair<int,int>> a, pair<double,pair<int,int>> b)
// {
//     if(a.first > b.first)   return true;
//     else if(a.first == b.first){
//         if(a.second.first > b.second.first)  return true;
//     }
//     return false;
// }

// ll solve(const std::vector<std::pair<ll,ll> >& vec, int i, ll n, ll m, ll sum){
//     if(i==n || m <= 0)   return sum ;
//     if(dp[i] != 0) return dp[i];
//     if(vec[i].first<=m)
//     return dp[i] = max( solve(vec,i+1,n,m-vec[i].first,sum+vec[i].second),solve(vec,i+1,n,m,sum) ) ;
//     else
//     return dp[i] = solve(vec,i+1,n,m,sum);
// }

int main(){
    fastio ;
    // w(t)
    // {
        ll a=0, b=0, c=0, d=0, e=0, p=0, q=0, r=0 ;
        ll ans=0, res=0, cnt=0, sum=0, diff=0, mul=1, val=0, k=0 ;
        // loop(0,n,i) brr[i]=0;
        // char s[100005];
        string s ;
        ll n,m ;
        cin >> n ;
        cin >> m ;
        ll dp[n+1][m+1];
        // cin >> s ;
        vector<pair<ll,ll> > vec(n+1);
        // ll wt[n+1], pri[n+1];
        loop(0,n+1,i)  loop(0,m+1,j)  dp[i][j]=0;
        loop(1,n+1,i){
            cin >> vec[i].first >> vec[i].second ;
        }
        // sort(vec.begin(), vec.end(), great);
        int i=0;
        // ans = solve(vec,i,n,m,sum);
        loop(1,n+1,i){
            loop(1,m+1,j){
                if(j-vec[i].first >= 0){
                    dp[i][j] = max(dp[i-1][j],dp[i-1][j-vec[i].first]+vec[i].second) ;
                }
                else{
                    dp[i][j] = dp[i-1][j] ;
                }
                // cout << dp[i][j] << " ";
            }
            // out("")
        }
        out(dp[n][m])
    // }
    return 0 ;
}

// g++ x.cpp -o as && ./as

Measured memory_bytes: 82400
def main():
  import sys

  n,m=map(int,input().split())
  LR=[list(map(int,e.split())) for e in sys.stdin]
  left,right=-1*float("inf"),float("inf")
  
  for L,R in LR:
    if right<L or R<left:
      print(0)
      break
    else:
      tmp=sorted([left,right,L,R])
      left,right=tmp[1],tmp[2]
  else:
    print(right-left+1)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 27380
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll x,y;
void modinv(ll a,ll b){
	if(b==0){
		x=1;
		y=0;
	}
	else {
		modinv(b,a%b);
		ll temp=x;
		x=y;
		y = temp-(a/b)*y;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n );
	ll fac[n+1];
	fac[0]=fac[1]=1;
	for(ll i=2;i<=n;i++){
		fac[i] = (i*fac[i-1])%mod;
	}
	ll binc[n];
	for(ll i=k-1;i<n;i++){
		ll num=fac[i];
		ll den = (fac[k-1]* fac[i-k+1])%mod;
        x=1;y=0;
		modinv(den,mod);
		if(x<0) x = (x+mod)%mod;
		binc[i] = (num * x)%mod;
	}
	ll mins=0;
	for(ll i=0;i<n-k+1;i++){
		mins += ( a[i] *binc[n-i-1])%mod;
	}
	ll maxs=0;
	for(ll i=n-1;i>=k-1;i--){
		maxs += ( a[i]*binc[i])%mod;
	}
	ll ans;
	ans = (maxs-mins+mod)%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define re register
#define int long long
#define ll long long
using namespace std;
const int maxn=2001;
const int mmd=4000010;
const int mod=1e9+7;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+(ch^48); ch=getchar();}
	return x*f;
}
int n,k;
ll f[maxn+10][maxn+10],inv[mmd],fac[mmd];
ll qpow(ll a,ll b)
{
	ll base=1;
	a%=mod;
	while(b)
	{
		if(b&1) base=base*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return base;
}
inline ll C(int n,int m){ return (((fac[m]*inv[n])%mod)*inv[m-n])%mod; }
signed main()
{
	n=read(); k=read();
	if(k==1) 
	{
		cout<<1<<endl;
		return 0;
	}
	fac[0]=1;
//	inc(i,1,maxn) 
	for(int i=1;i<=mmd;i++)
	fac[i]=(fac[i-1]*i)%mod;
	inv[mmd]=qpow(fac[mmd],mod-2);
//	dec(i,maxn-1,0) 
	for(int i=mmd-1;i>=0;--i)
	inv[i]=(inv[i+1]*(i+1))%mod;
	f[0][0]=1;
	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<=i;++j)
		{
			f[i][j]=f[i-1][j];
			if(j==0) continue;
			(f[i][j]+=f[i][j-1]*(n-j+1)%mod*C(k-2,n-i+(n-j+1)*(k-1)-1)%mod)%=mod;
		}
	}
	cout<<f[n][n]<<endl;
}

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

int main()
{
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    char s = 'a';

    for (int i = 0; i < 26; i++)
    {

        if (s != S[i])
        {
            cout << s << endl;
            ;
            return 0;
        }

        s++;
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

bool p[1000000];

int main(){
	int n;
	vector<long long> s;
	for(long long i=2;i<1000000;i++)if(!p[i]){
		s.push_back(i);
		for(int j=i+i;j<1000000;j+=i)p[j]=1;
	}
	partial_sum(s.begin(),s.end(),s.begin());
	for(;;){
		scanf("%d",&n);
		if(!n)break;
		printf("%d\n",s[n-1]);
	}
	return 0;
}

Measured memory_bytes: 2956
#include <bits/stdc++.h>
using namespace std;
int f[200010];
int main(){
    int n,m;
    cin >> n >> m;
    for(int i=0; i<m; i++){
       int a,b;
       cin >> a >> b;
       if(a>b){
           int temp = a;
           a = b;
           b = temp;
       }
       if(a==1){
           f[b]++;
       }
       if(b==n){
           f[a]++;
       }
    }
    for(int i=0; i<200010; i++){
        if(f[i]>=2){
            cout << "POSSIBLE" <<endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define x first
#define y second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s;
        cin>>t;
        int mi=1e9,n=s.size(),m=t.size();
        for(int i=0;i<=n-m;i++)
        {
            int diff=0;
            for(int j=0;j<m;j++)
            if(s[i+j]!=t[j])
            diff++;
            mi=min(mi,diff);
        }
        cout<<mi<<"\n";
    }
    return 0;
}

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

int main() {
  while(true){
    string s;
    cin >> s;
    if(s=="-") break;
    
    int m;
    cin >> m;
    for(int i=0; i < m; i++){
      int h;
      cin >> h;
      string fhalf=s.substr(h);
      string shalf=s.substr(0,h);
      s=fhalf+shalf;
    }
    cout << s <<endl;
  }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string s;
	cin>>s;
	ll i,j,k,l,n=s.length();
	ll a1[n+1]={0},a2[n+1]={0};

	k=0;
	for(i=0;i<n;i++){
		if(s[i]=='L'){
			k++;
			a2[i]=k;
		}
		else k=0;
	}
	k=0;
	for(i=n-1;i>=0;i--){
		if(s[i]=='R'){
			k++;
			a1[i]=k;
		}
		else k=0;
	}

	ll ar[n+1];
	for(i=0;i<=n;i++) ar[i]=1;
	for(i=0;i<n;i++){
		if(s[i]=='R'){
			k=a1[i];
			if(k%2) k--;
		//	cout<<i<<" "<<k<<endl;
			ar[i+k]++;
			ar[i]--;
		}
		else{
			k=a2[i];
			if(k%2) k--;
	//		cout<<i<<" "<<k<<endl;
			ar[i-k]++;
			ar[i]--;
		}
	}

	for(i=0;i<n;i++){
		cout<<ar[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 3024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
 
int main()
{
	int N,a,b,c,x,y,t,vis = 1,p;
	scanf("%d",&N);
	a = 0;
	b = 0;
	c = 0;
	while(N--)
	{
		scanf("%d %d %d",&t,&x,&y);
		a = t - a;
		b = abs(x - b);
		c = abs(y - c);
		p = abs(b+c-a);
		if(b + c > a) 
		{ 
			vis = 0;
		}
		else if(p % 2 !=0)
		{
			vis = 0;
		}
		a = t;
		b = x;
		c = y;
	}
	if(vis == 1) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include<stdio.h>
 
int main(void){
    int x,y,z;
    while(1){
        scanf("%d %d %d",&x,&y,&z);
        if(x==-1&&y==-1&&z==-1){
            break;
        }
        if(x==-1||y==-1){
            printf("F\n");
            continue;
        }
        if(x+y>=80){
            printf("A\n");
        }
        if(x+y>=65&&x+y<80){
            printf("B\n");
        }
        if(x+y>=50&&x+y<65){
            printf("C\n");
        }
        if(x+y>=30&&x+y<50){
            if(z>=50){
                printf("C\n");
            }
            else{
                printf("D\n");
            }
        }
        if(x+y<30){
            printf("F\n");
        }
    }
    return 0;
}

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

int main(){
  int n,valx, valy, valz;
  cin >> n;

  for(int i=1; i<=n; i++){
    int cnt=0;
    for(int x=1; x<=i; x++){
      valx = x*x;
      if(valx > i) break;
      for(int y=1; y<=i; y++){ 
        valy = valx + y*y + x*y;
        if(valy > i) break;
        for(int z=1; z<=i; z++){
          valz = valy + z*z + y*z + z*x;
          if(valz>i) break;
          if(valz == i) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
    
}


Measured memory_bytes: 3504
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int N = scanner.nextInt();

        if (N == 0){
            System.out.println(X);
            return;
        }

        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = scanner.nextInt();
        }

        int L = X, R = X;
        boolean C;
        while(true){
            C = true;
            for (int i = 0; i < N; i++) {
                if(P[i] == L){
                    C = false;
                    L--;
                    break;
                }
            }
            if(C){
                System.out.println(L);
                break;
            }

            C = true;
            for (int i = 0; i < N; i++) {
                if(P[i] == R){
                    C = false;
                    R++;
                    break;
                }
            }
            if(C){
                System.out.println(R);
                break;
            }
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y == 0)return x;
  return gcd(y, x % y);
}

vector<int> vvv(const string&s){
  map<int,int>mp;
  for(auto e:s){
    mp[e]++;
  }
  vector<int>v;
  for(auto e:mp){
    v.push_back(e.second);
  }
  sort(v.begin(), v.end());
  return v;
}

int main(){
  string s,t; cin >> s >> t;
  vector<int> vs = vvv(s);
  vector<int> vt = vvv(t);
  bool f = vs.size() == vt.size();
  for(int i = 0; f && i < (int)vs.size(); ++i){
    f = vs[i] == vt[i];
  }
  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3844
N,W = map(int,input().split())
wv = [0]
for i in range(N):
    wv.append(list(map(int,input().split())))
    
#- dp[i][j] i番目までの品物から、価値がjとなるように選んだ時の、重さの最小値
Vmax = 10**3*100
dp = [[float('inf')]*(Vmax+1) for i in range(N+1)]
dp[0][0]=0#なにも品物を選ばないなら価値0で重さ0

for i in range(1,N+1):#N番目以降は品物がもうないので0。→N-1からやる
    for j in range(0,Vmax+1): #価値でループ
        if j<wv[i][1]:#i番目の荷物の価値がそもそも入れたい価値よりも大きい→いれられない
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-wv[i][1]]+wv[i][0])#いれない or いれる　の大きいほう
#最後の出力は、最終番目以降の品物(つまり、全部)から、価値の大きいほうから見ていき、許容W以下のもの
for i in range(Vmax,-1,-1):
    if dp[N][i] <= W:
        print(i)
        break



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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

string S, T;
string ReplaceString(std::string String1, std::string String2, std::string String3) {
    std::string::size_type Pos(String1.find(String2));

    while(Pos != std::string::npos) {
        String1.replace(Pos, String2.length(), String3);
        Pos = String1.find(String2, Pos + String3.length());
    }

    return String1;
}

int main() {
    cin >> S >> T;
    ll N = S.length();
    string ans = "UNRESTORABLE";
    REP(i, N - T.length() + 1) {
        bool judge = true;
        string s = S.substr(i, T.length());
        REP(j, s.length()) {
            if(s[j] != T[j] && s[j] != '?') {
                judge = false;
                break;
            }
        }
        if(!judge) continue;
        string tmp = ReplaceString(S.substr(0, i), "?", "a") + T + ReplaceString(S.substr(T.length() + i, S.length() - T.length() - i), "?", "a");
        if(tmp < ans || ans == "UNRESTORABLE") ans = tmp;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 20 20:51:59 2019

@author: Owner
"""

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
    
all(nstr.count(c) for c in '753')
"""

s = int(input())

a = []

a.append(s)

i=1
while 1==1:
    if a[i-1] % 2 == 0:
        a.append(int(a[i-1]/2))
    else:
        a.append(int(3*a[i-1]+1))
    if a.count(a[i]) == 2:
        print(i+1)
        break
    else:
        i += 1

Measured memory_bytes: 20760
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main() {
  int s;
  cin>>s;
  
  set<int> st;
  int x=s;
  
  while(st.count(x)==0){
    st.insert(x);
    if(x%2==0)
      x=x/2;
    else
      x=3*x+1;
  }

  cout<<st.size()+1<<endl;
}


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

lint N,x;
const int MAX_N = 2010;
lint a[MAX_N];
lint b[MAX_N][MAX_N];

int main(){
    ios::sync_with_stdio(false);
    cin>>N>>x;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }

    for(int i=0;i<N;i++){
        lint min_cost = 1e18;
        for(int j=0;j<N;j++){
            int id = (i-j+N)%N;
            if(j>0)b[i][j] = b[i][j-1];
            if(min_cost > (lint)a[id]){
                min_cost = (lint)a[id];
                b[i][j] = j;
            }
        }
    }
    
    lint ans = 1e18;
    for(int i=0;i<N;i++){
        lint sum = i*x;
        for(int j=0;j<N;j++){
            sum += a[(j-b[j][i]+N)%N];
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 31744
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S, &T)

	s := make(map[byte]byte, len(S))
	t := make(map[byte]byte, len(T))
	for i := 0; i < len(S); i++ {
		if v, ok := s[S[i]]; ok {
			if v != T[i] {
				fmt.Println("No")
				return
			}
		} else {
			s[S[i]] = T[i]
		}
		if v, ok := t[T[i]]; ok {
			if v != S[i] {
				fmt.Println("No")
				return
			}
		} else {
			t[T[i]] = S[i]
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<s.length();i++)
      if(s[i]=='A')a++;
      else b++;
   if(!a||!b)cout<<"No\n";
  else cout<<"Yes\n";
}


Measured memory_bytes: 256
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let abs = Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun a b -> a, b)) in
  Array.to_list abs
  |> List.rev
  |> List.fold_left (fun pushed (a, b) -> pushed + if (a + pushed) mod b = 0 then 0 else b - (a + pushed) mod b) 0
  |> Printf.printf "%d\n"


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pcase cout<<"Case "<<++cs<<":"
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007

const int N = 1e5+10;
const ll inf = 1e18;

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n, w; cin>>n>>w;
    vll dp(N, inf);
    int a, b; cin>>a>>b;
    dp[b] = a; dp[0] = 0;
    for(i = 1 ; i < n; i++){
        int a, b; cin>>a>>b;
        vll new_dp(N,inf);
        for(j = 0; j < N; j++){
            new_dp[j] = dp[j];
            if(b <= j) new_dp[j] = min(new_dp[j], dp[j-b] + a);
        }
        dp = new_dp;
    }
    int ans = 0;
    for(i = 0; i < N; i++){
//        cout << dp[i] << " ";
        if(dp[i] <= w) ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
using namespace std;

int INF = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

vector<int> arr(55560);

void Eratosthenes() {
	int n = 55556;

	for (int i = 1; i <= n; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i <= n/2; i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < n; j++) {
				arr[i *(j + 2)] = 0; 
			}
		}
	}

	int j = 1;
	arr[1] = 0;
	for (int i = 1; i <= n; i++) {
		if (arr[i] && i%5 == 1) {
			arr[j] = i;
			j++;
		}
	}
}

int main() {
	int n;
	cin >> n;
	Eratosthenes();
	
	for (int i = 1; i <= n; i++) {
		cout << arr[i] << " ";
	}
}

Measured memory_bytes: 512
X, Y = map(int, input().split())
MOD = 10**9+7
N = 134*10**4

def power(base, num):
    if num == 0:
        return 1
    elif num % 2==0:
        return power(base, num//2) **2 % MOD
    elif num==1:
        return base % MOD
    else:
        return power(base, num//2) **2 * base % MOD
    
fact = [0 for i in range(N)]
inv_fact = [0 for i in range(N)]
 
fact[0] = 1
for i in range(1, N):
    fact[i] = fact[i-1] * i % MOD

inv_fact[N-1] = power(fact[N-1], MOD-2)
for i in range(1, N):
    inv_fact[N-1-i] = inv_fact[N-i] * (N-i) % MOD
 
def comb(x,y):
    return (fact[x] * inv_fact[y])%MOD * inv_fact[x-y] % MOD

if (2*X-Y)%3==0 and (-X+2*Y)%3==0 and 2*X-Y>=0 and -X+2*Y>=0:
    a = (2*X-Y) //3
    b = (-X+2*Y)//3
    ans = comb(a+b, min(a,b)) % MOD

    print(ans)

    
else:
    print(0)


Measured memory_bytes: 109080
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair <int,int> pii;

const int mod=1e9+7;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}
inline int mul(int x,int y) {return (long long)x*y%mod;}
inline int power(int a,int b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}

const int N=1e5+50;
int n,k;
#define div divc
vector <int> div;
int g[N];
int main() {
	cin>>n>>k; k%=mod;
	div.push_back(1);
	int t=n;
	for(int i=2;i*i<=t;i++) {
		if(!(t%i)) {
			int c=0;
			while(!(t%i)) t/=i, ++c;
			for(int j=div.size()-1;~j;j--) 
				for(int x=i,z=1;z<=c;x*=i,++z) 
					div.push_back(div[j]*x);
		}
	}
	if(t!=1) 
		for(int j=div.size()-1;~j;j--) div.push_back(div[j]*t);
	sort(div.begin(),div.end());
	for(int i=0;i<div.size();i++) 
		g[i]=power(k,(div[i]+1)/2);
	for(int i=0;i<div.size();i++) 
		for(int j=i-1;~j;j--) if(!(div[i]%div[j]))
			g[i]=dec(g[i],g[j]);
	int ans=0;
	for(int i=0;i<div.size();i++)
		ans=add(ans,mul((div[i]&1) ? div[i] : (div[i]/2),g[i]));
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let x: i64 = input();

    println!("{}", if a <= x && x <= a + b { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
c = [list(map(int, input().split())) for i in range(m)]
ans = min(A) + min(B)
for i in range(m):
    t = A[c[i][0]-1] + B[c[i][1]-1] - c[i][2]
    ans = min(ans, t)

print(ans)


Measured memory_bytes: 38560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    size_t n, m;
    cin >> n >> m;
    if (n == m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  rep(i, N){
    cin >> H.at(i);
  }
  sort(all(H));
  rep(i, min(K, N)){
    H.pop_back();
  }
  ll cnt = 0;
  rep(i, N-K){
    cnt += H.at(i);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

template<typename T>
using v = vector<T>;

ll merge_count(vll &a) {
	int n = a.size();
	if (n <= 1)return 0;
	ll cnt = 0;
	vll b(a.begin(), a.begin() + n / 2);
	vll c(a.begin() + n / 2, a.end());

	cnt += merge_count(b);
	cnt += merge_count(c);

	int ai = 0, bi = 0, ci = 0;

	while (ai < n) {
		if (bi < b.size() && (ci == c.size() || b[bi] < c[ci])) {
			a[ai] = b[bi];
			bi++;
		}
		else {
			cnt += n / 2 - bi;
			a[ai] = c[ci];
			ci++;
		}
		ai++;
	}
	return cnt;
}

int main() {
	int N, K;
	cin >> N >> K;
	vll a(N);
	vll sum(N + 1);
	sum[0] = 0;
	rep(i, N) {
		cin >> a[i];
		a[i] -= K;
		sum[i + 1] = sum[i] + a[i];
	}
	reverse(all(sum));

	ll ans = 0;

	cout << merge_count(sum) << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
const int maxn = 200000 + 5;
typedef unsigned long long ull;
ull a[maxn];
int main(){
	ull own = 1000;
	int n;
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	int left = 0;
	int right = 1;
	while(right<=n){
		if(a[left] < a[right]){
			//cout << own << endl;
			own = own/a[left]*a[right]+own%a[left];
			left = right;
			right++; 
		}else if(a[left] >= a[right]){
			//cout << own << endl;
			left = right;
			right+=1; 
		}
	}
	cout << own; 
	return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 1e9 + 7;
const ll maxn = 200005;
char s[1100]={'1','a','b','c','d','e','f','g','h','i','j','k'};
int a[1100]={0},n;
void dfs(int k,int ma){
	if(k>n){
		for(int i=1;i<=n;i++) printf("%c",s[a[i]]);
		printf("\n");
		return ;
	} 
	int t=ma;
	for(int i=1;i<=n;i++){
		if(i<=k&&i<=t+1){
			if(i>ma) ma=i;
			a[k]=i;
			dfs(k+1,ma);
			a[k]=0;
		}
	}
	
}
int main(){  
	//cin.tie(0);
    //ios::sync_with_stdio(false);
	scanf("%d",&n); 
	//for(int i=1;i<=10;i++) a[i]=1;
	dfs(1,0);
	
	
    return 0;
}




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

#define MAX 100000

int main() {
	int N;
	vector<pair<int, int>> R;
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x, l;
		cin >> x >> l;
		R.push_back(make_pair(x + l, x - l));
	}
    sort(R.begin(), R.end());
    int r = R[0].first;
    ans++;
    for (int i = 1; i < N; i++) {
        if (R[i].second >= r) {
            ans++;
            r = max(r, R[i].first);
        }
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400