akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	if (A <= 5) {
		cout << 0 << endl;
	}
	else if (6 <= A && A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << B << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		if (n == 1) { Console.WriteLine(1); return; }

		var l = new List<string>();
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++)
			{
				var p = ps[i][0] - ps[j][0];
				var q = ps[i][1] - ps[j][1];
				if (p == 0) q = Math.Abs(q);
				else if (p < 0) { p = -p; q = -q; }
				l.Add($"{p} {q}");
			}
		Console.WriteLine(n - l.GroupBy(x => x).Max(g => g.Count()));
	}
}


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

int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		int r, t; scanf("%d%d", &r, &t);
		if (r % 100 == 0) {
			if (t % 30 == 0)printf("%d\n", r / 100 + 5 * (t / 30));
			else printf("%d %d\n", r / 100 + 5 * (t / 30), r / 100 + 5 * (t / 30 + 1));
		}
		else if (t % 30 == 0)printf("%d %d\n", r / 100 + 5 * (t / 30), r / 100 + 1 + 5 * (t / 30));
		else printf("%d %d %d %d\n", r / 100 + 5 * (t / 30), r / 100 + 1 + 5 * (t / 30), r / 100 + 5 * (t / 30 + 1), r / 100 + 1 + 5 * (t / 30 + 1));
	}
}

Measured memory_bytes: 3200
#include <iostream>
 
using namespace std;
 
int K, N;
int ans[300005];
int t;
 
void prev(int a[])
{
	a[t]--;
	if(a[t] == 0) t--;
	else{
		for(int i = t+1;i < N; i++) a[i] = K;
		t = N-1;
	}
}
 
int main(void)
{
	cin >> K >> N;
	if(K % 2 == 0){
		cout << K/2 << " ";
		for(int i = 2; i <= N; i++){
			cout << K;
			if(i != N) cout << " ";
		}
		cout << endl;
		return 0;
	}
	
	for(int i = 0; i < N; i++) ans[i] = K/2+1;
	
	t = N-1;
	for(int i = 0; i < N/2; i++) prev(ans);
	
	for(int i = 0; i < N; i++){
		if(ans[i] == 0){
			i = N;
			continue;
		}
		cout << ans[i];
		if(i != N-1) cout << " ";
	}
	cout << endl;
	return 0;
}

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

using namespace std;

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

 int a[100][100];
 for(int i=0;i<n;i++)
  for(int j=0;j<m;j++) cin>>a[i][j];

 int b[100][100];
 for(int i=0;i<m;i++)
  for(int j=0;j<l;j++) cin>>b[i][j];
 
 long long c[100][100] = {};
 for(int i=0;i<n;i++)
   for(int j=0;j<l;j++)
     for (int k=0;k<m;k++) c[i][j] += a[i][k] * b[k][j];

 for(int i=0;i<n;i++){
  for(int j=0;j<l;j++){
     if(j) cout<<" ";
     cout<<c[i][j];
   }
   cout<<endl;
}
}


Measured memory_bytes: 3204
main :: IO()
main = do
    n <- getLine 
    a <- map read.words <$> getLine :: IO [Int]
    print( (max_list a) - (min_list a) )

max_list :: (Ord a) => [a] -> a 
max_list [x] = x
max_list (x:xs) = max x (max_list xs)


min_list :: (Ord a) => [a] -> a
min_list [x] = x
min_list (x:xs) = min x (min_list xs)

Measured memory_bytes: 1020
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int main() {
    unsigned long long n,m;
    long long ans=0;
    scanf("%llu %llu", &n,&m);
    if(n%2==0) {
        if(m%2!=0){
            int tmp = (m-n+1)/2;
            if(tmp%2==0) cout << 0 << "\n";
            else cout << 1 << "\n";
        } else {
            int tmp = (m-n)/2;
            if(tmp%2==0) cout << m << "\n";
            else cout << (1^m) << "\n";
        }
    } else {
        if(m%2==0){
            int tmp = (m-n)/2;
            if(tmp%2==0) cout << (n^m) << "\n";
            else cout << (n^m^1) << "\n";
        } else {
            int tmp = (m-n)/2;
            if(tmp%2==0) cout << n << "\n";
            else cout << (1^n) << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<lldo>&ar,lldo in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<lldo>&ar,lldo in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	string str;cin>>str;
	int i,j,n;n=str.size();
	bool cha=false;
	for(i=0;i<n-1;i++){
		if(str[i]!=str[i+1]){cha=true;break;}
	}
	if(!cha){cout<<1<<endl;return 0;}
	if(n==2){
		if(str[0]==str[1]){cout<<1<<endl;}
		else{cout<<2<<endl;}
		return 0;
	}
	if(n==3){
		if(str[0]==str[1]&&str[1]==str[2]){cout<<1<<endl;}
		else if(str[0]!=str[1]&&str[1]!=str[2]&&str[2]!=str[0]){cout<<3<<endl;}
		else if(str[0]==str[2]){cout<<7<<endl;}
		else{cout<<6<<endl;}
		return 0;
	}
	llint ans=1;
	for(i=0;i<n-1;i++){
		if(str[i]==str[i+1]){ans=0;break;}
	}
	llint san=1;
	llint dp[3][3]={0};
	//wa,saigo
	dp[0][0]=1;dp[1][1]=1;dp[2][2]=1;
	for(i=0;i<n-1;i++){
		san*=3;san%=mod;
		llint ddp[3][3]={0};
		for(int a=0;a<3;a++){
			for(int b=0;b<3;b++){
				ddp[(a+b)%3][b]+=dp[a][(b+1)%3];
				ddp[(a+b)%3][b]+=dp[a][(b+2)%3];
				ddp[(a+b)%3][b]%=mod;
			}
		}
		swap(dp,ddp);
	}
	llint wa=0;
	for(i=0;i<n;i++){wa+=str[i]-'a';}
	wa%=3;
	ans-=dp[wa][0];
	ans-=dp[wa][1];
	ans-=dp[wa][2];
	ans+=mod*10;
	ans+=san;
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll N,K; cin>>N>>K;
    vector<ll> A(N); rep(i,N)cin>>A.at(i);

    ll left = 0, right = 1e9;
    while(right-left>1){
        ll mid = left + (right-left)/2;
        ll cnt = 0;
        rep(i,N){
            cnt += (A.at(i)-1)/mid;
        }
        if(cnt<=K)right = mid;
        else left = mid;
    }
    cout<<right<<endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  
  if (a==b && b==c){
    cout<<1<<endl;
  }
  else if(a==b || b==c || a==c) {
    cout<< 2<<endl;
  }
  else{
    cout<<3<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  vector<long long> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  long long maxi = 0;
  int match = 0;
  for (int i=0; i<n; i++) {
    if (a.at(i) > maxi) {
      maxi = a.at(i);
      match = i;
    }
  }
  long long r = 0;
  double half = maxi / 2.0, diff = 1e10;
  for (int i=0; i<n; i++) {
    if (i == match) continue;
    if (fabs(a.at(i)-half) < diff) {
      r = a.at(i);
      diff = fabs(a.at(i)-half);
    }
  }
  cout << maxi << " " << r << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
    List<String> H = Arrays.asList("Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun");
    Scanner sc;
    Main() {
        sc = new Scanner(System.in);
    }
    public static void main(String[] args) {
        new Main().run();
    }
    int n;
    String[] hs;
    boolean init() {
        n = sc.nextInt();
        if (n == 0) return false;
        hs = new String[n];
        for (int i = 0; i < n; i++) {
            hs[i] = sc.next();
        }
        return true;
    }
    void run() {
        while (init()) {
            boolean end = false;
            for (int i = 0; i < n; i++) {
                boolean won = false;
                boolean defeated = false;
                for (int j = 0; j < n; j++) {
                    int a = H.indexOf(hs[i]);
                    int b = H.indexOf(hs[j]);
                    if (a == b) continue;
                    if ((a+15-b) % 15 <= 7) {
                        //System.out.println(hs[i] + " defeated by " + hs[j]);
                        defeated = true;
                    }
                    else if ((a+15-b) % 15 >= 8)
                        won = true;
                }
                if (won && (!defeated)) {
                    System.out.println(hs[i]);
                    end = true;
                    break;
                }
            }
            if (!end) {
                System.out.println("Draw");
            }
        }
    }
}

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

int main() {
    int a, b;
    while (cin >> a >> b) {
        int t = a + b;
        int cnt = 0;
        while (t) {
            cnt++;
            t /= 10;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n;cin>>n;
    vl a(3*n);rep(i,3*n)cin>>a[i];
    vl l(3*n,-LINF);
    ll sum=0;
    priority_queue<ll,vl,greater<ll>> pq1;
    rep(i,n){
        sum+=a[i];
        pq1.push(a[i]);
    }
    //cout<<sum<<endl;
    l[n-1]=sum;
    for(int i=n;i<2*n;i++){
        sum+=a[i];
        pq1.push(a[i]);
        ll num=pq1.top();
        pq1.pop();
        sum-=num;
        l[i]=sum;
    }
    vl r(3*n,LINF);
    priority_queue<ll,vl> pq2;
    sum=0;
    for(int i=3*n-1;i>=2*n;i--){
        sum+=a[i];
        pq2.push(a[i]);
    }
    r[2*n]=sum;
    for(int i=2*n-1;i>=n;i--){
        sum+=a[i];
        pq2.push(a[i]);
        ll num=pq2.top();
        pq2.pop();
        sum-=num;
        r[i]=sum;
    }
    ll ans=-LINF;
    
    for(int i=n-1;i<=2*n-1;i++){
        //cout<<"i: "<<i<<endl;
        //cout<<l[i]<<" "<<r[i+1]<<endl;
        chmax(ans,l[i]-r[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int MAX = 200010;
  ll a[200010] = {};
  int n;
  cin >> n;
  VI v(n);

  REP(i, n) {
    int tmp;
    cin >> tmp;
    v[i] = tmp;
    a[tmp]++;
  }

  ll sum = 0;
  REP(i, MAX) {
    sum += a[i] * (a[i] - 1) / 2;
  }
  // ANS(sum);

  REP(i, n) {
    int num = v[i];
    ll tmp = sum;
    tmp -= a[num] * (a[num] - 1) / 2;
    tmp += (a[num] - 1) * (a[num] - 2) / 2;
    ANS(tmp);
  }

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

    int t = pow(2, m);
    int x = (1900 * m + 100 * (n - m)) * t;

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int kN = 30;
int N, x[kN], y[kN], r[kN], c[kN], cross[kN];
char dp[(1<<24)+1];

int rec(int S) {
  if (dp[S] >= 0) return dp[S];
  int ret = 0;
  for (int i = 0; i < N; ++i) {
    if (S >> i & 1) continue;
    if (S != (S | cross[i])) continue;
    for (int j = i+1; j < N; ++j) {
      if (S >> j & 1) continue;
      if (c[i] != c[j]) continue;
      if (S != (S | cross[j])) continue;
      ret = max(ret, rec(S|(1<<i)|(1<<j)) +2);
    }
  }
  return dp[S] = ret;
}

int solve() {
  memset(cross, 0, sizeof (cross));
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      int dx = x[i] - x[j], dy = y[i] - y[j], ur = r[i] + r[j];
      if (dx*dx + dy*dy < ur*ur)
        cross[j] |= (1<<i);
    }
  }
  memset(dp, -1, sizeof dp);
  // rep(i,N) {
  //   printf("%d : %d\n", i, cross[i]);
  // }
  return rec(0);
}

int main() {
  while (scanf("%d", &N), N) {
    rep(i,N) scanf("%d%d%d%d", x+i, y+i, r+i, c+i);
    printf("%d\n", solve());
  }
  return 0;
}    

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
priority_queue<double ,vector<double>,greater<double> >pq;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		double k;
		cin>>k;
		pq.push(k);
	}
	while(pq.size()>1){
		double a=pq.top();
		pq.pop();
		double b=pq.top();
		pq.pop();
		double c=(a+b)/2.0;
		pq.push(c);
	}
	printf("%lf",pq.top());
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int main()
{
	ll X;
	cin >> X;
	ll K = (sqrt(8 * X + 1) - 1) / 2.0 - 1;
//	print(K)
	ll t = K;
	for (;; t++)
	{
//		print(t)
		if (t*(t+1) >= 2*X)
		{
			break;
		}
	}
	cout << t;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        double PI = Math.PI;
        double rad_A = 2 * PI / (12 * 60.0) * (H * 60.0 + M);
        double rad_B = 2 * PI / 60.0 * M;

        double rad = rad_A - rad_B;
        if(rad < 0) rad = -rad;
        if(rad > PI) rad = 2 * PI - rad;
        
        double C = Math.sqrt( A*A + B*B - 2*A*B*Math.cos( rad ) );
        System.out.println( C );
    }
}

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

int main(){
  int N, count = 0, d = 1, i;
  cin >> N;
  int nn[N-1];
  for(i = 0; i<N; i++){
    cin >> nn[i];
  }
  while(d){
  for(i = 0; i<N; i++){
    if(nn[i]%2 == 1){
      d = 0;
    }
    nn[i] = nn[i]/2;
  }
    if(d == 0) break;
    count += 1;
  }
  cout << count;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

  rep(i, 9) {
    rep(j, 9){
      if(n == (i+1)*(j+1)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
const Int MAX = 20;
Int dp[MAX][MAX]={};

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

  Int n;
  cin>>n;
  auto as=read<string>(n);

  Int ans=0;
  for(string s:as){
    Int res=0;
    if(s.find(".")==string::npos){
      res=stoll(s)*Int(1e9);
    }else{
      Int k=s.find(".");
      string x=s.substr(0,k);
      string y=s.substr(k+1);

      y+=string(9-y.size(),'0');
      while(y[0]==0) y.erase(y.begin());

      res=stoll(x)*Int(1e9)+stoll(y);
    }

    Int a=0,b=0;
    // cout<<res<<endl;
    while(res%2==0) res/=2,a++;
    while(res%5==0) res/=5,b++;

    chmin(a,MAX-1);
    chmin(b,MAX-1);

    // cout<<a<<' '<<b<<endl;

    for(Int i=0;i<MAX;i++)
      for(Int j=0;j<MAX;j++)
        if(a+i>=18 and b+j>=18) ans+=dp[i][j];

    // cout<<ans<<endl;
    dp[a][b]++;
  }

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


Measured memory_bytes: 9516
#include <bits/stdc++.h>
#define N 998244353
#define MAX 300001
using namespace std;

long long r, b, n, k, ans = 0;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

int main() {
  long long i;
  cin >> n >> r >> b >> k;
  smodfact();
  for(i = 0; i <= k; i += r) {
    if((k - i) % b == 0 && (k - i) / b <= n && i / r <= n)
      ans +=
          calccomb(n, i / r) * calccomb(n, (k - i) / b) % N;
    ans %= N;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int n, w; cin >> n >> w;
    vi a(n), b(n);
    F0R (i, n) cin >> a[i] >> b[i];
    
    // vector<vll> dp(w + 1, vll(n + 1, 0));
    // FOR (i, 1, w) {
    //     FOR (j, 1, n) {
    //         if (a[j - 1] <= i) {
    //             dp[i][j] = max(dp[i][j - 1], b[j - 1] + dp[i - a[j - 1]][j - 1]);
    //         } else {
    //             dp[i][j] = dp[i][j - 1];
    //         }
    //     }
    // }
    // cout << dp[w][n] << endl;

    vector<vll> dp(n + 1, vll(w + 1, 0));
    FOR (i, 1, n) {
        FOR (j, 1, w) {
            if (a[i - 1] <= j) {
                dp[i][j] = max(dp[i - 1][j], b[i - 1] + dp[i - 1][j - a[i - 1]]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}



void solve()
{
    int n, k;
    cin>>n>>k;
    int cnt[n+1];
    reset(cnt);
    for(int i=0;i<k;i++)
    {
        int d;
        cin>>d;
        for(int  j=0;j<d;j++)
        {
            int p;
            cin>>p;
            cnt[p]++;
        }
    }
    int sm=0;
    for(int i=1;i<=n;i++)
        if(cnt[i]==0)
            sm++;
    cout<<sm<<endl;
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    long int N,i,j;
    cin >> N;
    long int n[201010];
    long int m[201010];
    for(i=0;i<N-1;++i){
       cin >> n[i];
      
    }
     for(i=0;i<N-1;++i){
     
       m[n[i]-1]++;
    }
    for (j=0;j<N;++j){
        
         cout << m[j] << "\n";
    

    }   
    
  return 0;
}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG



signed main() {
  int N, M; cin >> N >> M;
  
  unordered_map<int,int> s, g;
  rep(i, M) {
    int a, b; cin >> a >> b;
    if(a == 1) s[b]++;
    if(b == N) g[a]++;
  }
  
  for(auto p : s) {
    if(g[p.first] > 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  
}


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

int main()
{
	while (true)
	{
		int H, W;
		cin >> H>> W;

		if (H == 0 && W == 0)
		{
			break;
		}
		
		for (int i = 0;i < H;i++)
		{
			for (int j = 0;j < W;j++)
			{
				cout << "#";
			}
			cout << '\n';
		}
		cout << '\n';
	}

	return 0;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
using namespace std;
const int MAXN=55;
typedef pair<int,int> pii;
vector<pii> ans;
int a[MAXN];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	int mx=-1,num=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(abs(a[i])>mx)
			num=i,mx=abs(a[i]);
	}
	ans.pb(mp(num,num));
	a[num]+=a[num];
	for(int i=1;i<=n;i++)
	{
		if(i!=num)
		{
			a[i]+=a[num];
			ans.pb(mp(num,i));

		}
	}
	if(a[num]>=0)
	{
		for(int i=2;i<=n;i++)
		{
			if(a[i]>=a[i-1])
			{
				continue;
			}
			else
			{
				a[i]+=a[i-1];
				ans.pb(mp(i-1,i));
			}
		}
	}
	else
	{
		for(int i=n-1;i>=1;i--)
		{
			if(a[i]<=a[i+1])
			{
				continue;
			}
			else
			{
				a[i]+=a[i+1];
				ans.pb(mp(i+1,i));
			}
		}
	}
	printf("%d\n",ans.size());
	for(auto i:ans)
	{
		printf("%d %d\n",i.xx,i.yy);
	}
	return 0;
}


Measured memory_bytes: 256
def counting_sort(A, B, k):
    len_A = len(A)

    C = [0 for _ in range(k + 1)]

    for j in range(len_A):
        C[A[j]] += 1

    for i in range(1, k + 1):
        C[i] = C[i] + C[i - 1]

    for j in range(len_A - 1, -1, -1):
        B[C[A[j]] - 1] = A[j]
        C[A[j]] -= 1


n = int(input())
input_list = list(map(int, input().split(' ')))

B = [0 for _ in range(n)]

counting_sort(input_list, B, max(input_list) + 1)

print(*B)


Measured memory_bytes: 224388
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String r=br.readLine();
		double i=Double.parseDouble(r);
		double p =Math.PI;
		double s=i*i*p;
		double l=p*2*i;
		System.out.printf("%f %f",s,l);
	
	}
	}

Measured memory_bytes: 17100
lines = STDIN.readlines
n = lines[0].chomp.to_i
h = lines[1].split(" ").map(&:to_i).reverse

(n-1).times do |i|
    if h[i + 1] - h[i] > 1
      puts "No"
      exit
    end

    if h[i+1] - h[i] == 1
      h[i + 1] -= 1
      next
    end
end

puts "Yes"


Measured memory_bytes: 9348
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    
    N--;
    for(int i = -N; i <= N; i += 2) {
        int free = (N - abs(i))/2 * (D - C);
        int lower = min(A + C * i, A + D * i) - free;
        int upper = max(A + C * i, A + D * i) + free;
        //cout << i << " " << lower << " " << upper << endl;
        if(lower <= B && B <= upper) {
            cout << "YES" << endl;
            return 0;
        }
        
    }
    cout << "NO" << endl;


    return 0;
}


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

int main(){
  string s;
  cin>>s;
  int left=0,right=0;
  for(int i=0;i<s.size();i+=2){
    if(s[i]=='0'){
      left++;
    }
    else if(s[i]=='1'){
      right++;
    }
  }
  for(int i=1;i<s.size();i+=2){
    if(s[i]=='1'){
      left++;
    }
    else if(s[i]=='0'){
      right++;
    }
  }
  cout<<min(left,right)<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int n, i, j;
    ll answer = 0;
	cin >> n;
	unordered_map<string, long long> input;
	for (i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		sort(tmp.begin(), tmp.end());
		auto itr_f = input.find(tmp);
		if (itr_f == input.end())
			input[tmp] = 0;
		else
			itr_f->second += 1;
	}

	auto itr = input.begin();
	for (; itr != input.end(); itr++) 
		answer += ((itr->second + 1) * itr->second) / 2;
	
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if ((A + B) < (C - 1))
    {
        cout << A + B + 1 + B << endl;
    }
    else
    {
        cout << B + C << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int, C: int, X: int, Y: int):
    a = A * X + B * Y
    minv = min(X, Y)
    b = C * 2 * minv + A * (X - minv) + B * (Y - minv)
    c = 2 * max(X, Y) * C

    return min(a, b, c)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    result = solve(A, B, C, X, Y)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5252
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = list(input())
ans = 0
for t in s:
    if t == '+':
        ans += 1
    else:
        ans -= 1
print(ans)

Measured memory_bytes: 38256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N;
	std::cin >> N;
	int c = 0;
	for (int i : boost::irange(1, N + 1))
	{
		int a;
		std::cin >> a;
		if (i != a)
		{
			++c;
		}
	}
	if (c <= 2)
	{
		std::cout << "YES" << std::endl;
	}
	else
	{
		std::cout << "NO" << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
import sys
import collections
input = sys.stdin.readline
q = int(input())
A = collections.deque()
cursol = 0
# print('-----')
for i in range(q):
    query = input().split()
    if query[0] == '0':
        A.appendleft(query[1])
    elif query[0] == '1':
        A.rotate(-int(query[1]))
        cursol += int(query[1])
    elif query[0] == '2':
        A.popleft()
    # print(A)
A.rotate(cursol)
for a in A:
    print(a)


Measured memory_bytes: 35592
import numpy as np

H,W = map(int,input().split())
hw = np.array([list(input()) for _ in range(H)])

gyo = np.all(hw == ".",axis=1)
retu= np.all(hw == ".",axis=0)

for i in range(H):
	if not gyo[i]==True:
		for j in range(W):
			if not retu[j]==True:
				print(hw[i][j],end="")
		print()

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

int main(){
    long long N,A,B,count[51][51];
    cin >> N >> A >> B;
    vector<long long> v(N);
    for(int i=0;i<N;i++) cin >> v[i];
    long long dp[51][51];
    for(int i=0;i<N+1;i++){ 
        dp[0][i]=0;
        count[0][i]=1;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N+1;j++){
            dp[i+1][j]=dp[i][j];
            count[i+1][j]=count[i][j];
            if(j<=i+1&&j>0){
                long long left=dp[i][j];
                long long right=dp[i][j-1]+v[i];
                if(left==right) count[i+1][j]=count[i][j]+count[i][j-1];
                else if(left<right) count[i+1][j]=count[i][j-1];
                dp[i+1][j]=max(left,right);
            } 
        }
    }
    long long ans_a = 0, ans_b = 1, all = 0; // ans = ans_a / ans_b;
    for(int i = A; i <=B; i++){
      long long a = dp[N][i];
      if(a * ans_b > ans_a * i){
        ans_a = a;
        ans_b = i;
        all = count[N][i];
      }else if(a * ans_b == ans_a * i){
        all += count[N][i];
      }
    }
    double ans = (double)ans_a / (double) ans_b;
    printf("%.16f\n%lld",ans,all);
}


Measured memory_bytes: 256
let f c1 c2 c3 c4 c5 c6 c7 c8 c9 = String.concat "" [String.make 1 c1; String.make 1 c5; String. make 1 c9];;
let () = Scanf.scanf "%c%c%c %c%c%c %c%c%c" f
|> Printf.printf "%s\n"

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

bool f2(ll v) {
  if (v <= 2) {
    return true;
  }

  bool ans = true;
  for (ll i = 2; i * i <= v; ++i) {
    if (v % i == 0) {
      ans = false;
      break;
    }
  }

  return ans;
}

vector<ll> f(ll v) {
  vector<ll> ans;
  for (ll i = 2; i * i <= v; ++i) {
    if (v % i == 0) {
      ans.push_back(i);
      if (i * i != v)
        ans.push_back(v / i);
    }
  }
  return ans;
}

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

  ll N;
  cin >> N;
  vector<ll> y = f(N);
  y.push_back(N);
  sort(y.begin(), y.end());

  // for (ll i : y) {
  //   cout << i << ",";
  // }
  // cout << endl;

  vector<ll> p;
  for (ll i : y) {
    if (f2(i)) {
      p.push_back(i);
    }
  }

  // for (ll i : p) {
  //   cout << i << ",";
  // }
  // cout << endl;

  vector<ll> p2(p);
  for (ll v : p) {
    ll v2 = v * v;
    if (v2 < 0) {
      continue;
    }
    while (v2 < N) {
      p2.push_back(v2);
      v2 *= v;
      if (v2 < 0) {
        break;
      }
    }
  }
  sort(p2.begin(), p2.end());

  // for (ll i : p2) {
  //   cout << i << ",";
  // }
  // cout << endl;

  ll ans = 0;
  ll c = 0;
  ll idx_mx = p2.size();
  while (N > 1 && c < idx_mx) {
    bool flg = false;
    for (int i = 0; i < idx_mx; ++i) {
      if (p2.at(i) == -1) {
        continue;
      }
      if (N % p2.at(i) == 0) {
        N /= p2.at(i);
        p2.at(i) = -1;
        flg = true;
        break;
      }
    }
    if (!flg) {
      break;
    }

    ++c;
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[101010];
ll k[101010];
ll b[101010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin>>N>>X;
    ans =1;
    ll num = 0;
    rep(i,0,N){
        cin>>l[i];
        num+=l[i];
        if(num>X)break;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
int main() {
	ll a,b;
	cin>>a>>b;
	if(b==1){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	ll n = a;
	while(1){
		if(n>=b)break;
		ans++;
		n += a-1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
typedef long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  int N, M;
  scanf("%d%d", &N, &M);

  printf("%d", N * (N - 1) / 2 + M * (M - 1) / 2);

  return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;

int main(){

    string s; cin >> s;

    int min = 1000;
    for(int i=0; i<s.length()-2; i++){
        int temp = abs(stoi(s.substr(i,3)) - 753);
        if (min > temp){
            min = temp;
        }
    }

    cout << min;

    return 0;
}

Measured memory_bytes: 764
def main():
    N, T = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    dp = [-1] * (T + 3000)
    dp[0] = 0
    c = 0
    for a, b in sorted(AB):
        for j in range(c, -1, -1):
            if dp[j] == -1:
                continue
            t = dp[j] + b
            if dp[j + a] < t:
                dp[j + a] = t
        c = min(c + a, T - 1)
    print(max(dp))


main()


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

int main(int argc, char const *argv[])
{
  string w;
  cin >> w;
  bool b = true;

  for(char ch = 'a'; ch <= 'z'; ch++)
  {
    int num = 0;
    for(int i = 0; i < w.length(); i++)
    {
      if(w[i] == ch)
        num++;
    }
    if(num % 2 != 0)
    {
      b = false;
      break;
    }
  }
  cout << (b ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, Y;
int main(){
	scanf("%lld %lld", &N, &Y);
	for(ll i = 0; i <= 2000; i++){
		for(ll j = 0; j <= 2000; j++){
			if(i + j > N)	break;
			if(i * 10000 + j * 5000 + (N - i - j) * 1000 == Y){
				printf("%lld %lld %lld\n", i, j, N - i - j);
				return 0;
			}
		}
	}
	puts("-1 -1 -1");
}

Measured memory_bytes: 256
s = input()
s = s[::-1]
li = ['maerd', 'remaerd', 'esare', 'resare']
t = ''

for i in range(len(s)):
  t = t + s[i]
  for c in li:
    if t == c:
      t = ''

if t == '':
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string word;
  cin >> word;
  sort(word.begin(),word.end());
  bool judge=false;
  if(word.size()%2==0){
    for(int i=0;i<word.size();i+=2){
      if(word.at(i)!=word.at(i+1)){
        judge=true;
        break;
      }
    }
  }
  if(word.size()%2!=0){
    judge=true;
  }
  
  if(judge){
    cout << "No" << endl;
  }
  if(judge==false){
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
int main() {
	string s;
	int a = 0, b = 0;
	cin >> s;
	rep(i, 0, 3) {
		if (s[i] == 'A')a++;
		if (s[i] == 'B')b++;
	}
	Yes(a&&b)
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

val MAX = 86
fun main(args: Array<String>) {
    
    val n = readInt()
    val dp = (0..86).map { 0L }.toMutableList()
    dp[0] = 2L
    dp[1] = 1L
    for(i in 2..86) {
        dp[i] = dp[i-1] + dp[i-2]
    }
    println(dp[n])

    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 33688
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	double L;
	cin>>L;
	DBG("","","","");
	double a;
	a=L/3;
	cout<<fixed << setprecision(14)<<(a*a*a)<<endl;
	return 0;
}


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

int nex[100005],pre[100005];
int a[100005];

int head = 0,tail;
int n, q, tmp1, tmp2;
	
void print(){
	int p=nex[head];
	int a=0;
	while( p != tail){
		if(a)cout<<' ';
		a++;
		cout<<p;
		p=nex[p];
	}
	cout<<endl;
}

int main(void){
	cin >> n >> q;
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	tail = n+1;
	a[0] = 0; a[n+1] = n+1;
	for(int i = 1; i < n+1; ++i){
		cin >> a[i];
	}
	for(int i = 0; i <= n+1; ++i){
		nex[a[i]] = a[i+1];
		pre[a[i+1]] = a[i];
	}
	//print();
	for(int i = 0 ; i < q; ++i){
		int id;
		cin >> id;
		if(pre[tail] == id){
			int a = nex[head];
			int b = pre[id];
			nex[head] = id;
			pre[id] = head;
			nex[id] = a;
			pre[a] = id;
			nex[b] = tail;
			pre[tail] = b;
		}else if(nex[head] == id){
			int c = nex[id];
			int d = pre[tail];
			nex[head] = c;
			pre[c] = head;
			nex[d] = id;
			pre[id] = d;
			nex[id] = tail;
			pre[tail] = id;
		}else{
			int a = nex[head];
			int b = pre[id];
			int c = nex[id];
			int d = pre[tail];
			nex[id] = a;
			pre[id] = d;
			pre[a] = id;
			nex[d] = id;
			pre[c] = head;
			nex[head] = c;
			nex[b] = tail;
			pre[tail] = b;
		}
		//print();
	}
	print();
	// for(int i = 0 ; i < n; ++i){
	// 	cin >> tmp1;
	// 	if(i == 0){
	// 		pre[tmp1] = 0;
	// 	}else{
	// 		pre[tmp1] = tmp2;
	// 	}
	// 	if(i == n-1){
	// 		nex[tmp1] = n+1;
	// 	}else{
	// 		nex[tmp2] = tmp1;
	// 	}
	// 	tmp2 = tmp1;
	// }

	// for(int i = 1; i <= n+1;++i){
	// 	cout << pre[i] << " ";
	// }
	// cout << endl;
	return 0;
}


Measured memory_bytes: 4268