akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<vector<ll>> graph(n);
    for (ll i = 0; i < n - 1; i++)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    ll ans = 1;
    ll tmp;
    stack<pair<ll, ll>> st;
    st.push(make_pair(-1, 0));

    while (!st.empty())
    {
        // cout << "hoge" << endl;
        auto p = st.top();
        st.pop();
        if (p.first == -1)
        {
            tmp = k - 1;
        }
        else
        {
            tmp = k - 2;
        }
        if (k < graph[p.second].size())
        {
            cout << 0 << endl;
            return 0;
        }
        for (auto v : graph[p.second])
        {
            if (v == p.first)
            {
                continue;
            }
            ans = ans * tmp % MOD;
            tmp--;
        }
        for (auto v : graph[p.second])
        {
            if (v == p.first)
            {
                continue;
            }
            st.push(make_pair(p.second, v));
        }
    }
    ans = k * ans % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 8180
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = 1123456789012345678;

long n;

int main(){
	scanf("%ld", &n);
	if(n%2 == 0){
		printf("%ld\n", n*(n-2)/2);
		for(int i = 1; i <= n; i++){
			for(int j = i+1; j <= n; j++){
				if(i+j != n+1){
					printf("%d %d\n", i, j);
				}
			}
		}
	}else{
		printf("%ld\n", (n-1)*(n-1)/2);
		for(int i = 1; i <= n-1; i++){
			for(int j = i+1; j <= n-1; j++){
				if(i+j != n){
					printf("%d %d\n", i, j);
				}
			}
			printf("%d %d\n", i, n);
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A+B>=C){
        cout << B+C << endl;
    }else{
        cout << A+B+1+B << endl;
    }
    
    return 0;
}   


Measured memory_bytes: 256
#include<iostream>
    #include<string>
    #include<cmath>
    using namespace std;
     
    int main(){
     
      int n,k,x,y,a;
      cin>>n>>k>>x>>y;
      a=0;
        if(n<=k){
          a=x*n;
        }else{
          a=x*k+y*(n-k);
    	}
      cout<<a<<endl;
     
    }

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int x, y, k;
   
    while(1){
        scanf("%d %d\n", &x, &y);
    
        if(x==0 && y==0){
            break;
        }
        
        if(x>y){
            k = x;
            x = y;
            y = k;
        }
        
        printf("%d %d\n", x, y);
    }
    
    return 0;    
}





Measured memory_bytes: 2044
from sys import stdin
input = stdin.readline

while True:
    n, x = map(int, input().split())
    ans = 0

    if n == 0 and x == 0:
        break

    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    ans += 1

    print(ans)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
int A[1 << 18 + 1];
int mx1[1 << 18], mx2[1 << 18];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < (1 << N); ++i){
        cin >> A[i];
        mx1[i] = 1 << 18; 
        mx2[i] = 1 << 18; 
    }
    mx1[0] = 0;

    int ans = 0;
    for(int i = 1; i < (1 << N); ++i){
        mx1[i] = i;
        for(int j = 0; j < N; ++j){
            if(i >> j & 1){
                int to = i ^ 1 << j;

                auto update = [&i](int idx){
                    if(A[idx] > A[mx1[i]]) mx2[i] = mx1[i], mx1[i] = idx;
                    else if(idx != mx1[i] && A[idx] > A[mx2[i]]) mx2[i] = idx;
                };

                update(mx1[to]);
                update(mx2[to]);
            }
        }
        chmax(ans, A[mx1[i]] + A[mx2[i]]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int INIT, MAX;
  while(cin >> INIT >> MAX && (INIT || MAX)){
    int H, W;
    cin >> H >> W;
    string grid[100];
    REP(i, H) cin >> grid[i];

    int T;
    cin >> T;
    int damage[256];
    REP(i, T){
      string s;
      cin >> s;
      cin >> damage[s[0]];
    }

    int S;
    cin >> S;
    string dir[1000];
    int step[1000];
    REP(i, S) cin >> dir[i] >> step[i];

    string DIRS = "RDLU";

    int P;
    cin >> P;
    int potion[15];
    REP(i, P) cin >> potion[i];

    int x = 0, y = 0;
    int hp[1 << 12] = {};
    hp[(1 << P) - 1] = INIT;
    REP(i, S){
      int r;
      for(r = 0; r < 4; r++) if(DIRS[r] == dir[i][0]) break;

      REP(_, step[i]){
        int nx = x + dx[r];
        int ny = y + dy[r];
        assert(valid(nx, ny, W, H));
        int d = damage[grid[ny][nx]];

        int nhp[1 << 12] = {};
        for(int s = (1 << P) - 1; s >= 0; s--)if(hp[s] > 0){
          int hp2 = hp[s] - d;
          if(hp2 > 0){
            nhp[s] = hp2;
          }else{
            for(int j = 0; j < P; j++)if(s >> j & 1){
              int hp2 = min(MAX, hp[s] + potion[j]);
              hp[s & ~(1 << j)] = max(hp[s & ~(1 << j)], hp2);
            }
          }
        }

        REP(s, 1 << P) hp[s] = nhp[s];
        x = nx, y = ny;
      }
    }

    bool ok = false;
    REP(s, 1 << P) if( hp[s] > 0 ) ok = true;
    cout << (ok ? "YES" : "NO") << endl;
  }
  return 0;
}

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



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

    long long a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;

    long long r=0;

    if(a+b>2*c)
    {
        long long v=min(x,y);
        x-=v;
        y-=v;
        r+=2*c*v;
    }
    if(x>0)
    {
        if(a>2*c)
        {
            r+=2*c*x;
            y-=x;
            x=0;
        }
        else
        {
            r+=a*x;
            x=0;
        }
    }
    if(y>0)
    {
        if(b>2*c)
        {
            r+=2*c*y;
            x-=y;
            y=0;
        }
        else
        {
            r+=b*y;
            y=0;
        }
    }
    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Linq;
namespace DPL_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            String [] first = Console.ReadLine().Trim().Split(' ');
            var n = 0;
            var w = 0;
            int.TryParse(first[0],out n);
            int.TryParse(first[1],out w);
            int [] valueList = new int [w + 1];
            for (int i = 0; i < n; i++)
            {
                String [] line = Console.ReadLine().Trim().Split(' ');
                var l_v = 0;
                var l_w = 0;
                int.TryParse(line[0], out l_v);
                int.TryParse(line[1], out l_w);
                for (int weight = w; weight > 0; weight--){
                    if(weight >= l_w){
                        valueList[weight] = valueList[weight - l_w] +  l_v > valueList[weight] ? valueList[weight - l_w] +  l_v : valueList[weight];
                    }
                }
            }
            Console.WriteLine(valueList.Max());
            Console.ReadLine();
        }
    }
}



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

int a[105];
int main()
{
	int n,x;
	while(scanf("%d%d",&n,&x)!=EOF){
		int minn = 10000000;
		int sum = 0;
		for(int i=1;i<=n;++i){
			scanf("%d",&a[i]);
			sum += a[i];
			if(a[i]<minn){
				minn = a[i];
			}
		}
		int ans = n+(x-sum)/minn;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int num = Integer.parseInt(br.readLine());
		String[] lengthList = br.readLine().split(" ");

		int numOfCombination = 0;
		for(int i1=0; i1 < num; i1++){
			for(int i2=i1+1; i2 < num; i2++){
				for(int i3=i2+1; i3 < num; i3++){
					int[] lengthArr = new int[]{Integer.parseInt(lengthList[i1]), Integer.parseInt(lengthList[i2]), Integer.parseInt(lengthList[i3])};
					if(canCreateTriangle(lengthArr)){
						numOfCombination++;
					}
				}
			}
		}
		System.out.println(numOfCombination);
	}

	public static boolean canCreateTriangle(int[] lengthArr){
		boolean canCreate = false;
		Arrays.sort(lengthArr);
		if(lengthArr[2] < (lengthArr[0] + lengthArr[1])){
			if(lengthArr[0] != lengthArr[1] && lengthArr[1] != lengthArr[2]){
				canCreate = true;
			}
		}
		return canCreate;
	}
}

Measured memory_bytes: 40928
#include <iostream>
using namespace std;
using ll = long long;
int main() {
	//Product of all even terms...?
	ll n;
	cin>>n; //Every 5 2s gives me 1 5 in middle...
	if(n%2==0) //Even...
	{
		ll c5=0, num = 10;
		while(num <= n)
		{
			c5 += n/num;
			num*=5;
		}
		cout<<c5;
	}
	else
	{
		cout<<0;
	}
	return 0;
}

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

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	int d,t,v;
	cin>>d>>t>>v;
	if(v*t>=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
	return 0;
}

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

class Main {

    void solve(){
	Scanner sc = new Scanner( System.in );

	int[] p1 = new int[3];
	int[] p2 = new int[3];	
	for ( int i=0; i<3; ++i ) p1[i] = sc.nextInt();
	for ( int i=0; i<3; ++i ) p2[i] = sc.nextInt();

	if ( p1[0] > p2[0] ||
	     (p1[0] == p2[0] && (p1[1] > p2[1] || (p1[1] == p2[1] && p1[2] > p2[2]))) ) {
	    int t = p1[0];  p1[0] = p2[0];  p2[0] = t;
	    t = p1[1];  p1[1] = p2[1];  p2[1] = t;	    
	    t = p1[2];  p1[2] = p2[2];  p2[2] = t;	    
	}

	if ( p1[1] < p2[1] || (p1[1] == p2[1] && p1[2] < p2[2]) ) System.out.println( p2[0] - p1[0] + 1 );
	else System.out.println( p2[0] - p1[0] );

    }

    public static void main( String[] a ) { new Main().solve(); }
}



Measured memory_bytes: 26420
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), y = scanner.nextInt(), z = scanner.nextInt(), k = scanner.nextInt();
			long[] a = IntStream.range(0, x).mapToLong(i -> scanner.nextLong()).sorted().toArray();
			long[] b = IntStream.range(0, y).mapToLong(i -> scanner.nextLong()).sorted().toArray();
			long[] c = IntStream.range(0, z).mapToLong(i -> scanner.nextLong()).sorted().toArray();
			long[] sum = new long[k];
			Queue<Sum> queue = new PriorityQueue<>((s1, s2) -> Long.compare(s2.sum, s1.sum));
			Set<Sum> set = new HashSet<>();
			Sum first = new Sum(a[x - 1] + b[y - 1] + c[z - 1], x - 1, y - 1, z - 1);
			queue.add(first);
			set.add(first);
			for (int j = 0; j < k; j++) {
				Sum now = queue.poll();
				sum[j] = now.sum;
				if (now.ia > 0) {
					Sum sum1 = new Sum(a[now.ia - 1] + b[now.ib] + c[now.ic], now.ia - 1, now.ib, now.ic);
					if (!set.contains(sum1)) {
						queue.add(sum1);
						set.add(sum1);
					}
				}
				if (now.ib > 0) {
					Sum sum2 = new Sum(a[now.ia] + b[now.ib - 1] + c[now.ic], now.ia, now.ib - 1, now.ic);
					if (!set.contains(sum2)) {
						queue.add(sum2);
						set.add(sum2);
					}
				}
				if (now.ic > 0) {
					Sum sum3 = new Sum(a[now.ia] + b[now.ib] + c[now.ic - 1], now.ia, now.ib, now.ic - 1);
					if (!set.contains(sum3)) {
						queue.add(sum3);
						set.add(sum3);
					}
				}
			}
			Arrays.stream(sum).forEach(System.out::println);
		}
	}

	/**
	 * sum,ia,ib,icを表すクラス
	 */
	private static class Sum {
		long sum;
		int ia;
		int ib;
		int ic;

		Sum(long sum, int ia, int ib, int ic) {
			super();
			this.sum = sum;
			this.ia = ia;
			this.ib = ib;
			this.ic = ic;
		}

		@Override
		public int hashCode() {
			return Objects.hash(sum, ia, ib, ic);
		}

		@Override
		public boolean equals(Object obj) {
			if (obj instanceof Sum) {
				Sum sum2 = (Sum) obj;
				return (sum == sum2.sum) && (ia == sum2.ia) && (ib == sum2.ib) && (ic == sum2.ic);
			}
			return false;
		}
	}
}


Measured memory_bytes: 44540
S = input()
K = int(input())

S2 = ""
for i in range(len(S)):
    if S[i]=="1":
        S2 += "1"
    else:
        S2 += S[i]*101
        break

if K<100:
    print(S2[K-1])
else:
    print(S2[100])


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

int main() {
	// your code goes here
	int n;long w;
	
	cin>>n>>w;
	
	
	long wt[n],v[n];
	long size=0;
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>v[i];
        size+=v[i];
        
    }
    vector<long long>dp(size+1,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(long j=size-v[i];j>=0;j--)
        {
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+wt[i]);
        }
        
    }
    
    
    long  a=0;
    for(long i=1;i<=size;i++)
    {
        if(dp[i]<=w)
        a=max(a,i);
    }	
    cout<<a;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,a,b; cin >> n >> a >> b;
	vl p(n); rep(i,n) cin >> p[i];
	vl cnt(3,0);
	sort(all(p));
	rep(i,n){
		if(p[i] <= a) cnt[0]++;
		else if(p[i] <= b) cnt[1]++;
		else cnt[2]++;
	}
	cout << *min_element(all(cnt)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,A,B;
	cin >> N >> A >> B;
	cout << min(N*A,B) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
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;}


int main()
{
    ll n;
    cin >> n;
    ll now=26;
    string s="";
    while(n>0){
        char a;
        if(n%26==0){
            a='z';
            n-=26;
        }
        else{
            a = 'a' + (n % 26 - 1);
        }
        n /= 26;
        s.push_back(a);
    }
    reverse(all(s));
    cout << s << endl;
}


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

using namespace std;

using ll = long long;

struct Node {
    Node* go[2];
    Node() {
        go[0] = go[1] = nullptr;
    }
};

Node* root = new Node();
int ans = 0;

int gr(ll x) {
    int ans = 1;
    while (x % 2 == 0) {
        ans++;
        x /= 2;
    }
    return ans;
}

void dfs(Node* v, ll h) {
    if (v == nullptr) {
        return;
    }
    int sm = 0;
    for (int i = 0; i < 2; i++) {
        dfs(v->go[i], h - 1);
        if (!v->go[i]) {
            sm++;
        }
    }
    if (sm == 1) {
        ans ^= gr(h);
    }
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    ll l;
    cin >> l;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        Node* v = root;
        for (int j = 0; j < s.size(); j++) {
            int x = s[j] - '0';
            if (v->go[x] == nullptr) {
                v->go[x] = new Node();
            }
            v = v->go[x];
        }
    }
    dfs(root, l);
    cout << (ans ? "Alice" : "Bob") << "\n";
}




Measured memory_bytes: 8044
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int const MAX_T = 100000;

signed main() {
    int N, C;
    cin >> N >> C;

    bool table[C][MAX_T];
    fill(table[0], table[C], false);

    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        s--; t--; c--;

        for (int time = s; time < t; time++) {
            table[c][time] = true;
        }
    }

    for (int ch = 0; ch < C; ch++) {
        bool flag = false;
        for (int time = MAX_T - 1; time >= 0; time--) {
            if (table[ch][time]) {
                flag = true;
            } else {
                if (flag) {
                    table[ch][time] = true;
                    flag = false;
                }
            }
        }
    }

    int ret = -1;
    for (int time = 0; time < MAX_T; time++) {
        int cnt = 0;
        for (int ch = 0; ch < C; ch++) {
            if (table[ch][time]) cnt++;
        }

        ret = max(ret, cnt);
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; i < n; i++)
#define r(i, k, n) for (int i = k; i >= n; i--)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << ","<< #z << "=" << z << endl
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
// =================

const int mod = 1e9;
const int N = 3e5 + 1;

void solve()
{
    int n;
    cin>>n;
    while (n--)
    {
        cout<<"ACL";
    }
    
     
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3616
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = input()
wol = []
ans = 0
def win(p):
    wol.append(1)
    if T[p]=='r':
        return P
    elif T[p]=='s':
        return R
    else:
        return S

for i in range(N):
    if i<K:
        ans += win(i)
    else:
        if T[i-K]==T[i] and wol[i-K]==1:
            wol.append(0)
        else:
            ans += win(i)
print(ans)

Measured memory_bytes: 4212
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

typedef pair<long long, long long> pl;

long long N, M, k, a, b, c, d, e, H, W,X;
long long A[200000] = {};
long long B[200002] = {};
long long tt[20000] = {};
bool f;
bool ff;
string S, SS;
set <long long>sll;
pl buf;
vector <long long>vpl[100002];
vector <long long>vl;


int main() {
	N = 100000;
	M = 0;
	a = 0;
	for (int i = 0; i < 5; i++) {
		cin >> A[i];
		M += (A[i] / 10) * 10;
		if (A[i] % 10 != 0) {
			M += 10;
			if (A[i] % 10 < N) {
				N = A[i] % 10;
			}
		}
		else {
			a++;
		}
		


	}

	if (a==5) {
		cout << M<<endl;
	}
	else {
		cout <<M+N-10 << endl;
	}

	return 0;
}

Measured memory_bytes: 4352
n = int(input())
l = input().split()
l = list(map(int,l))
c=0

for i in range(n):
  for j in range(i+1,n):
    for h in range(j+1,n):
      if l[i]!=l[j] and l[h]!=l[j] and l[i]!=l[h]:
        a = [l[i],l[j],l[h]]
        #print(a)
        a.sort()
        if a[0]+a[1]>a[2]:
          #print(c,a)
          c+=1
        
print(c)  

Measured memory_bytes: 9200
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  int g = 0, p = 0;
  int SIZE = s.size();
  for (int i = 0; i < SIZE; ++i){
    p += s[i] == 'p';
    g += s[i] == 'g';
  }

  print((g - p) / 2);

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int N,c;
    cin>>N;
    for(int t=1;t<=9;t++)
    {
    	if(N/t<10 && N%t==0)
    	c++;
    	else
    	c+=0;
    }
    if(c==0)
    cout<<"No";
    else
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n ;
  cin >> n;
 int e = 0;
  for (int i = 1; i <= n; i++) {
    int d = i;
    int c = 0;
    while ( d > 0 ) {
      d /= 10;
      c++; } 
    if ( c % 2 == 1 ) {
      e++; } }
    cout << e; }
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int X;
  cin>>X;
  long long Ans=0;
  for(int i=1;i<=X;i++)
    if(i%3&&i%5)
      Ans+=i;
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

int main(void) {
  ll a, b, c;
  cin >> a >> b >> c;

  ll res = b + min(c, b+a+1);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
int A1 = sc.nextInt();
int A2 = sc.nextInt();
if(A1>A2){
    int temp=A1;
    A1=A2;
    A2=temp;
}

int A3 = sc.nextInt();
if(A2>A3){
    int temp=A2;
    A2=A3;
    A3=temp;
}

System.out.println(A1*A2/2);
}
}


Measured memory_bytes: 22612
n=int(input())
a=[int(i) for i in input().split()]
o,q,e=[],[],[]
for i in a:
    if i%4==0: q.append(i)
    elif i%2==0: e.append(i)
    else: o.append(i)
s=0
for i in range(n):
    if s==0:
        if len(o):
            o.pop()
            s=4
        elif len(e):
            e.pop()
            s=2
        else:
            q.pop()
    elif s==2:
        if len(e):
            e.pop()
            s=2
        elif len(q):
            q.pop()
            s=0
        else:
            print("No")
            exit()
    else:
        if len(q):
            q.pop()
            s=0
        else:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 14100
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define repi(a,b) for (int i=a;i<=b;i++)
#define repj(a,b) for (int j=a;j<=b;j++)
#define ll long long

int n,p;
int a[55];
ll f[55][2];

int main()
{
	cin>>n>>p;
	repi(1,n) 
		cin>>a[i];
	
	f[1][0]=((a[1]%2==0)?1:0);
	f[1][1]=((a[1]%2==0)?0:1);
	
	//cout<<f[1][0]<<' '<<f[1][1]<<endl;
	
	repi(2,n)
	{
		repj(i-1,i-1)
		{
			if (a[i]%2==0) //ou
			{
				f[i][0] += 2*f[j][0] + 1;
				f[i][1] += 2*f[j][1];
			}
			else
			{
				f[i][0] += f[j][1] + f[j][0];
				f[i][1] += f[j][0] + f[j][1] + 1; 
			}
		}
	}
	
	//repi(1,n) printf ("(%d,%d) ",f[i][0],f[i][1]);
	if (p==0) cout<<f[n][p]+1<<endl;
	else cout<<f[n][p]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int x, y;
    cin >> x >> y;
    for (int c = 0; c <= x; c++) {
        int t = x - c;
        int tot = 2 * c + 4 * t;
        if (y == tot) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
}


Measured memory_bytes: 3632
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    long long X,K,D;cin >> X >> K >> D;
    long long movement = abs(X)/D;
    long long movement_more = K-movement;
    if(movement <= K){
        if(X > 0){
            long long before = abs(X-D*movement);
            long long after = abs(X-D*(movement+1));
            if(movement_more % 2 == 1){
                cout << after << endl;
            }
            else{
                cout << before << endl;
            }
        }
        else{
            long long before = abs(X+D*movement);
            long long after = abs(X+D*(movement+1));
            if(movement_more % 2 == 1){
                cout << after << endl;
            }
            else{
                cout << before << endl;
            }
        }
        return 0;
    }

    if(X > 0){
        cout << abs(X-K*D) << endl;
    }
    else{
        cout << abs(X+K*D) << endl;
    }
    

}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, a, b);
	OUT(a * b);
}


Measured memory_bytes: 3632
private fun readInts() = readLine()!!.split(" ").map(String::toInt)

private val MOD = 1000000007
private val NOT_YET = -1

fun main(args: Array<String>) {
    val (N, M) = readInts()
    val a = (0 until M).map { readLine()!!.toInt() - 1 } // 0-indexed

    if (N == 1) {
        println(1)
        return
    }

    val ways = Array(N) { NOT_YET }
    for (hole in a) ways[hole] = 0

    ways[0] = if (ways[0] != NOT_YET) 0 else 1
    ways[1] = if (ways[1] != NOT_YET) 0 else ways[0] + 1

    if (N == 2) {
        println(ways[1])
        return
    }

    for (position in 2 until N) {
        if (ways[position] == NOT_YET) {
            ways[position] = (ways[position - 1] + ways[position - 2]) % MOD
        }
    }

    println(ways.last())
}

Measured memory_bytes: 41572
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i =0;i<n;i++)
signed main() {
  int n;cin >> n;
  vector<int> a, b;
  a.reserve(n); b.reserve(n);
  rep(i,n) { int t; cin >> t; a.emplace_back(t); }
  rep(i,n) { int t; cin >> t; b.emplace_back(t); }
  int ans = 0;
  rep(i,n) rep(j,n) {
    ans ^= (a[i] + b[j]);
  }cout << ans << endl;
}

Measured memory_bytes: 4760
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	string s;
	cin >> s;
	cout << "ABC" << s << '\n';
 	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,m;
int main(){
	cin>>n>>m;
	bool ok;
	if(n%2==1){
		n=(n+1)/2;
		// puts("g1");
	}else{
		n=n/2;
		// puts("g2");
	}
		cout<<((n>=m)?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W, A, B;
	cin >> H >> W >> A >> B;
	int A1[H][W];
	rep(i,H){
		rep(j,W){
			A1[i][j] = 0;
		}
	}
	rep(i,B){
		rep(j,A){
			A1[i][j] = 1;
		}
	}
	rep(i,H-B){
		rep(j,W-A){
			A1[B+i][A+j] = 1;
		}
	}
	rep(i,H){
		rep(j,W){
			cout << A1[i][j];
		}
		cout << endl;
	}
}

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

// マクロ群
#define REP(i,n) for(int i=0;i<n;++i)
#define REP2(i,a,b) for (int i=(a);i<(b);++i)
#define rep(n) REP(i,n)
#define SF(f,v) scanf(f,v)
#define SF_N(v) SF("%d",&v)
#define SF_S(v) SF("%s",v)
#define PF(f,v) printf(f,v)
#define PFS_N(v) PF("%d ",v)
#define PFS_S(v) PF("%s ",v)
#define PFL_N(v) PF("%d\n",v)
#define PFL_S(v) PF("%s\n",v)


using namespace std;

const int ARRMAX = 1024;

void removeAt(vector<int>& v, int i, int j)
{
	v.erase(v.begin() + i);
	v.erase(v.begin() + j - 1);
}


void Slove()
{
	int N;
	SF_N(N);
	vector<int> A(N);
	rep(N) SF_N(A[i]);

	while (true)
	{
		int find = -1;

		bool IsAdd = bitset<1>(A[0])[0];

		REP2(i, 1, N) if (IsAdd == bitset<1>(A[i])[0])
		{
			find = i;
			break;
		}

		if (find < 0) break;

		A.push_back(A[0] + A[find]);
		removeAt(A, 0, find);
		N--;
	}

	PFL_S(N == 1 ? "YES" : "NO");
}

int main()
{
	Slove();
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S,W;
		
		S=sc.nextInt();
		W=sc.nextInt();
		
		if(W>=S) System.out.println("unsafe");
		else System.out.println("safe");
	}
}


Measured memory_bytes: 35536
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define anin(a) printf("%d\n",a);
#define ando(a)printf("%lf\n",a);


int main(void){
	int n;
	scanf("%d",&n);
	double A[n],ans(0.);
	rep(i,0,n){
		scanf("%lf",&A[i]);
		ans += 1. / A[i];
	}
	ans = 1. / ans;
	ando(ans);
	return 0;
}


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

int main() {

  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  A = 100 * A;
  B = 100 * B;
  
  double rate = 0;
  int answerWater = 0;
  int answerSuger = 0;
  
  for (int i = 0; i <= F; i++) {
    for (int j = 0; j <= F - i; j++) {
      int water = A * i + B * j;
      if (F < water) {
        continue;
      }
      for (int k = 0; k <= F; k++) {
        for (int l = 0; l <= F - k; l++) {
          int suger = C * k + D * l;
          if ((water * E) < (suger * 100)) {
            continue;
          }
          int sugerWater = water + suger;
          if (F < sugerWater) {
            continue;
          }
          double rate_ = (double) suger / sugerWater * 100;
          if (rate <= rate_) {
            rate = rate_;
            answerWater = sugerWater;
            answerSuger = suger;
          }
        }
      }
    }
  }

  cout << answerWater << " " << answerSuger << endl;

  return 0;

}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
  string s;
  cin >> s;
  
  reverse(s.begin(), s.end());
  for (int i=0; i<4; i++) reverse(divide[i].begin(), divide[i].end());
  
  bool can =true;
  for (int i=0; i<s.size();){
    bool can2 = false;
    for (int j=0; j<4; j++){
      string d = divide[j];
      if (s.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if (!can2){
      can = false;
      break;
    }
  }
  
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        long[][] dp = new long[N+1][W+1];
        for(int i = 1; i <= N; i++){
            int w = sc.nextInt();
            int v = sc.nextInt();
            for(int j = 1; j <= W; j++){
                if(w > j) dp[i][j] = dp[i-1][j];
                else dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w] + v);
            }
        }
        System.out.println(dp[N][W]);
        sc.close();

    }

}


Measured memory_bytes: 126548
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const A_VALUE: usize = 500;
const B_VALUE: usize = 100;
const C_VALUE: usize = 50;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }

    let mut count = 0;

    for i in 0..(a + 1) {
        for j in 0..(b + 1) {
            for k in 0..(c + 1) {
                if (A_VALUE * i + B_VALUE * j + C_VALUE * k) == x {
                    count += 1;
                }
            }
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
const ll INF=9223372036854775807;
const ll mod=1000000007;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int main()
{
    fastio;
    ll n;
    cin>>n;
    vll a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vll cnt(60);
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<60;j++)
        {
            if((a[i]&((ll)1<<j))!=0)
            {
                cnt[j]++;
            }
        }
    }
    ll ans=0;
    for(ll j=0;j<60;j++)
    {
        ans=((ans+(((((ll)(((ll)1<<j)%mod)*(cnt[j]%mod))%mod)*((n-cnt[j])%mod))%mod))%mod);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 2560
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int N;
int dp[105][105];
int candies[105][105];
int finalAns = 0;

int dpOperation(int row, int col)
{
	int INF = 1e9;
	int &ans = dp[row][col];

	if(ans != -1)
	{
		return ans;
	}
	if(col >= N)
	{
		return 0;
	}
	if(row >= 2)
	{
		return 0;
	}

	ans = -INF;
	ans = max(ans, candies[row][col] + dpOperation(row, col + 1));
	ans = max(ans, candies[row][col] + dpOperation(row + 1, col));

	return ans;
}

int main()
{
	memset(dp, -1, sizeof(dp));
	scanf("%d", &N);

	for(int i = 0; i < 2; i++)
	{
		for(int j = 0; j < N; j++)
		{
			scanf("%d", &candies[i][j]);
		}
	}
	if( N == 1)
	{
		finalAns = candies[0][0] + candies[1][0];
		printf("%d\n", finalAns);
	}
	else
	{	
		finalAns = dpOperation(0, 0);
		// finalAns += candies[1][N - 1];
		printf("%d\n", finalAns);
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<string,int>;

int main(){

  int N;
  cin >> N;
  string S;

  map<string,int>m;

  m["AC"] = 0;
  m["WA"] = 0;
  m["TLE"] = 0;
  m["RE"] = 0;

  for (int i = 0; i < N; i++) {
    cin >> S;
    m[S] += 1;
  }

  for(auto i = m.find("AC"); i != m.end(); i++) {
    cout << i->first << " x " << i->second << endl;
    break;
  }

  for(auto i = m.find("WA"); i != m.end(); i++) {
    cout << i->first << " x " << i->second << endl;
    break;
  }


  for(auto i = m.find("TLE"); i != m.end(); i++) {
    cout << i->first << " x " << i->second << endl;
    break;
  }


  for(auto i = m.find("RE"); i != m.end(); i++) {
    cout << i->first << " x " << i->second << endl;
    break;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define MAX(a, b) ((a) < (b) ? (b) : (a))
using namespace std;
int main()
{
  int n;
  cin >> n;
  int f[n][10];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++)
      cin >> f[i][j];
  int p[n][11];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 11; j++)
      cin >> p[i][j];

  int maxprofit = -2147483647;
  for (int sched = 1; sched < 1024; sched++)
  {
    int profit = 0;
    for (int i = 0; i < n; i++)
    {
      int c = 0;
      for (int j = 0; j < 10; j++)
      {
        if ((sched & (1 << j)) && f[i][j])
        {
          c++;
        }
      }
      profit += p[i][c];
    }
    maxprofit = MAX(profit, maxprofit);
  }
  cout << maxprofit << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  bool a[n+1];
  for(int i=1;i<=n;++i){
    int x,y;
    cin>>x>>y;
    if(x==y)
      a[i]=true;
    else
      a[i]=false;
  }
  for(int i=2;i<n;++i){
    if(a[i]&&a[i-1]&&a[i+1]){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3632