akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string S;

  cin>>S;

  if(S[1] == 'R') S[1] = 'B';
  else S[1] = 'R';
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 3640
//
// Created by matteo on 29/03/19.
//
#include <bits/stdc++.h>

using namespace std;
vector<long> h;
vector<long> DP;

long d(long i, long j) {
   if (i >= h.size() || j >= h.size() || i < 0 || j < 0)
      throw invalid_argument("Index are longer thant the vectot h");
   return abs(h[i] - h[j]);
}

long frog(long i) {
   if (DP[i] == -1) {
      DP[i] = min(d(i, i - 1) + frog(i - 1), d(i, i - 2) + frog(i - 2));
   }
   return DP[i];
}

int main() {
   //input parsing
   unsigned long N = 0;
   scanf("%ld", &N);
   DP.resize(N, -1);
   h.reserve(N);
   for (int i = 0; i < N; ++i) {
      long value;
      scanf("%ld", &value);
      h.emplace_back(value);
   }
   //initialization
   DP[0] = 0;
   DP[1] = d(0, 1);
   //calculations
   long minPath = frog(N - 1);
   printf("%ld", minPath);
}


Measured memory_bytes: 4096
#include<stdio.h>
#include<limits.h>
#define ll long long
ll K[20],cost,ans=LLONG_MAX,a,b,i;
ll min1(ll a,ll b){
	if(a<b)
		return a;
	else
		return b;
}
void match(ll c,ll d,ll e){
	if(c==a){
		if(d>=b){
			ans=min1(ans,cost);
		}
		return ;
	}
	if(K[c]>e){
		match(c+1,d+1,K[c]);
	}
	else{
		match(c+1,d,e);
		cost+=(e+1-K[c]);
		match(c+1,d+1,e+1);
		cost-=(e+1-K[c]);
	}
}
int main(){
	scanf("%lld%lld",&a,&b);
	for(i=0;i<a;i++)
		scanf("%lld",&K[i]);
	match(1,1,K[0]);
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 128
import math
n, m = map(int, input().split())

def nCr(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

even = nCr(n, 2)
odd = nCr(m, 2)
print(even + odd)

Measured memory_bytes: 38384
(let ((n (read))
      (tm (read))
      (before 0)
      (total 0))
  (dotimes (i n)
    (let ((x (read)))
      (incf total
            (min (- x before)
                 tm))
      (setf before x)))
  (incf total tm)
  (format t "~A~%" total))

Measured memory_bytes: 57700
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stack>
const int maxn=2e5+5;
using namespace std;
int main()
{
	string s;
	cin>>s;
	stack<char> q;
	for(int i=0;i<s.size();i++)
	{
		if(q.size()==0)
		{
			q.push(s[i]);
			continue;
		}
		char temp=q.top();
		q.push(s[i]);
		if(temp=='S'&& s[i]=='T')
		{
			q.pop();
			q.pop();
		}	
	}
	cout<<q.size()<<endl;
	return 0;
} 

Measured memory_bytes: 644
#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 ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

// d[u][v]は辺e = (u, v)のコスト（存在しない場合はINF、ただしd[i][i] = 0とする。）
// Vは頂点数
void warshall_floyd(vector<vector<int>> &d, int V)
{
    for (int k = 0; k < V; k++)
    {
        for (int i = 0; i < V; i++)
        {
            for (int j = 0; j < V; j++)
            {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> d(n, vector<int>(n, 1));
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        d[a][b] = 0;
    }

    warshall_floyd(d, n);
    vector<vector<int>> ans(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
            {
                ans[i].push_back(j + 1);
            }
            else if (d[i][j] == d[j][i] && d[i][j] == 0)
            {
                ans[i].push_back(j + 1);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<ans[i].size();j++){
            if(j == ans[i].size() - 1){
                cout << ans[i][j];
            }else{
                cout << ans[i][j] << ' ';
            }
        }
        cout << endl;
    }
}


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


int main() {
	int x, y, z;

	cin >> x >> y >> z;
	int A = 0;
	x -= z;
	while (1) {
		if (x < y + z)break;
		x -= (y + z);
		A++;
	}
	cout << A << endl;



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n;
    cin>>k;
    int a[n];
    int sum=0;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        if (a[i]>=k)
            sum++;
    }
    cout<<sum;


}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int i,n,x,min=0,max=0;
  long long sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    x=0;
    scanf("%d",&x);
    sum+=x;
    if(i==0){
      min=x;
      max=x;
    }
    if(x>max){
      max=x;
    }
    if(x<min){
      min=x;
    }
  }
  printf("%d %d %lld\n",min,max,sum);
  return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
const int N=233,M=20;
char a[N],x[M],y[M];
int myxn,myyn,n;
long long dp[M][M];

long long solve(int i)
{
	if(i==n)
	{
		//printf("233\n");
		memset(dp,0,sizeof(dp));
		dp[0][myxn]=1;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<=myxn;j++)if(dp[i][j])
			{
				if(j && a[i+n]==x[j-1])dp[i+1][j-1]+=dp[i][j];
				int k=myxn-j-i+myyn;
				//printf("i=%d j=%d k=%d\n",i,j,k);
				if(k && a[i+n]==y[k-1])dp[i+1][j]+=dp[i][j];
			}
		}
		return dp[n][0];
	}
	x[myxn++]=a[i];
	long long ans=solve(i+1);
	myxn--;
	y[myyn++]=a[i];
	ans+=solve(i+1);
	myyn--;
	return ans;
}

int main()
{
	scanf("%d%s",&n,a);
	myxn=myyn=0;
	printf("%lld\n",solve(0));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define MAXN 5000000
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
const long long mod = 1000000007;
int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
int main(){
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n;
    cin>>n;
    ll ans = 0;
    for(ll i = 1;i<=n;i++){
       if(i%3!=0 && i%5!=0)
         ans+= i;
    }
    cout<<ans;
return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
  }
  sort( A.begin(), A.end() );
  
  int L = A.at(N-1);
  int R;
  int sa = 1000000000000;
  for( int i = 0; i < N-1; i++ ){
    if( abs( A.at(i) - L/2 ) <= sa ){
      R = A.at(i);
      sa = abs( A.at(i) - L/2 );
    }
  }
  cout << L << " " << R << endl;
    
  
  
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[argc])
{
  ull X, Y;

  scanf("%llu%llu", &X, &Y);

  int N = floor(log2((long double)Y / X) + 1);
  printf("%d\n", N < 1 ? 1 : N);
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i <= n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int k, a, b;
    cin >> k >> a >> b;
    bool ans = false;
    FOR(i,a,b){
        if(i % k == 0) ans = true; 
    }
    cout << (ans ? "OK":"NG") << endl;
    return 0;
}

Measured memory_bytes: 3604
/*
______________________________
                              |
Shubham Singhal               |
                              |
CodeChef          torque      |
HackerEarth       torque      |
SPOJ              torque      |
HackerRank        torquecode  |
CodeForces        torquecode  |
AtCoder           torque            |
______________________________| */


// If Tyrion dies, I am gonna riot :P


# include <bits/stdc++.h>
using namespace std;

# define MOD         1000000007
# define gc          getchar
# define LL          long long
# define L           long
# define pb          push_back
# define mp          make_pair
# define vi          vector<int>
# define MAXN        100005
# define INF         1e9

int d[20],k;

bool eval(int n)
{
    int a[10]={0};
    while(n)
    {
        int temp=n%10;
        a[temp]=1;
        n/=10;
    }
    for(int i=0;i<k;i++)
    {
        if(a[d[i]]==1)
            return false;
    }
    return true;
}
int main()
{

    int n;
    cin>>n>>k;

    for(int i=0;i<k;i++)
        cin>>d[i];
    for(int i=n;;i++)
    {
        if(eval(i))
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
Temp, A = list(map(int, input().split()))
H = list(map(float, input().split()))
k = 0
target = float("inf")
n = []
for i, v in enumerate(H, start=1):
    k = Temp - v * float(0.006)
    if target > abs(k - A):
        target = abs(k - A)
        n.append(i)

print(n[-1])


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define INF (1e9)
#define PI (acos(-1))


int main() {
  int A, B;
  int res;

  cin >> A >> B;
  
  res = A * B - A - B + 1;

  cout << res << endl;  

  return 0;
}


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

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] == s[i - 1]) {
            cout << "Bad";
            return;
        }
    }
    cout << "Good";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    while (t--) solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define MAX 150000000
#define rep(i,n) for(li i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

li judge(li x,vector<li>& c,vector<vector<li>>& a,li bs){
  int n=c.size(),i=0;
  int m=a[i].size();
  vector<li> und(m,0);
  li cost=0;
  while(bs){
    if(df)print("bs:",bs);
    if(bs&1){
      cost+=c[i];
      rep(j,m){
        und[j]+=a[i][j];
      }
    }
    bs/=2; i++;
  }
  if(df)print("und",und);
  rep(i,m){
    if(und[i]<x) return MAX;
  }
  return cost;
}

int main(){
  int n,m; li x; cin >>n >>m >>x;
  vector<li> c(n);
  vector<vector<li>> a(n,vector<li>(m));
  rep(i,n){
    cin >>c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }
  
  if(df) rep(i,n) print(a[i]);
  li lim=1<<n,ans=MAX;
  if(df) print(lim);
  rep(bs,lim){
    li jd=judge(x,c,a,bs);
    chmin(ans,jd);
  }
  if(ans==MAX) ans=-1;
  print(ans);
}


Measured memory_bytes: 3588
using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
      int a = int.Parse(Console.ReadLine());
      Test.call(a);
    }

    public static void call(int n)
    {
      for (int i = 1; i <= n; i++)
      {
        if (i % 3 == 0)
        {
          Console.Write(" " + i);
        }
        else
        {
          int j = i;
          do
          {
            if (j % 10 == 3)
            {
              Console.Write(" " + i);
              break;
            }
            j /= 10;
          }
          while (j != 0);
        }
      }
      Console.WriteLine();
    }
  }
}


Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll n,i;
    cin>>n;
    vector<ll> a(n);
    map<ll,ll> mp;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    for(i=0;i<n;i++)
    {
        if(mp[a[i]] > 1) {cout<<"NO";return 0;}
    }
    cout<<"YES";
}

Measured memory_bytes: 14336
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int result = 0;
		int[] i = new int[n];
		int[] r = new int[n];
		for (int j = 0; j < n; j++) {
			i[j] = in.nextInt();
			r[j] = in.nextInt();
		}
		for (int j = 0; j < n; j++) {
			result += (r[j] - i[j]) + 1;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 28016
#include <iostream>
#include <vector>
#include <algorithm>
using namespace  std;
const long long INF = 1<<30;

int LIS(vector<int> &A){
    int N = A.size();
    vector<int> dp(N+1, INF);
    for(int i=0; i<N; i++){
        *lower_bound(dp.begin(), dp.end(), A[i]) = A[i];
        
    }
    int res = 0;
    while(dp[res]!=INF) res++;
    return res;
}
signed main(){
    int N; cin>>N;
    vector<int> A(N);
    for(long long i=0; i<N; i++){
        cin>>A[i]; 
    } 
    cout << LIS(A) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000009
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
typedef unsigned short int usi;

// 昇順
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int n, k;
    scanf("%d %d",&n,&k);
    printf(2*k-1<=n?"YES":"NO");
    return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> foods(m);
	rep(i, n) {
		int k;
		cin >> k;
		rep(j, k) {
			int a;
			cin >> a;
			a--;
			foods[a]++;
		}
	}
	int ans = 0;
	for (int c : foods) {
		if (c == n) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;

ll sum_keta(ll a){
	ll A=a,SUM=0;
	while(A!=0){
		SUM=SUM+A%10;
		A=A/10;
	}
	return SUM;
}

int main()
{
	ll N,A,B;
	string s;
	cin>>N>>A>>B;
	for(;;){
		if(A+1==B){
			s="Borys";
			break;
		}
		A++;
		if(B-1==A){
			s="Alice";
			break;
		}
		B--;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  vector<int> A(n);
  for(int &i:A)
    cin>>i;
  int j,k,l=100000000000000000;
  for(int a=0;a<2;a++){
    k=0,j=0;
    for(int i=0;i<n;i++){
      k+=A[i];
      if(((i+a)%2*2-1)*k<=0){
        j+=1+abs(k);
        k=(i+a)%2*2-1;
      }
    }
    l=min(l,j);
  }
  cout<<l<<endl;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e6+9;
int main()
{
    FASTINOUT;
    ll x,h;
    cin>>x>>h;
    pair<int,int>p[x];
    int ans=0,mx=0;
    for (int i=0;i<x;i++){
        cin>>p[i].second>>p[i].first;
        mx=max(mx,p[i].second);
    }
    sort(p,p+x);
    reverse(p,p+x);
    for (int i=0;i<x;i++){
        if (p[i].first>mx){
            h-=p[i].first;
            ans++;
            if (h<=0){
                h=0;
                break;
            }
        }
        else
            break;
    }
    ans+=h/mx+(h%mx!=0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int N;
int m[111111];
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>N;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        if(N%2==x%2){
            cout<<0<<'\n'; 
            return 0;
        }
        if(x==0&&m[x]){
            cout<<0<<'\n';
            return 0;
        }
        if(m[x]++==2){
            cout<<0<<'\n';
            return 0;
        }
    }
    long long ans=1;
    for(int i=0;i<N/2;i++){
        ans*=2;
        ans%=1000'000'007;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		long N = Long.parseLong(sc.next());
		long M = (long) Math.sqrt(N);
		int tmp=1;
		for(int i=1;i<=(int)M;i++){
			if(N%i==0){
				tmp = i;
			}
		}
		long r = Math.max(tmp,N/tmp);
		int count = 0;
		while(r>0){
			r /= 10;
			count ++ ;
		}
		out.println(count);

	sc.close();
	out.flush();
	}
}



Measured memory_bytes: 21972
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
# define M_PI           3.14159265358979323846  /* pi */
#define ll long long
#define ld long  double
int max(long long int array[],long long int n );
using namespace std;
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
double a;
cin>>a;
cout<<fixed<<setprecision(10)<<2*M_PI*a<<endl;


  }


Measured memory_bytes: 3780
#include <stdio.h>

int main(void) {
  int N, i;
  int x = 0, max = 0;
  char S[110];
  
  scanf("%d %s", &N, S);
  for(i = 0; i < N; i++) {
    if(S[i] == 'I') {
      x++;
      if(max < x) max = x;
    } else {
      x--;
    }
  }
  printf("%d\n", max);
  
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	int answer = 0;
	if(s[0] == s[1] && s[0] == 'R')
		answer += 2;
	if(s[1] == s[2] && s[1] == 'R') {
		if(!answer)
			answer += 2;
		else
			++answer;
	}
	if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
		answer = max(answer, 1);
	cout << answer;
	
}


Measured memory_bytes: 3520
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  string X;
  cin >> X;
  int N = X.size();
  int count = 0;
  int answer = N;
  for (int i = 1; i < N; ++i) {
    // cout << X.substr(i - 1) << ": count=" << count << " answer=" << answer
    //<< endl;
    if (X[i - 1] == 'T' && X[i] == 'S') {
      count = 0;
    } else if (X[i - 1] == 'S' && X[i] == 'T') {
      X[i] = X[i - count];
      answer -= 2;
      count--;
    } else if (X[i - 1] == 'S') {
      count++;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main(){
  ios::sync_with_stdio(false);
  
  ll N,K;
  cin>>N>>K;
  ll ans=0;
  
  for(ll i = K; i<N+2;i++){
  	ans= (ans + (i*(N-i+1)+1 ) ) %mod;
  }
	
  cout<<ans % mod;
  
}

Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);
#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)

int Q;
int dp[1100][1100];
// 1-leadingとして，
// dp[i][j] := sのi番目までの文字列とtのj番目までの文字列のLCSのサイズ

signed main(){
    cin>>Q;
    rep(q,Q){
        string s,t;
        cin>>s>>t;
        for(int i=0;i<=s.length();i++)dp[i][0]=0;
        for(int i=0;i<=t.length();i++)dp[0][i]=0;
        for(int i=1;i<=s.length();i++){
            for(int j=1;j<=t.length();j++){
                if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
        cout<<dp[s.length()][t.length()]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11684
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

ll digits(ll n)
{
    ll ans = 0;
    while (n > 0) {
        n /= 10;
        ++ans;
    }
    return ans;
}
ll f(ll a, ll b)
{
    return digits(max(a, b));
}
int main()
{
    ll n = in();
    double rt = sqrt(n);
    ll ans = INFLL;
    REP1(i, n) {
        if (i > rt)break;
        if (n % i == 0) {
            ans = min(ans, f(n / i, i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
           int n;
           cin>>n;
           int a[n],b[n];
           for(int i=0;i<n;i++)cin>>a[i];
           for(int i=0;i<n;i++)cin>>b[i];
           int x[3*n],y[3*n];
           for(int i=0;i<n;i++)x[i]=b[i%n]^(b[(i+1)%n]);
           for(int i=0;i<n;i++){
               x[i+n]=a[i%n]^a[(i+1)%n];
               x[i+2*n]=a[i%n]^a[(i+1)%n];
           }
           y[0] = 3*n;
int i = 1, j = 0;
while (i < 3*n) {
  while (i+j < 3*n && x[j] == x[i+j]) ++j;
  y[i] = j;
  if (j == 0) { ++i; continue;}
  int k = 1;
  while (i+k < 3*n && k+y[k] < j) y[i+k] = y[k], ++k;
  i += k; j -= k;
}
for(int i=n;i<2*n;i++){
    if(y[i]>=n)cout<<i-n<<' '<<(a[i-n]^b[0])<<endl;
}

         return 0;

        }


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

template < typename T >
void printVector (const vector < T > & vec) {
	for (const T x : vec) {
		cout << x << " ";
	}
	cout << endl;
}

template < typename T >
void printMatrix (const vector < vector < T > > & mat) {
	for (const vector < T > vec : mat) {
		printVector (vec);
	}
	cout << endl;
}

const ll INF = 1e18L + 5;

template < typename T >
void min_self (T& a, T b) {
	a = min (a, b);
}

template < typename T >
void max_self (T& a, T b) {
	a = max (a, b);
}

template < typename T >
void add_self (T & a, T b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

template < typename T >
void sub_self (T & a, T b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}

int main() {
	int n;
	scanf ("%d", &n);
	vector < vector < int > > p (n, vector < int > (n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf ("%d", & p[i][j]);
		}
	}
	vector < int > dp (1 << n, 0);
	dp[0] = 1;
	for (int state = 0; state < (1 << n) - 1; state++) {
		int a = __builtin_popcount (state);
		for (int b = 0; b < n; b++) {
			if (p[a][b] && !((state >> b) & 1)) {
				int mask = state ^ (1 << b);
				add_self (dp[mask], dp[state]);
			}
		}
	}
	printf ("%d\n", dp[(1 << n) - 1]);
	return 0;
}



Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
int main() {
  int a, b ;
  cin >> a >> b;
  ll ans = b*pow(b-1, a-1);
  cout << ans << endl;
  return 0;
}

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

int main() {
	string s;cin>>s;
	int m=(s[5]-'0')*10+(s[6]-'0');
	int d=(s[8]-'0')*10+(s[9]-'0');
	if(m>=5){
		cout<<"TBD"<<endl;
	}else{
		cout<<"Heisei"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  double result = 0;
  cin >> N >> K ;

  for (int i = 1; i <= N ;i++) {
    int point = i;
    double continuous = 0;
    while(point < K){
      point *= 2;
      continuous++;
    }
    result += (1.0/N)*pow(0.5,continuous);
  }
  
  cout << std::setprecision(12) << result << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

    int firstRectangles = A * B;
    int secondRectangles = C * D;

    if (firstRectangles > secondRectangles)
        cout << firstRectangles << endl;
    else
        cout << secondRectangles << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>

using namespace std;
long double possibility(double N, int K);


int main() {
    long long int N, K;
    cin >> N >> K;

    long double ans = 0;
    ans = possibility(N, K);

    cout << setprecision(15) << ans;

    return 0;
}

long double possibility(double N, int K) {
    long double ans = 0, percentage;
    int j, score;
    for (int i = 1; i <= N; i++) {
        percentage = 0;
        j = 0;
        score = 0;
        while (score < K) {
            score = i *  pow(2, j);
            percentage = 1 / N * pow(0.5, j);
            j++;
        }
        ans += percentage;
    }
    return ans;
}

Measured memory_bytes: 4100
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b;
    for(int i = 1;i<=3;i++){
        c = i;
        int ans = a * b * c;
        if(ans % 2 != 0){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

vll p;
vll s;

ll get_num_of_patty(ll n, ll x) {
	if (n==0) {
		return x;
	}
	else if (x < 2) {
		return 0;
	}

	ll ret = 0;
	if (s[n] == x) {
		return p[n];
	}
	else if (s[n - 1]+1 < x) {
		return p[n - 1] + 1 + get_num_of_patty(n - 1, x - s[n - 1] - 2);
	}
	else {
		return get_num_of_patty(n - 1, x-1);
	}

}

int main() {
	ll N, X;
	std::cin >> N >> X;
	p.resize(N + 1,1);
	s.resize(N + 1,1);
	repeq(i, 1, N) {
		p[i] = p[i - 1] * 2 + 1;
		s[i] = s[i - 1] * 2 + 3;
	}

	std::cout << get_num_of_patty(N,X) << endl;
	return 0;
}


Measured memory_bytes: 256
//In the name of God

#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e5+10 , mod = 1e9+7;

vector <int> g[N];
int dp[N] , d[N];
set <pii> s;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , m;
   cin >> n >> m;
   for(int i = 0 ; i < m ; i++){
      int u , v;
      cin >> u >> v;
      u--; v--;
      d[u]++;
      g[v].push_back(u);
   }
   for(int i = 0 ; i < n ; i++)
      s.insert({d[i] , i});
   int ans = 0;
   while(s.size()){
      auto a = *s.begin();
      s.erase(s.begin());
      int v = a.second;
      dp[v] = max(dp[v] , 1);
      for(int u : g[v]){
         dp[u] = max(dp[u] , dp[v] + 1);
         s.erase({d[u] , u});
         d[u]--;
         s.insert({d[u] , u});
      }
      ans = max(ans , dp[v]);
   }
   cout << ans - 1;
   return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>

using namespace std;

void solve(int n, string s) {
    string original = s;
    int righthang = 0;
    int lefthang = 0;
    for (int i = 0; i < n; i++) {
        if (s.back() == ')') {
            break;
        }
        righthang += 1;
        s.pop_back();
    }
    while (s.empty() != true) {
        if (s.back() == ')' ) {
            lefthang += 1;
        } else {
            if (lefthang == 0) {
                righthang += 1;
            } else {
                lefthang -= 1;
            }
        }
        s.pop_back();
    }
    for (int i = 0; i < lefthang; i++) {
        std::cout << '(';
    }
    std::cout << original;
    for (int i = 0; i < righthang; i++) {
        std::cout << ')';
    }
    std::cout << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n;

    gettimeofday(&start,NULL);

    string s;
    std::cin >> n >> s;
    solve(n, s);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

int main() {
    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            if (i + j == X && 2 * i + 4 * j == Y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3620
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
 
a, b = map(int, input().split())
print(len(set(prime_factorize(a)) & set(prime_factorize(b))) + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define ld double
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()

using namespace std;
//using namespace __gnu_pbds;

ll MOD = 998244353;
const ll INF = 1e18;
const ld E = 1e-18;
const ld PI=acos(-1);
mt19937_64 rnd(time(0));
ll p1 = 31, p2 = 37, p3 = 7, p4 = rnd() % 100 + 1, md1 = MOD, md2 = 998244353, md3 = 998244357, md4 = rnd() % 1000000000;

//using ord_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

ll n, m, k;


ll binpow(ll h, ll r, ll md = MOD)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l *= h, l%=md;
        h *= h;
        h %= md;
        r /= 2;
    }
    return l;
}

ll gcd(ll x, ll y)
{
    if (x < y) swap(x, y);
    while (x && y)
    {
        x %= y;
        swap(x, y);
    }
    return x + y;
}

void solve()
{
    cin >> n >> m;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen("capitals.in","r",stdin);
    //freopen("capitals.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    m*=m;ll ans=0;
    for (int i = 1; i <= n; i++)
    {
        ll x, y;
        cin >> x >> y;
        ans+=((x*x+y*y)<=m);
    }
    cout << ans << "\n";
    return 0;
}

/*
a-b=k
a+b=m
a=(m+k)/2;
b=(m-k)/2;
*/


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

int main(){
  int N,M,C,cnt=0;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));
  rep(i,M)
    cin >> B.at(i);
  rep(i,N)
    rep(j,M)
      cin >> A.at(i).at(j);
  rep(i,N){
    int num = 0;
    rep(j,M){
      num += A.at(i).at(j) * B.at(j);
    }
    if(num+C > 0)
      ++cnt;
  }
  cout << cnt;
}

Measured memory_bytes: 256
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	n = I()
	A = LI()
	d=defaultdict(lambda: 0)
	for a in A:
		d[a] += 1
	ans=0
	for k,v in d.items():
		if k>v:
			ans+=v
		else:
			ans += v-k

	print(ans)




if __name__ == '__main__':
	main()

Measured memory_bytes: 18460
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c, x;
  cin >> a >> b >> c >> x;
  ll ans = 0;
  rep(i, a + 1) rep(j, b + 1) rep(k, c + 1) {
    ll now = i * 500 + j * 100 + k * 50;
    if(now == x) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
using vpll = vector<pair<ll, ll>>;

int main()
{
   ll n, w, v = 0, MAX = numeric_limits<ll>::max(), res = 0;
   cin >> n >> w;
   vpll wv(n, pair<ll, ll>());
   for (ll i = 0; i < n; i++)
   {
      cin >> wv[i].first >> wv[i].second;
      v += wv[i].second;
   }
   vvll dp(n, vll(v + 1, MAX));
   dp[0][wv[0].second] = wv[0].first;
   for (ll i = 1; i < n; i++)
   {
      for (ll j = 1; j <= v; j++)
      {
         dp[i][j] = dp[i - 1][j];
      }
      for (ll j = 1; j <= v; j++)
      {
         if (dp [i - 1][j] != MAX)
         {
            if (dp[i - 1][j] + wv[i].first <= w)
            {
               dp[i][j + wv[i].second] = min(dp[i - 1][j + wv[i].second], dp[i - 1][j] + wv[i].first);
            }
         }
      }
      dp[i][wv[i].second] = min(dp[i][wv[i].second], wv[i].first);
   }
   ll r = 0;
   for(ll i = 1; i <= v; i++)
   {
      if (dp[n - 1][i] != MAX) r = max(r, i);
   }
   cout << r;
   return 0;
}

Measured memory_bytes: 79360
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


void no()
{
  std::cout << "NO" << std::endl;
  
  exit(0);
}


bool solve(int W, int x, const std::string& S, const std::string& T)
{
  std::string s;

  for (int i = 0, size = S.size(); i < size; i ++) {
    if (S[i] == 'L' || S[i] == 'R')
      s.push_back(S[i]);

    if (T[i] == 'L' || T[i] == 'R')
      s.push_back(tolower(T[i]));
  }

  int N = s.size(), l = 1, r = W;

  for (int i = N - 1; i >= 0; i --) {
    char c = s[i];

    if (c == 'L') {
      l ++;
    }
    else if (c == 'R') {
      r --;
    }
    else if (c == 'l') {
      r = std::min(r + 1, W);
    }
    else {
      assert(c == 'r');

      l = std::max(l - 1, 1);
    }

    if (l > r)
      return false;
  }

  return l <= x && x <= r;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int H, W, N, sr, sc, xm, xp, ym, yp;

  std::string S, T;

  std::cin >> H >> W >> N >> sr >> sc >> S >> T;

  std::string s(S), t(T);

  if (! solve(W, sc, s, t))
    no();

  for (int i = 0; i < N; i ++) {
    if (s[i] == 'R') {
      s[i] = 'D';
    }
    else if (s[i] == 'L') {
      s[i] = 'U';
    }
    else if (s[i] == 'U') {
      s[i] = 'L';
    }
    else {
      s[i] = 'R';
    }

    if (t[i] == 'R') {
      t[i] = 'D';
    }
    else if (t[i] == 'L') {
      t[i] = 'U';
    }
    else if (t[i] == 'U') {
      t[i] = 'L';
    }
    else {
      t[i] = 'R';
    }
  }

  if (! solve(H, sr, s, t))
    no();

  std::cout << "YES" << std::endl;

  return 0;
}


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

int g[15][15];

int main(void){
    int n;
    cin >> n;
    rep(i,n) rep(j,n) g[i][j] = -1;
    rep(i,n) {
        int a; cin >> a;
        rep(j,a) {
            int x, y;
            cin >> x >> y;
            --x;
            g[i][x] = y;
        }
    }
    int ans = 0;
    // bit全探索
    // 2^n回実行する
    rep(i, 1<<n) {
        // d : i番目の人の証言を管理
        // 0 : 不親切, 1 : 正直者
        vector<int> d(n);
        rep(j,n) if(i>>j&1) {
            d[j] = 1;
        }
        
        bool ok = true;
        rep(j,n) {
            if(d[j]) {
                rep(k,n) {
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int n, m;
    cin >> n >> m;

    print((ll)((1900 * m + 100 * (n - m)) * pow(2, m)));
}

Measured memory_bytes: 3984
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"100 17
" => r"83",

r"48 58
" => r"0",

r"1000000000 1000000000
" => r"0"
}

use std::cmp;
use std::cmp::max;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: i32,
        t: i32,
    }

    max(0, x - t).to_string()
}


Measured memory_bytes: 4352