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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
int main() {
const ll INF = 100100100100100100;

int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N+1);
    rep(i,M) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> tag(N+1, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    tag[1] = 0;
    que.push(1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (tag[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            tag[nv] = v;
            que.push(nv);
        }
    }
    bool flag =true;
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    rep3(v,N) {
      if(tag[v]==-1) flag=false;
      
    }
    if(flag){
      cout<<"Yes"<<endl;
      rep4(i,2,N) cout<<tag[i]<<endl;
    }
    else{
      cout<<"No"<<endl;
    }

return 0;
}


Measured memory_bytes: 10328
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

int nextInt()
{
    int y = 0;
    char c = getchar();
    while ('0' <= c && c <= '9')
    {
        y = 10 * y + c - '0';
        c = getchar();
    }
    return y;
}

long long max(long long a, long long b)
{
    if (a > b) return a;
    return b;
}

long long min(long long a, long long b)
{
    if (a < b) return a;
    return b;
}

int n;
int pos[5101];
int res[3000000];

signed main()
{
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> pos[i + 1];
    set<pair<int, int> > ss;
    for (int i = 1; i <= n; i++)
    {
        ss.insert({pos[i], i - 1});
        res[pos[i]] = i;
    }
    for (int i = 1; i <= n * n; i++)
    {
        auto it = ss.begin();
        if (res[i] == 0)
        {
            pair<int, int> r = *it;
            while (r.second == 0)
            {
                ss.erase(r);
                if (ss.size() == 0)
                {
                    cout << "No";
                    return 0;
                }
                it = ss.begin();
                r = *it;
            }
            if (r.first > n * n) res[i] = r.first - n * n;
            else res[i] = res[r.first];
            ss.erase(it);
            r.second--;
            ss.insert(r);
        }
        else
        {
            int t = 1;
            for (auto it : ss)
            {
                if (it.first == i)
                {
                    if (it.second > 0) t = 0;
                }
            }
            if (!t)
            {
                cout << "No";
                return 0;
            }
            pair<int, int> v = {n * n + res[i], n - res[i]};
            ss.insert(v);
        }
    }
    cout << "Yes\n";
    for (int i = 1; i <= n * n; i++)
    {
        cout << res[i] << " ";
    }
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>
int N=1000;

int lcs(char X[],char Y[]){
    int c[N+1][N+1];
    int m=strlen(X);
    int n=strlen(Y);
    int maxl=0,i,o;
    for(i=1;i<=m;i++)
        c[i][0]=0;
    for(o=1;o<=n;o++)
        c[0][o]=0;
    for(i=1;i<=m;i++){
        for(o=1;o<=n;o++){
            if(X[i-1] == Y[o-1])
                c[i][o]=c[i-1][o-1]+1;
            else
                c[i][o]=c[i-1][o]>c[i][o-1]?c[i-1][o]:c[i][o-1];
            maxl=maxl>c[i][o]?maxl:c[i][o];
        }
    }
    return maxl;
}


int main(void){
    char line1[1001],line2[1001];
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",line1,line2);
        printf("%d\n",lcs(line1,line2));
    }
    return 0;
}

Measured memory_bytes: 4524
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<cmath>
using namespace std;


#define ll long long
#define fr(m) for(int i=0; i<m; i++)
#define frj(m) for(int j=0; j<m; j++)
#define frr(n) for(int i=n; i>=0; i--)
#define pb push_back
#define orr ||
#define nl \n
#define sci(n) scanf("%lld ", &n)
#define pri(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

bool compare(ll a, ll b){
    return(a>b);
}

int main()
{

    string a;
    cin>>a;
    ll len=a.size();
    vector<char>vec;
    vector<char>::iterator it;
    fr(len){
        if(a[i]!='B'){
            vec.pb(a[i]);
        }
        else{
            if(!vec.empty()){
                vec.pop_back();
            }
        }
    }
    for(it=vec.begin(); it!=vec.end(); it++){
        cout<<*it;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, i;
	int cnt = 0;

	scanf("%d %d %d", &a, &b, &c);

	for (i = a; i <= b; i++) {
		if (c % i == 0) cnt ++;
	}

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

	return 0;
}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int a[102];
int main()
{
	   int n,x;
	   cin>>n;
	   for(int i=1;i<=n;i++){
	   cin>>x;
	   a[x]=1;
	}
	int s=0;
	for(int i=1;i<=100;i++){
		if(a[i]==1)   s++;
	}
	cout<<s<<endl;
	return 0;
} 


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	double s=abs(6*d-(30*c+0.5*d))/180*PI;
	cout<<shosu(9)<<sqrt(a*a+b*b-2*a*b*cos(s))<<endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 300 + 10;

int n, arr[nax][nax], del[nax], m;
int posrem;
int ans[nax];
int solve()
{
    memset(ans, 0, sizeof(ans));

    for(int i = 1; i <= n; i++)
    {
        int j = 1;
        while(j <= m && del[arr[i][j]] == 1) j++;
        ans[arr[i][j]]++;
    }
    int maxi = 0;
    for(int i = 1; i <= m; i++)
    {
        if(del[i] == 1) continue;
        if(maxi < ans[i])
        {
            maxi = ans[i];
            posrem = i;
        }
    }
    return maxi;
}
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++) cin >> arr[i][j];
    }
    int mainans = inf;
    for(int i = 1; i <= m; i++)
    {
        int cur = solve();
        mainans = min(mainans, cur);
        del[posrem] = 1;
       // cout << cur << " " << posrem << endl;
    }
    cout << mainans;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    string s; cin >> s;
    
    int a = stoi(s.substr(0,2));
    int b = stoi(s.substr(2,2));
    
    bool mmyy = (1 <= a && a <= 12);
    bool yymm = (1 <= b && b <= 12);
    
    string ans;
    if(mmyy && yymm) ans = "AMBIGUOUS";
    else if(mmyy) ans = "MMYY";
    else if(yymm) ans = "YYMM";
    else ans = "NA";

    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
#define inf 0x3f3f3f3f3f3f3f3f


int main()
{
	int n;
	scanf("%d",&n);
	ll sum=0;
	ll tmp=inf;
	for(int i=0;i<n;i++)
	{
		ll a,b;
		scanf("%lld%lld",&a,&b);
		sum+=a;
		if(a>b)
		tmp=min(tmp,b);
	}
	if(tmp==inf)
	cout<<0<<endl;
	else
	cout<<sum-tmp<<endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func main() {
	io := NewIo()
	defer io.Flush()

	N := io.NextInt()
	M := io.NextInt()

	L := 0
	R := N + 1

	for i := 0; i < M; i++ {
		tmpL := io.NextInt()
		if tmpL > L {
			L = tmpL
		}

		tmpR := io.NextInt()
		if tmpR < R {
			R = tmpR
		}
	}

	if R-L < 0 {
		io.PrintLn(0)
	} else {
		io.PrintLn(R - L + 1)
	}
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll N,M,V,P;
  cin>>N>>M>>V>>P;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(rng(A));
  reverse(rng(A));
  ll l=0;
  ll r=N;
  ll m;
  while(r-l>1){
    m=(l+r)/2;
    ll sum=0;
    vector<ll>B=A;
    ll AA=A[m]+M;
    ll VV=V*M-M;
    B[m]=AA;
    for(int i=0;i<N;i++){
      if(i==m)continue;
      VV-=min(max(AA-B[i],0ll),M);
      B[i]=min(max(AA,B[i]),B[i]+M);
      if(VV<=0)break;
    }
    for(int i=0;i<N;i++){
      if(i==m)continue;
      ll D=M-(B[i]-A[i]);
      if(D<=0)continue;
      B[i]+=min(VV,D);
      VV=max(VV-D,0ll);
      if(VV==0)break;
    }
    ll c=0;
    for(auto it:B)if(it>AA)c++;
    if(c<P)l=m;
    else r=m;
  }
  cout<<l+1<<endl;
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn=2e3+5;
const ll p=998244353;
int a[105][105];

int main(){
	ios::sync_with_stdio(false);
	int n,d;
	
	cin>>n>>d;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=d;j++){
			cin>>a[i][j];
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			ll sum=0;
			for (int k=1;k<=d;k++){
				sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			ll dis=sqrt(sum);
			if (dis*dis==sum){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=200009;
typedef long long ll;
ll a[N],d[N];
ll n,k,ans;
bool cmp(const int &x, const int &y) {
    return x>y;
}
bool OK(ll mid) {
    ll i,cnt=0;
    for(i=1;i<=n;i++)
        if(a[i]*d[i]>mid) 
            cnt+=ceil((a[i]*d[i]-mid)/(double)d[i]);
    return cnt<=k;
}
int main() {
	cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>d[i];
    sort(a+1,a+n+1);
    sort(d+1,d+n+1,cmp);
    ll l=0,r=1000000000000,mid;
    while(l<=r) {
        mid=l+(r-l)/2;
        if(OK(mid))
            r=mid-1, ans=mid;
        else
            l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ld=long double;
 
 
int main(){
    lli n,k;
    cin>>n>>k;
    if(n<k)
    cout<<min(n,k-n);
    else if(!(n%k))
    cout<<0;
    else
    cout<<k-n%k;
    
    
    
    return 0;
}

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

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int K = 40;
const int INF = 1e9 + 239;

int dp[K];
int ndp[K];

void init() {
	fill(dp, dp + K, INF);
	fill(ndp, ndp + K, INF);
	dp[0] = 0;
}

void rec(int a, int b) {
	for (int i = 0; i < K; i++) {
		int nt = (a + 1) * (dp[i] + 1) + b;
		nt = min(nt, INF);
		if (i + 1 < K) ndp[i + 1] = min(ndp[i + 1], nt);
		ndp[i] = min(ndp[i], dp[i]);
	}
	for (int i = 0; i < K; i++) {
		dp[i] = ndp[i];
		ndp[i] = INF;
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	auto get = [&](pair<int, int> x, pair<int, int> y) {
		int t = 1;
		t += (x.first * t) + x.second;
		t++;
		t += (y.first * t) + y.second;
		return t;
	};

	auto cmp = [&](pair<int, int> x, pair<int, int> y) {
		return get(x, y) < get(y, x);
	};

	int n, mx;
	cin >> n >> mx;
	vector<pair<int, int>> a(n);
	for (auto &t : a) {
		cin >> t.first >> t.second;
	}
	sort(a.begin(), a.end(), cmp);
	vector<int> cost0;
	while (!a.empty() && a.back().first == 0) {
		cost0.push_back(a.back().second);
		a.pop_back();
	}
	init();
	for (auto t : a) {
		rec(t.first, t.second);
	}
	sort(cost0.begin(), cost0.end());
	int ans = 0;
	{
		int sm = 0;
		for (int i = 0; i <= (int)cost0.size(); i++) {
			for (int j = 0; j < K; j++) {
				if (sm + dp[j] <= mx) ans = max(ans, i + j);
			}
			if (i < (int)cost0.size()) sm += cost0[i] + 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5620
def iroha():
    a, b = map(int, input().split())

    if a == 2 or b == 2:
        print("No")
        return

    list = [4, 6, 9, 11]
    count = 0
    
    for x in list:
        if a == x or b == x:
            count += 1

    if count == 1:
        print("No")
        return
        
    print("Yes")


if __name__ == "__main__":
    iroha()



Measured memory_bytes: 9012
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

template<typename T>
struct Segtree{
        using F = std::function<T(T,T)>;
        std::vector<T> seg;
        int size=1;
        T unit;
        F func;

        Segtree(int n, const T &u, const F f): unit(u), func(f) {
                while(size<n) size <<= 1;
                seg.assign(2*size-1, unit);
        }

        void update(int idx, const T &x){
                idx += size-1;
                seg[idx] = x;
                while(idx>0){
                        idx = (idx-1) / 2;
                        seg[idx] = func(seg[2*idx+1], seg[2*idx+2]);
                }
        }

        T query(int a, int b, int k=0, int l=0, int r=-1){
                if(r<0) r = size;
                if(b<=l or r<=a) return unit;
                if(a<=l and r<=b) return seg[k];
                return func(query(a,b, 2*k+1, l,(l+r)/2), query(a,b, 2*k+2, (l+r)/2,r));
        }

        T operator[](const int &i) const {return seg[size-1+i];}
};


int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	std::vector<P> ab(m);
	rep(i, 0, m) scanf("%ld %ld", &ab[i].fi, &ab[i].se);
	std::sort(be(ab), [](P x, P y){return x.se<y.se;});

	int ans = 0;
	Segtree<bool> seg(n, 0, [](bool a, bool b){return a|b;});
	rep(i, 0, m){
		ll a=ab[i].fi-1, b=ab[i].se-1;
		if(!seg.query(a, b)){
			ans++;
			seg.update(b-1, 1);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int x,a[4],c=0;
  string s;
  cin>>s;
  rep(i,0,4){
    a[i]=s[i]-48;
  }
  c+=a[0];
  rep(i,0,8){
    x=i;
    rep(j,1,4){
      if(x%2==1) c-=a[j];
      else c+=a[j];
      x/=2;
    }
    if(c==7){
      x=i;
      cout<<a[0];
      rep(j,1,4){
        if(x%2==1) cout<<'-'<<a[j];
        else cout<<'+'<<a[j];
        x/=2;
      }
      cout<<"=7";
      break;
    }
    c=a[0];
  }
  
  return 0;
}


Measured memory_bytes: 256
N = input()

DP_just = 0
DP_plus = 1

for c in N:
    d = int(c)
    last_just = DP_just
    last_plus = DP_plus
    DP_just = min(last_just + d, last_plus + 10 - d)
    d += 1
    DP_plus = min(last_just + d, last_plus + 10 - d)

print(DP_just)

Measured memory_bytes: 5492
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353 //1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 100000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int dp[N];
int pref[N];
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,k;
   cin>>n>>k;
   dp[1]=1;
   pref[1]=1;
   vector<pii>v;
   for(int i=0;i<k;i++)
   {
       int x,y;
       cin>>x>>y;
       v.pb({x,y});
   }
   for(int i=2;i<=n;i++)
   {
       for(int j=0;j<v.size();j++)
       {
           int l=v[j].F;
           int r=v[j].S;
           if(i-l>=1)
           {
               (dp[i]+=(pref[i-l]))%=M;
           }
           if(i-r>=1)
           {
               dp[i]=(dp[i]-pref[i-r-1]+M)%M;
           }
       }
       //debug(dp[i],i);
       pref[i]=pref[i-1]+dp[i];
       pref[i]%=M;
   }
   cout<<(dp[n]%M)<<endl;
}


Measured memory_bytes: 6748
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto f(string t){
    for(auto c : t){
        if(c == 'A' or c == 'G' or c == 'C' or c == 'T')
            continue;
        else
            return false;
    }
    return true;
}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    string s;
    cin >> s;
    string ans = "";
    for(int  i = 0; i < s.size(); i++){
        for(int l = 1;  i + l <= s.size() ; l++){
            auto t = s.substr(i,l);
            if(f(t)){
                if(ans.size() < t.size())
                    ans = t;
            }
        }
    }
    cout << ans.size() << endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

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


Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
int popcount(int val) { return __builtin_popcount(val); }
int popcountll(ll val) { return __builtin_popcountll(val); }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

using CostType = ll;
struct Edge {
  int src, dst; CostType cost;
  Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {}
  inline bool operator<(const Edge &rhs) const {
    return cost != rhs.cost ? cost < rhs.cost : dst != rhs.dst ? dst < rhs.dst : src < rhs.src;
  }
  inline bool operator<=(const Edge &rhs) const { return !(rhs < *this); }
  inline bool operator>(const Edge &rhs) const { return rhs < *this; }
  inline bool operator>=(const Edge &rhs) const { return !(*this < rhs); }
};

bool is_bipartite(const vector<vector<Edge> > &graph, vector<int> &color) {
  int n = graph.size();
  color.assign(n, 0);
  function<bool(int, int)> dfs = [&](int ver, int now) {
    color[ver] = now;
    for (const Edge &e : graph[ver]) {
      if (color[e.dst] == now || (color[e.dst] == 0 && !dfs(e.dst, -now))) return false;
    }
    return true;
  };
  REP(i, n) {
    if (color[i] == 0 && !dfs(i, 1)) return false;
  }
  return true;
}

int main() {
  int n, m; cin >> n >> m;
  vector<vector<Edge> > graph(n);
  REP(_, m) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(a, b);
    graph[b].emplace_back(b, a);
  }
  vector<int> color;
  if (is_bipartite(graph, color)) {
    int black = 0, white = 0;
    REP(i, n) ++(color[i] == 1 ? black : white);
    cout << 1LL * black * white - m << '\n';
  } else {
    cout << 1LL * n * (n - 1) / 2 - m << '\n';
  }
  return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>   
using namespace std;    
int main(){
  int d;
  cin>>d;
  
  if(d==25){
    cout<<"Christmas"<<endl;
  }

  else if(d==24){
    cout<<"Christmas"<<" "<<"Eve"<<endl;
  }

  else if(d==23){
    cout<<"Christmas"<<" "<<"Eve"<<" " <<"Eve"<<endl;
  }

  else{
    cout<<"Christmas"<<" "<<" Eve"<<" Eve"<<" Eve"<<endl;
  }

  
}



  
  

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    A = []
    for _ in range(N):
        a, b = LI()
        A.append((a, b))
    A = sorted(A, key=lambda x:x[0])
    bought = 0
    ix = 0
    money = 0
    while bought < M:
        if bought + A[ix][1] > M:
            money += A[ix][0] * (M - bought)
            break
        bought += A[ix][1]
        money += A[ix][0] * A[ix][1]
        ix += 1
    print(money)


main()



Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int a;
string s;

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)
d = [-1,0,1]
def search(x,y,m):
    if not(0<=x<len(m[0]) and 0<=y<len(m)) or m[y][x]=='0': return
    m[y][x] = '0'
    for dy in d:
        for dx in d:
            search(x+dx,y+dy,m)
while True:
    w,h = map(int,input().split())
    if w==h==0: break
    m = [input().split() for _ in range(h)]
    c = 0
    for y in range(h):
        for x in range(w):
            if m[y][x]=='1':
                c += 1
                search(x,y,m)
    print(c)

Measured memory_bytes: 9544
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
int store[500000+2],ans;
int L[250000+2],R[250000+2];
void merge(int left,int mid,int right)
{
	int i,j,k;
	int n1,n2;
	n1=mid-left;n2=right-mid;
	for(i=0;i<n1;i++) L[i]=store[left+i];
	for(i=0;i<n2;i++) R[i]=store[mid+i];
	L[n1]=1000000000+1;R[n2]=1000000000+1;
	i=0;j=0;
	for(k=left;k<right;k++)
	{
		if(L[i]<=R[j]){
			store[k]=L[i++];
		}else{
			store[k]=R[j++];
		}
		ans++;
	}
}
void mergesort(int left,int right)
{
	int mid;
	if(left+1<right){
		mid=(left+right)/2;
		mergesort(left,mid);
		mergesort(mid,right);
		merge(left,mid,right);
	}
} 
int main(int argc, char *argv[]) {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&store[i]);
	}
	mergesort(0,n);
	for(int i=0;i<n;i++)
	{
		if(i!=n-1)
			printf("%d ",store[i]);
		else
			printf("%d\n",store[i]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 7028
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll n;
	cin>>n;
	char a[n+1],b[n+1];
	rp(i,1,n)cin>>a[i];
	rp(i,1,n)cin>>b[i];
	for(int i=1;i<=n;i++){
		cout<<a[i]<<b[i];
	}return cout<<endl,0;
}/*『你强归你强，我永不示弱』*/





Measured memory_bytes: 256
function Main(input) {

    input = input.split("\n");

    tmp0 = input[0].split(' ');
    tmp1 = input[1].split(' ');

    var H = tmp0[0];
    var W = tmp0[1];
    var h = tmp1[0];
    var w = tmp1[1];

    console.log((H*W)-(W*h)-((H-h)*w))

}

    Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toLong).toSeq)
  val N = ls(0)(0)
  val M = ls(0)(1)
  val l = ls.tail
  val sorted = l.sortBy(_(0)).toArray
  
  var m = M
  var ret = 0L
  var i = 0
  while(m>0){
    val t = sorted(i)
    val a = t(0)
    val b = t(1)
    val qty = Math.min(m, b)
    ret += qty * a
    m -= qty
    i += 1
  }
  println(ret)
}


Measured memory_bytes: 109192
import math
n=int(input())
x=[float(a) for a in input().split()]
y=[float(b) for b in input().split()]
p=[float(1),float(2),float(3),math.inf]
for j in range(3):
    lst=[]
    for i in range(n):
        if x[i]>=y[i]:
            s=(x[i]-y[i])**(p[j])
        else:
            s=(y[i]-x[i])**(p[j])
        lst.append(s)
    t=sum(lst)
    print(f'{t**(1/p[j]):10.8f}')
lst1=[]
for k in range(n):
    if x[k]>=y[k]:
        u=x[k]-y[k]
    else:
        u=y[k]-x[k]
    lst1.append(u)
print(f'{max(lst1):10.8f}')
        



Measured memory_bytes: 5752
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
int cnt[N],v[N],dp[N];
int dfs(int s)
{
	if(s==0) return 0;
	if(dp[s]!=-1) return dp[s];
	dp[s]=0x3f3f3f3f;
	for(int i=0;i<16;i++)
	{
		if(s>>i&1)
		{
			for(int j=0;j<16;j++)
			{
				if(s>>j&1)
				{
					int x=i^j;int ns=s^(1<<i)^(1<<j)^(1<<x);
					if(__builtin_popcount(ns)<__builtin_popcount(s))
					 dp[s]=min(dp[s],dfs(ns)+1+((s&(1<<x))==(1<<x)));
				}
			} 
	    }
	}
	return dp[s];
}
int main()
{
	int n;
	cin>>n;
	for(int i=1,x,y,z;i<n;i++)
	{
		cin>>x>>y>>z;
		v[x]^=z;
		v[y]^=z;
	}
	memset(dp,-1,sizeof dp);
	for(int i=0;i<n;i++)
	 if(v[i]) cnt[v[i]]++;
	int st=0,ans=0;
	for(int i=1;i<16;i++)
	{
		ans+=cnt[i]/2;
		st|=(cnt[i]&1)*(1<<i);
	} 
	ans+=dfs(st);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main(void){
  int n;
  char ch,pch;
  int s;

  std::cin>>n;
  std::cin.get();
  pch = 0;
  s=0;
  for(int i=0;i<n;i++){
    std::cin.get(ch);
    if(ch!=pch){s++;pch=ch;}
  }

  std::cout << s;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
depositions = []
for _ in range(n):
    p = []
    for _ in range(int(input())):
        x, y = map(int, input().split())
        p.append((x - 1, y))
    depositions.append(p)

num_honest = 0
for i in range(2 ** n):
    honests = []
    dishonests = []
    flag = 0
    for j in range(n):
        if flag:
            break
        if i & (1 << j):
            if j not in honests and j not in dishonests:
                honests.append(j)
            elif j in dishonests:
                flag = 1
                break
            for p in depositions[j]:
                a, b = p
                if b == 1:
                    if a not in honests and a not in dishonests:
                        honests.append(a)
                    elif a in dishonests:
                        flag = 1
                        break
                else:
                    if a in honests:
                        flag = 1
                        break
                    elif a not in dishonests:
                        dishonests.append(a)
        elif j in honests:
            flag = 1
            break
        elif j not in dishonests:
            dishonests.append(j)
    if flag == 0:
        num_honest = max(num_honest, len(honests))
print(num_honest)

Measured memory_bytes: 3064
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=1e5+5;



int main()
{

         
         ll n,W;
         cin >> n >> W;
         ll weight[n],value[n];
         rep(i,0,n)
         cin >> weight[i] >> value[i];
         ll dp[n+1][W+1];
         memset(dp,0,sizeof(dp));
         for(int i=1;i<=n;i++)
         {
            for(int j=1;j<=W;j++)
            {
               if(j<weight[i-1])
                dp[i][j]=dp[i-1][j];
              else dp[i][j]=max(dp[i-1][j],value[i-1]+dp[i-1][j-weight[i-1]]);
            }
         }
         cout<<dp[n][W];
         
     return 0;
}



Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	vector<ll> x(n), y(n);
	bool odd = true, even = true;
	rep(i, n) {
		cin >> x[i] >> y[i];
		if ((x[i] + y[i]) % 2 == 0) odd = false;
		else even = false;
	}
	if (!odd && !even) {
		cout << "-1\n";
		return 0;
	}
	cout << (odd ? 39 : 40) << '\n';
	vector<ll> dis;
	vector<string> w(n);
	ll d = 1ll << 38;
	bool flag = true;
	while (d) {
		dis.pb(d);
		rep(i, n) {
			if (abs(x[i]) < abs(y[i])) {
				if (y[i] > 0) w[i] += 'U', y[i] -= d;
				else w[i] += 'D', y[i] += d;
			}
			else {
				if (x[i] > 0) w[i] += 'R', x[i] -= d;
				else w[i] += 'L', x[i] += d;
			}
		}
		d >>= 1;
		if (d == 0 && even && flag) { d = 1, flag = false; }
	}
	for (ll i : dis) cout << i << ' '; cout << '\n';
	for (string s : w) cout << s << '\n';
}

Measured memory_bytes: 3700
N,X = map(int,input().split())

L = list(map(int,input().split()))

D = 0
cnt = 0
for i in range(N):
    D += L[i]
    cnt += 1
    if D > X:
        break

if D <= X:
    print(cnt + 1)
else:
    print(cnt)

Measured memory_bytes: 3060
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M) = nextLongList()
    val ans = (1900 * M + 100 * (N - M)) * Math.pow(2.0, M.toDouble()).toLong()
    println(ans)
}

Measured memory_bytes: 37852
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,M = inpl()
lines = defaultdict(set)
for _ in range(M):
	a,b = inpl()
	a,b = a-1,b-1
	lines[a].add(b)
	lines[b].add(a)

ans = 0

def search(s,ed,num):
	global ans

	if num == N:
		ans += 1
	else:
		for t in lines[s]:
			if not ed & (1<<t):
				search(t,ed+(1<<t),num+1)


search(0,1,1)
print(ans)


Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof(v))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = LLONG_MAX - INT_MAX, MOD = 1e9 + 7, LIMIT = 100001;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
// const int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int a, b, c, k, n, m, x, y, z, w, h;
str s, t;

signed main(){
    incant();
    while(cin >> a >> b >> k){
        int res = 0, cnt = 0, sum = 0, mx = -INF, mn = INF;
        bool flag = true;
        rev(i, min(a, b) + 1, 1){
            if(a % i == 0 && b % i == 0){
                k--;
                if(k == 0){
                    print(i);
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long m, long long n)
{
  while (m>0&&n>0){
    n = n % m;
    if (n>0)
      m = m % n;
  }
  if (n==0)
    return m;
  else
    return n;
}
int main()
{
  long long n,i,j,k,t,res=0;
  cin >> n;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++){
      t=gcd(i,j);
      for(k=1;k<=n;k++)
        res+=gcd(t,k);
    }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3172