akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

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

    string number;
    cin >> number;
    //cout << number << endl;
    int K; cin >> K;
    vector<vector<int> > smaller(number.length()+1,vector<int>(K+1,0)), equal(number.length()+1,vector<int>(K+1,0));
    equal[0][0] = 1;
    //smaller[0][0] = 1;
    REP(i,number.length()){
        REP(j,K+1){
            if(number[i] == '0'){
                equal[i+1][j] = equal[i][j];
            }
            else{
                if(j >= 1) equal[i+1][j] = equal[i][j-1];
                else equal[i+1][0] = 0;
            }
        }
    }

    REP(i,number.length()){
        REP(j,K+1){
            if(number[i] == '0'){
                if(j >= 1) {
                    smaller[i+1][j] = (smaller[i][j] + smaller[i][j-1] * 9);
                }//i桁目が0になる数字を足す
                else{
                    smaller[i+1][j] = smaller[i][j];
                }
                
            }
            else{
                if(j >= 1){
                    smaller[i+1][j] = equal[i][j] + equal[i][j-1] * (number[i] - '0'-1) + smaller[i][j] + smaller[i][j-1] * 9;
                }
                else{
                    smaller[i+1][j] = equal[i][j] + smaller[i][j];
                }
            }
        }
    }

    /*REP(i,number.length()+1){
        REP(j,K+1){
            cout << smaller[i][j] << " ";
        }
        cout << endl;
    }*/

    int ans =smaller[number.length()][K] + equal[number.length()][K];
    
    cout << ans << endl;

}

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

int main()
{
  int n,p;
  scanf("%d%d",&n,&p);
  int a[100];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }
  long long P0=1ll,P1=0ll;
  for(int i=0;i<n;i++){
    long long NP0,NP1;
    if(a[i]%2==0){
      NP0=2ll*P0,NP1=2ll*P1;
    }
    else{
      NP0=P0+P1,NP1=P0+P1;
    }
    P0=NP0,P1=NP1;
  }
  printf("%lld\n",p==0?P0:P1);
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
        for(int j = 0; j < m; j++)cin >> a[i][j];
    }

    int min_cost = 12345678;

    for(int bit=1; bit < (1 << n); bit++)
    {
        int cost =0;
        vector<int> skill(m); 
        bool judge = true;

        //i 番目のbitが立っているかチェック
        for(int i =0; i<n; i++)
        {
            int mask = 1<< i;
            if(bit & mask)
            {
                //料金アップ
                cost += c[i];

                //スキルアップ
                for(int j=0; j<m; j++)
                {
                    skill[j] += a[i][j];
                }
            }
        }

        //スキルがX未満のものが一つでもあるならjudgeをfalseに
        for(int k=0; k<m; k++)
        {
            if(skill[k] < x)
            {
                judge = false;
            }
        }

        //最小費用を更新
        if(judge == true)
        {
            min_cost = min(min_cost, cost);
        }

    }

    
    if(min_cost != 12345678)
    {
        cout << min_cost;
    }
    else
    {
        cout << (-1);
    }
    
    return 0;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  char c ='a';
  sort(S.begin(), S.end());
 
  for(int i=0; i<S.size(); i++) {
    if(S.at(i) == c) c +=1;
  }
  
  if(c > 'z') cout << "None" << endl;
  else cout << c << endl;
}

Measured memory_bytes: 3728
N = int(input())
H = list(map(int, input().split()))

cnt = 0
ans = 0
for i in range(N-1):
    if H[i+1] <= H[i]:
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt + 0
        cnt = 0
else:
    if ans < cnt:
        ans = cnt + 0
        
print(ans)

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

int main() {
    int N;
    cin >> N;

    vector<int> D(N);
    rep(i, N) cin >> D.at(i);
    sort(D.begin(), D.end());

    int ans = 1;
    rep(i, N) {
        if (i == 0) continue; 
        if (D.at(i) == D.at(i-1)) continue;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

k = len(s)
win = 0

for i in range(k):
	if s[i] == 'o':
		win += 1

if k < 7:
	print('YES')
elif k >= 8:
	if win + (15 - k) >= 8:
		print('YES')
	else:
		print('NO')

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

int N;
int f[100010];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        f[a]++;
    }

    int ma = 0;
    for (int i = 0; i < 100000; i++)
    {
        if (i + 2 < 100000)
        {
            int sum = f[i] + f[i + 1] + f[i + 2];
            ma = max(ma, sum);
        }
    }

    cout << ma << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
const ll N=3005;
ll bexpo(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==0)return bexpo(x*x,n/2);
    else return x*bexpo(x*x,(n-1)/2);
}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);} 
int Arr[N];
void initialize()
{
    for(int i = 0;i<N;i++)
    Arr[ i ] = i ;
}
int root(int i)
{
    while(Arr[ i ] != i)       
    {
     i = Arr[ i ];
    }
    return i;
}

void unio(int A ,int B)
{
    int root_A = root(A);       
    int root_B = root(B);  
    if(root_A<root_B)
        Arr[ root_A ] = root_B ;    
    else
        Arr[root_B]=root_A;
}
bool find(int A,int B)
{
    if( root(A)==root(B) )    
    return true;
    else
    return false;
}
int main() {
FIO;
  string s,t;
  cin>>s>>t;
  ll n=s.length();
  ll m=t.length();
  ll dp[n+1][m+1];
  ll i,j;
  for(i=0;i<=n;i++)
  {
     for(j=0;j<=m;j++)
     {
      if(i==0 || j==0)
          dp[i][j]=0;
      else if(s[i-1]==t[j-1])
          dp[i][j]=1+dp[i-1][j-1];
      else
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

     }
  }
  i=n;
  j=m;
  string ans="";
  while(i>0 && j>0)
  {
    if(dp[i][j]==dp[i-1][j])
        i-=1;
    else if(dp[i][j]==dp[i][j-1])
         j-=1;
    else
    {
      ans=s[i-1]+ans;
      i-=1;j-=1;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 74032
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]

t = sorted(t)

bus = 0
jyokyaku = 0
start = 0

for i in range(n):
	if jyokyaku == 0:
		start = t[i] + k
		jyokyaku = 1
	
	elif jyokyaku == c:
		bus = bus + 1
		start = t[i] + k
		jyokyaku = 1
							
	else:	
		if t[i] > start:
			bus = bus + 1
			start = t[i] + k
			jyokyaku = 1
				
		elif t[i] <= start:
			jyokyaku = jyokyaku + 1

	#print(i,jyokyaku,bus,start)

print(bus+1)		
		
		


Measured memory_bytes: 8280
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    double ans;
    if (N % 2 == 0) {
        ans = 0.5;
    } else {
        ans = (double)(N / 2 + 1) / (double)N;
    }
    cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 888
numOfItem = gets.to_i
arrayOfPrice = []
for times in 1..numOfItem do
  arrayOfPrice << gets.to_i
end

maxPrice = arrayOfPrice.max
numOfMaxPrice = arrayOfPrice.count(maxPrice)
arrayOfPrice.delete(maxPrice)

if numOfMaxPrice > 1 then
  for times in 1..numOfMaxPrice-1 do
    arrayOfPrice << maxPrice
  end
end

arrayOfPrice << maxPrice/2

puts arrayOfPrice.inject(:+)

Measured memory_bytes: 1788
#include<cstdio>
#include<iostream>
int m,n;
int fie[90][90]={0};
int nowans,maxans=0;
int maze(int nowm,int nown);
int main(){
    while(1){
        scanf("%d%d",&m,&n);
        if(m==0&&n==0)
            goto exit;
            nowans=0,maxans=0,fie[90][90]={0};
        for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    scanf("%d",&fie[i][j]);
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                nowans=0;
                maze(i,j);
                /*
                printf("=======\n");
                */
            }
        }
        printf("%d\n",maxans);
    }
exit:
    return 0;
}
int maze(int nown,int nowm){
        if(fie[nown][nowm]==1&&0<=nown&&nown<n&&0<=nowm&&nowm<m){

            /*
            printf("[%d][%d] [%d]\n",nown,nowm,nowans);
            */

            nowans++;
            if(maxans<nowans)
                maxans=nowans;
            fie[nown][nowm]=0;
            maze(nown,nowm+1);
            maze(nown+1,nowm);
            maze(nown,nowm-1);
            maze(nown-1,nowm);
            nowans--;
            fie[nown][nowm]=1;
        }
}

Measured memory_bytes: 1220
#include<iostream>
using namespace std;
int main(){
  int total[2],bell[10],hess[10],top1[3]={0},top2[3]={0};
  for(int i=0;i<10;i++){
    cin >> bell[i];
    if(bell[i]>=top1[0]){
      top1[2]=top1[1];
      top1[1]=top1[0];
      top1[0]=bell[i];
    }
    else if(bell[i]>=top1[1]){
     top1[2]=top1[1];
     top1[1]=bell[i];
    }
    else if(bell[i]>top1[2]){
      top1[2]=bell[i];
    }
  }
  for(int i=0;i<10;i++){
    cin >> hess[i];
    if(hess[i]>=top2[0]){
      top2[2]=top2[1];
      top2[1]=top2[0];
      top2[0]=hess[i];
    }
    else if(hess[i]>=top2[1]){
     top2[2]=top2[1];
     top2[1]=hess[i];
    }
    else if(hess[i]>top2[2]){
      top2[2]=hess[i];
    }
  }
  total[0]=top1[0]+top1[1]+top1[2];
  total[1]=top2[0]+top2[1]+top2[2];
  cout << total[0] << " " << total[1] << endl;
  return (0);
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sigma_size 30
#define max_size (int)(3e5+10)
#define MAX (int)(1e5+7)
int qread()
{
	char c; int s=0,t=1; while ((c=getchar())<'0' || c>'9') (c=='-' && (t=-1));
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*t;
}

int a[max_size];
LL sum[max_size] , pre[max_size];
int n;
vector <int> v;
bool check( int k , int lim )
{
	k -= ( pre[n] - pre[lim-1] );
	if ( k <= 0 ) return true;
	return sum[lim-1] >= (LL)k*lim;
}
int main ()
{
	n = qread();
	for ( int i = 1 ; i <= n ; i++ ){
		int x = qread();
		a[x]++;
	}
	for ( int i = 1 ; i <= n ; i++ )	pre[a[i]]++;
	for ( int i = 1 ; i <= n ; i++ )	
		sum[i] = sum[i-1] + i*pre[i] , pre[i] += pre[i-1];
	
	cout << n << endl;
	for ( int k = 2 ; k <= n ; k++ )
	{
		if ( k > pre[n] )
		{
			cout << "0" << endl;
			continue;
		}
		int l = 0 , r = n;
		while ( l < r )
		{
			int mid = l + r + 1 >> 1;
			if ( check(k,mid) ) l = mid;
			else r = mid-1;
		}
		cout << l << endl;
	}
}

Measured memory_bytes: 9476
#include <bits/stdc++.h>
#define maxn 200086
#define maxm 4086

using namespace std;

const int p = 1e9 + 7;//写错了 调了一万年 我吐了 

inline int fpow(int x, int y){
	int ans = 1;
	while(y){
		if(y & 1) ans = 1ll * ans * x % p;
		x = 1ll * x * x % p;
		y >>= 1;
	}
	return ans;
}

int sum[maxn], inv[maxn];
inline int C(int n, int m){
	return 1ll * sum[n] * inv[m] % p * inv[n - m] % p;
} 


int n;
int f[maxm][maxm];
int a[maxm][maxm];
int x[maxn], y[maxn];
int ans;

int main(){
	sum[0] = 1;for(int i = 1;i < maxn;i++) sum[i] = 1ll * sum[i - 1] * i % p;
	inv[maxn - 1] = fpow(sum[maxn - 1], p - 2);
	for(int i = maxn - 2;~i;i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % p;
	scanf("%d", &n);
	for(int i = 1;i <= n;i++) scanf("%d%d", &x[i], &y[i]), a[x[i]][y[i]]++;
	for(int i = -2000;i <= 2000;i++){
		for(int j = -2000;j <= 2000;j++){
			f[i + 2001][j + 2001] = (1ll * f[i - 1 + 2001][j + 2001] + f[i + 2001][j - 1 + 2001] + (i < 0 && j < 0 ? a[-i][-j] : 0)) % p;
		}
	}
	for(int i = 1;i <= n;i++){
		//printf("%d %d--\n", i, f[x[i] + 2001][y[i] + 2001]);
		ans = (1ll * ans + f[x[i] + 2001][y[i] + 2001] + p - C((x[i] + y[i]) * 2, x[i] * 2)) % p;//debug：x[i] * 2写成x[i] + y[i] 
	}
	printf("%d", 1ll * ans * inv[2] % p);
}

Measured memory_bytes: 93960
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

char s[1<<13];int n,x,y;
bitset<(1<<14)> bx,by;

int main(){
	scanf("%s%d%d",s,&x,&y);n=strlen(s);
	bx[1<<13]=by[1<<13]=1;
	int i=0,z=0;bool asd=false;
	while(i<n){
		if(s[i]=='T')z^=1,i++;
		else {
			int j=i;
			while(j<n&&s[j]=='F')j++;
			if(z)by=(by<<(j-i))|(by>>(j-i));
			else if(asd)bx=(bx<<(j-i))|(bx>>(j-i));
			else bx=bx<<(j-i);
			i=j;
		}
		asd=true;
	}
	puts(bx[(1<<13)+x]&&by[(1<<13)+y]?"Yes":"No");
	return 0;
}

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

int main()
{
    const int mod = 1000000007;
    long long n, k;
    std::cin >> n >> k;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    long long p = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                p++;
                p %= mod;
            }
        }
    }

    long long q = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) {
                q++;
                q %= mod;
            }
        }
    }

    p *= k;
    p %= mod;

    q *= ((k * (k - 1) / 2) % mod);

    p += q;
    p %= mod;
    std::cout << p << std::endl;
}


Measured memory_bytes: 256
_sx, _sy, _tx, _ty = [int(i) for i in input().split()]
sx, sy, tx, ty = _sx, _sy, _tx, _ty
"""
# 全ての場合を一度tx > sx, ty > syにしてから考える
if sx != tx and sy != ty:
    if tx > sx and ty < sy:
        ty += (ty - sy) * 2
    elif tx < sx and ty > sy:
        tx += (tx - sx) * 2
    elif tx < sx and ty < sy:
        tx += (tx - sx) * 2
        ty += (ty - sy) * 2
elif sx == tx:
    if ty < sy:
        ty += (ty - sy) * 2
else:  # sx==txの形に変換
    if tx < sx:
        tx += (tx - sx) * 2
    sy = sx
    ty = sx
"""
path = ""
# 1回目の行き
for i in range(tx - sx):
    path += "R"
for i in range(ty - sy):
    path += "U"
# 1回目の帰り道
for i in range(tx - sx):
    path += "L"
for i in range(ty - sy):
    path += "D"
# 2回目の行き
path += "D"
for i in range(tx - sx + 1):
    path += "R"
for i in range(ty - sy + 1):
    path += "U"
path += "L"
# 2回目の帰り道
path += "U"
for i in range(tx - sx + 1):
    path += "L"
for i in range(ty - sy + 1):
    path += "D"
path += "R"
"""
else:  # sy == ty
    if tx > sx:
        for i in range(tx - sx):
            path += "U"
        path += "R"
        for i in range(tx - sx):
            path += "D"
        path += "L"
        path += "DRR"
        for i in range(tx - sx + 2):
            path += "U"
        path += "LLDL"
        for i in range(tx - sx):
            path += "D"
        path += "R"
"""
print(path)
"""
if sx != tx and sy != ty:
    if tx > sx:
        for i in range(tx - sx):
            path += "R"
    else:
        for i in range(sx - tx):
            path += "L"
    if ty > sy:
        for i in range(ty - sy):
            path += "U"
    else:
        for i in range(sy - ty):
            path += "D"
    # 帰り道
    if tx > sx:
        for i in range(tx - sx):
            path += "L"
    else:
        for i in range(sx - tx):
            path += "R"
    if ty > sy:
        for i in range(ty - sy):
            path += "D"
    else:
        for i in range(sy - ty):
            path += "U"
    # 2回目の行き
    if tx > sx and ty > sy:
        path += "D"
    elif tx > sx
    if tx > sx:
        for i in range(tx - sx):
            path += "R"
    else:
        for i in range(sx - tx):
            path += "L"
    if ty > sy:
        for i in range(ty - sy):
            path += "U"
    else:
        for i in range(sy - ty):
            path += "D"

elif sx == tx:
    if ty > sy:
        for i in range(ty - sy):
            path += "U"
        path += "R"
        for i in range(ty - sy):
            path += "D"
        path += "L"
    else:
        for i in range(sy - ty):
            path += "D"
        path += "R"
        for i in range(sy - ty):
            path += "U"
        path += "L"
else:  # sy == ty
    if tx > sx:
        for i in range(tx - sx):
            path += "R"
        path += "U"
        for i in range(tx - sx):
            path += "L"
        path += "D"
    else:
        for i in range(sx - tx):
            path += "L"
        path += "U"
        for i in range(sx - tx):
            path += "R"
        path += "D"
print(path)
"""


Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
 
using namespace std;
 
typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;
 
const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;
 
template <typename T> inline void scf(T &x)
{
	bool f = 0;
	x = 0;
	char c = getchar();
	while(c != '-' && (c < '0' || c > '9')) c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	if(f) x = -x;
	return;
}
 
template <typename T1, typename T2> void scf(T1 &x, T2 &y)
{
	scf(x);
	return scf(y);
}
 
template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z)
{
	scf(x);
	scf(y);
	return scf(z);
}
 
template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w)
{
	scf(x);
	scf(y);
	scf(z);
	return scf(w);
}
 
inline char mygetchar()
{
	char c = getchar();
	while(c == ' ' || c == '\n') c = getchar();
	return c;
}
 
template <typename T> inline bool chkmax(T &x, const T &y)
{
	return y > x ? x = y, 1 : 0;
}
 
template <typename T> inline bool chkmin(T &x, const T &y)
{
	return y < x ? x = y, 1 : 0;
}
 
#ifdef King_George
#define DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
 
//---------------------------------------------------------head----------------------------------------------------
 
LL n;
LL cnt[300];
char s[200100];
 
int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	LL ans = n * (n - 1) / 2 + 1;
	forn(i, 1, n) ++cnt[s[i]];
	forn(i, 'a', 'z') ans -= cnt[i] * (cnt[i] - 1) / 2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
import sys
input = lambda: sys.stdin.readline().rstrip()

class SegmentTree():
    def __init__(self, init, unitX, f):
        self.f = f # (X, X) -> X
        self.unitX = unitX
        self.f = f
        if type(init) == int:
            self.n = init
            self.n = 1 << (self.n - 1).bit_length()
            self.X = [unitX] * (self.n * 2)
        else:
            self.n = len(init)
            self.n = 1 << (self.n - 1).bit_length()
            self.X = [unitX] * self.n + init + [unitX] * (self.n - len(init))
            for i in range(self.n-1, 0, -1):
                self.X[i] = self.f(self.X[i*2], self.X[i*2|1])
        
    def update(self, i, x):
        i += self.n
        self.X[i] = x
        i >>= 1
        while i:
            self.X[i] = self.f(self.X[i*2], self.X[i*2|1])
            i >>= 1
    
    def getvalue(self, i):
        return self.X[i + self.n]
    
    def getrange(self, l, r):
        l += self.n
        r += self.n
        al = self.unitX
        ar = self.unitX
        while l < r:
            if l & 1:
                al = self.f(al, self.X[l])
                l += 1
            if r & 1:
                r -= 1
                ar = self.f(self.X[r], ar)
            l >>= 1
            r >>= 1
        return self.f(al, ar)
    
    def max_right(self, l, z):
        if l >= self.n: return self.n
        l += self.n
        s = self.unitX
        while 1:
            while l % 2 == 0:
                l >>= 1
            if not z(self.f(s, self.X[l])):
                while l < self.n:
                    l *= 2
                    if z(self.f(s, self.X[l])):
                        s = self.f(s, self.X[l])
                        l += 1
                return l - self.n
            s = self.f(s, self.X[l])
            l += 1
            if l & -l == l: break
        return self.n
    def min_left(self, r, z):
        if r <= 0: return 0
        r += self.n
        s = self.unitX
        while 1:
            r -= 1
            while r > 1 and r % 2:
                r >>= 1
            if not z(self.f(self.X[l], s)):
                while r < self.n:
                    r = r * 2 + 1
                    if z(self.f(self.X[l], s)):
                        s = self.f(self.X[l], s)
                        r -= 1
                return r + 1 - self.n
            s = self.f(self.X[r], s)
            if r & -r == r: break
        return 0

N, Q = map(int, input().split())
A = [int(a) for a in input().split()]
st = SegmentTree(A, 0, max)
for _ in range(Q):
    t, a, b = map(int, input().split())
    if t == 1:
        st.update(a-1, b)
    elif t == 2:
        print(st.getrange(a-1, b))
    else:
        z = lambda x: x < b
        print(min(N, st.max_right(a-1, z)) + 1)

Measured memory_bytes: 104540
n,l = map(int,input().split())
n_l = [0]*n
flag = "ng"
for i in range(n):
    n_l[i] = l + (i+1) - 1
    if n_l[i] == 0:
        flag = "ok"
if flag == "ok":
    print(sum(n_l))
    exit()
n_l_min = min(n_l)
if n_l_min < 0 :
    print(sum(n_l)-max(n_l))
    exit()
print(sum(n_l)-n_l_min)
#print(n_l)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    string T;
    cin >> T;

    for(ll i=0; i<T.size(); i++){
        if(T.at(i) == '?'){
            T.at(i) = 'D';
        }
    }
    cout << T << endl;
}

Measured memory_bytes: 3528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long cnt = x / 11;
		long ret = cnt * 11;
		cnt *= 2;
		int[] ary = new int[2];
		ary[0] = 6;
		ary[1] = 5;
		long index = 0;
		while (x > ret) {
			ret += ary[(int) index];
			cnt++;
			index = (index + 1) % 2;
		}
		System.out.println(cnt);

	}
}

Measured memory_bytes: 23380
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define fr(x,y) for(int x=0; x<(y); ++x)
#define fr2(x,z,y) for(int x=z; x<(y); ++x)
#define Rabee_Adel          file();
const double PI = acos(-1), EPS = 1e-7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
ll mod = 998244353;
ll power(ll x, ll y){if (y == 0)return 1;if (y == 1)return x;ll r = power(x, y / 2) % mod;return r%mod*r%mod*power(x, y % 2) % mod;}
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int main()
{

	Rabee_Adel
		int n,x;
	cin >> n;
	vi v(n + 1,0);
	fr(i, n-1){
		cin >> x;
		v[x]++;
	}
	fr2(i, 1, n + 1)cout << v[i] << endl;
	 
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll N, M; cin >> N >> M;
  ll A[N+1]={}; rep(i,N) cin >> A[i];
  ll B[M+1]={}; rep(i,M) cin >> B[i];
  sort(A,A+N+1, [](const int &x, const int &y){return x>y;});
  sort(B,B+M+1, [](const int &x, const int &y){return x>y;});  
  rep(i,N) if (A[i+1]==A[i]||B[i+1]==B[i]) { cout << 0 << endl; return 0; }

  ll result = 1;
  ll pa = 0, pb = 0;
  for (int i=N*M; i>=1; i--) {
    if (A[pa]==i&&B[pb]==i) {
      pa++; pb++;
    }
    else if (A[pa]==i) {
      pa++;
      result *= pb; result %= MOD;
    }
    else if (B[pb]==i) {
      pb++;
      result *= pa; result %= MOD;
    } 
    else {
      result *= pa*pb-(N*M-i); result %= MOD;
    }
    // cout << i << ":" << result << endl;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll T1, T2;
    cin >> T1 >> T2;
    ll A1, A2, B1, B2;
    cin >> A1 >> A2 >> B1 >> B2;
    if((A1 > B1 && A2 > B2) || (A1 < B1 && A2 < B2)) {
        cout << 0 << endl;
    } else {
        if(A1 < B1) {
            swap(A1, B1);
            swap(A2, B2);
        }
        // A1>B1
        ll C = A1 - B1;
        ll D = A2 - B2;
        if(C * T1 + D * T2 > 0) {
            cout << 0 << endl;
        } else if(C * T1 + D * T2 == 0) {
            cout << "infinity" << endl;
        } else {
            cout << (C * T1 / ((abs(D) * T2) - C * T1)) * 2 + 1 -
                        !(C * T1 % ((abs(D) * T2) - C * T1))
                 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;  cin >> str;
    int q;  cin >>q;
    for(int i = 0; i < q; i++){
        string order; 
        int a,b;
        cin >> order >> a >> b;
        if(order == "print"){
            cout << str.substr(a,(b-a+1)) << endl;
        }else if(order == "reverse"){
            string work = str.substr(a,(b-a+1));
            reverse(work.begin(), work.end());
            str = str.substr(0, a) + work + str.substr(b+1);
        }else if(order == "replace"){
            string p; cin >> p;
            str = str.substr(0, a) + p + str.substr(b+1);
        }
    }
}


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

int main(){
    while(1){
        string str;
        cin>>str;
        if(str=="-"){
            break;
        }
        int n;
        cin>>n;
        for(int i=0; i<n; i++){
            int m;
            cin>>m;
            string head=str.substr(0,m);
            string tail=str.substr(m,str.length()-m+1);
            str = tail + head;
        }
        cout<<str<<endl;
    }
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



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

	set<int> st;
	FOR(i, 3, 10) {
		ll a = 1;
		REP(j, i)a *= 3;

		REP(k, a) {
			ll t = 0;
			int tmp = k;
			REP(j, i) {
				t *= 10;
				if (tmp % 3 == 0)t += 3;
				else if (tmp % 3 == 1)t += 5;
				else t += 7;
				tmp /= 3;
			}
			st.insert(t);
		}
	}
	int ans = 0;
	for (auto a : st) {
		if (a > n)continue;
		map<int,int> m;
		int b = a;
		while (b > 0) {
			m[b % 10]++;
			b /= 10;
		}
		if (m.size() == 3)ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 1664
program main
  implicit none
  integer :: i, j, N
  integer,allocatable,dimension(:, :) :: v, dp
  logical,dimension(3, 3) :: f
  f = .true.
  do i = 1,3
    f(i, i) = .false.
  enddo

  read*, N
  allocate(dp(3, N), v(3, N))
  do i = 1, N
    read*, v(:, i)
  end do

  dp(:, 1) = v(:, 1)
  do i = 2, N
    do j = 1, 3
      dp(j, i) = maxval(pack(dp(:, i-1), f(:, j))) + v(j, i)
    enddo
  enddo
  print*, maxval(dp(:, N))
end

Measured memory_bytes: 2560
package main

import (
	"fmt"
	"math/big"
)

func main() {
	var n, ans int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var x int64
		fmt.Scan(&x)
		// こういう意図ではないが…。
		if big.NewInt(x).ProbablyPrime(0) {
			ans++
		}
		// if isPrime(x) {
		// 	ans++
		// }
	}
	fmt.Println(ans)
}

func isPrime(x int) bool {
	if x == 2 {
		return true
	}
	if x <= 1 || x%2 == 0 {
		return false
	}

	for i := 3; i*i <= x; i += 2 {
		if x%i == 0 {
			return false
		}
	}
	return true
}



Measured memory_bytes: 6040
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;


const int max_comb=200000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

template<class T> class BIT   // 1-indexed (0 is not used)
{
private:
    int num;
    vector<T> bit;
public:
    BIT(int n):bit(vector<T>(n+1, 0)), num(n) {}

    T sum(int i) {   // sum of 1..i
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, T x) {
        if (i > num) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

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

    vector<int> x(n), y(n);
    vector<pair<int,int> > xx(n);   // x,id
    vector<pair<int,int> > yy(n);   // x,id
    int i;
    for(i=0; i<n; i++) {
        scanf("%d%d", &x[i], &y[i]);
        xx[i]=make_pair(x[i], i);
        yy[i]=make_pair(y[i], i);
    }
    sort(xx.begin(),xx.end());
    sort(yy.begin(),yy.end());

    map<int,int> mpy;
    for(i=0; i<n; i++) {
        mpy[yy[i].first]=i;
    }

    vector<ll> cnt(4*n);
    BIT<int> bit(n);
    for(i=0; i<n; i++) {
        int id=xx[i].second;
        cnt[id*4+2]=bit.sum(mpy[y[id]]+1);
        cnt[id*4+1]=i-cnt[id*4+2];
        bit.add(mpy[y[id]]+1, 1);
    }
    for(i=0; i<n; i++) {
        int id=yy[i].second;
        cnt[id*4+3]=i-cnt[id*4+2];
        cnt[id*4+0]=n-1-cnt[id*4+1]-cnt[id*4+2]-cnt[id*4+3];
    }

    ll ans=0;
    for(i=0; i<n; i++) {
        ll ans0=mpow(2,n)-1;
        int k;
        for(k=0; k<4; k++) {
            int numtmp=cnt[i*4+k]+cnt[i*4+(k+1)%4];
            ans0 = (ans0 - mpow(2, numtmp%(MOD-1))+MOD) %MOD;
        }
        for(k=0; k<4; k++) {
            int numtmp=cnt[i*4+k];
            ans0 = (ans0 + mpow(2, numtmp%(MOD-1))+MOD) %MOD;
        }
        ans = (ans + ans0)%MOD;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 26496
#include<bits/stdc++.h>
using namespace std;
bool table[110][12];
int p[102][12];
int c[11];
int main(){
    int n;
    while(cin>>n){
        for(int i=0;i<n;++i)
            for(int j=0;j<10;++j) cin>>table[i][j];
        for(int i=0;i<n;++i)
            for(int j=0;j<11;++j) cin>>p[i][j];
        int ans=-0x3f3f3f3f;
        for(int i=1;i<1024;++i){

            for(int j=0;j<10;++j) c[j]=i>>j&1;
            int a=0,b;
            for(int j=0;j<n;++j){
                b=0;
                for(int k=0;k<10;++k)
                    if(c[k] && table[j][k]) ++b;
                a+=p[j][b];
            }
            if(a>ans) {
                ans=a;
            }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i,N)cin>>a[i];
  sort(All(a));
  int al = 0, bo = 0;
  bool flag = false;
  for (int i = 0; i < N;i++){
    if(!flag)
      al += a[N - 1 - i];
    else
      bo += a[N - 1 - i];
    flag ^= true;
  }
  cout << al - bo << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
	int n,k,x,ans = 0;
	cin >> n >> k;
	FOR(i,0,n){
		cin >> x;
		ans += min(x,abs(x-k));
	}
	cout << ans*2;
	return 0;
}

Measured memory_bytes: 256
//code by parshuram_84
#include <bits/stdc++.h>
#define mod 1000000007
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
#define mp make_pair
typedef std::numeric_limits< double > dbl;
using namespace std;
 
ll power(ll a,ll b)
{
	ll z=1,p=mod;
	while(b>0)
	{
		if(b&1) z=(z*a)%p;
		a=(a*a)%p;
		b=b>>1;
	}
	return z;
}
 
int main() {
	IOS;
	ll i,k,a,b,c=0;
	cin>>k>>a>>b;
	for(i=a;i<=b;i++)
	{
		if(i%k==0) 
		{
			c=1;
			cout<<"OK";
			break;
		}
	}
	if(c==0) cout<<"NG";
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int64 solve() {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    vector<vector<int>> id(26);
    rep(i, 0, N) id[S[i] - 'a'].push_back(i);
    int pos = -1;
    int64 ans = 0;
    for(auto &c : T) {
        int i = c - 'a';
        if(id[i].empty()) return -1;
        auto nx = upper_bound(id[i].begin(), id[i].end(), pos);
        if(nx == id[i].end()) {
            pos = id[i][0];
            ans += N;
        } else pos = *nx;
    }
    return ans + pos + 1;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <sstream>

using namespace std;
typedef long long ll;
ll n, m, k;
ll a[200001];
ll b[200001];
ll d[200001];

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < m; i++)cin >> b[i];
	d[0] = b[0];
	for (int i = 1; i < m; i++)d[i] = d[i - 1] + b[i];
	int ans = 0;
	ll cnt = 0;
	for (int i = 0; i <= n; i++) {
		ll tmp = k - cnt;
		int ret = i;
		if (tmp < 0)break;
		int l = 0;
		int r = m - 1;
		while (l <= r) {
			int mid = (l + r) / 2;
			if (d[mid] <= tmp) {
				l = mid + 1;
			}
			else r = mid - 1;
		}
		ans = max(ans, ret + r + 1);
		if (i == n)break;
		cnt += a[i];
	}

	cout << ans << '\n';

}

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

struct node{
  //int id;
  int k;
  //int pk;
  //int lk;
  //int rk;
};
typedef struct node *Node;

int largest;

int parent(i){
  return floor(i/2);
}

int left(i){
  return 2*i;
}

int right(i){
  return (2*i)+1;
}

void maxHeapify(Node A,int i, int H){
  struct node b;
  int l = left(i)+1;
  int r = right(i)+1;
  if(l <= H && A[l].k > A[i].k)
    largest = l;
  else{
    largest = i;
  }
  if(r<=H && A[r].k > A[largest].k){
    largest = r;
  }

  if(largest != i){
    b = A[i];
    A[i] = A[largest];
    A[largest] = b;
    maxHeapify(A, largest, H);
  }
}

void buildMaxHeap(Node A, int H){
  int i;
  for(i=H/2-1; i>=0; i--){
    maxHeapify(A, i, H);
  }
}

int main(){

  int H, i, K, P;
  Node n;
  //int *A;
  scanf("%d",&H);

  //A = (int *)malloc(sizeof(int)*H);
  n = (Node)malloc(sizeof(Node)*H);

  for(i=0; i<H; i++){
    scanf("%d", &K);
    n[i].k = K;
    }

  buildMaxHeap(n,H);

  for(i=0; i<H; i++){
    printf(" %d",n[i].k);
  }
  printf("\n");

  return 0;
}


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

using namespace std;

#define ll long long 

ll n, CAP,w[105],v[105], dp[105][100005];

ll knapsack(ll item, ll weight)
{
	if(item > n)
	{
		return 0;
	}
	
	if(dp[item][weight] != -1) return dp[item][weight];
	
	ll ans1 = 0;
	
	if(weight + w[item] <= CAP)
	{
		ans1 = knapsack(item+1, weight+w[item]) + v[item];
	}
	
	ll ans2 = knapsack(item+1, weight);
	
	return dp[item][weight] = max(ans1, ans2);
}

int main()
{
	ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    	
	cin >> n >> CAP;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> w[i] >> v[i];
	}
	
	memset(dp, -1, sizeof(dp));
	
	ll ans = knapsack(1,0); 
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 82304
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! 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")
    };
}

fn main() {
    input! {
        a: u64,
        b: u64,
        c: u64,
    }
    for i in 1..b+1 {
        if a * i % b == c {
            println!("YES");
            return;
        }
    }
    println!("NO");
}


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


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

using namespace std;

const int N = 1e6 + 7;

int n;
long long a[N];

long long base[100];
long long xr, xrs;

void add(long long x)
{
        for (int i = 62; i >= 0; i--)
        {
                if (x & (1LL << i))
                {
                        if (!base[i] && (xrs & (1LL << i)))
                        {
                                base[i] = x;
                                break;
                        }
                        x ^= base[i];
                }
        }
        return;
}

long long Max(long long x)
{
        long long ret = 0;
        long long mask = 0;

        for (int i = 62; i >= 0; i--)
        {
                if (!base[i] || !(x & (1LL << i)) || ret & (1LL << i))
                        continue;
                ret ^= base[i];
        }

        return ret << 1;
}

int main()
{

        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);

        cin >> n;

        for (int i = 0; i < n; i++)
        {
                cin >> a[i];
                xr ^= a[i];
        }

        long long ans = xr;
        xrs = xr ^ ((1LL << 62) - 1);

        for (int i = 0; i < n; i++)
        {
                a[i] &= xrs;
                add(a[i]);
        }

        long long mxx = Max(xrs);
        cout << mxx + ans;

        return 0;
}

Measured memory_bytes: 4404
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
#define ll long long 
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 0, n) {
        string t, r;
        int sum = 0;
        t = s.substr(0, i);
        r = s.substr(i);
        sort(t.begin(), t.end()); sort(r.begin(), r.end());
        t.erase(unique(t.begin(), t.end()), t.end());
        r.erase(unique(r.begin(), r.end()), r.end());
        rep(j, 0, t.size()) {
            if(r.find(t[j]) != string::npos) {
                sum++;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 51;
int n, m, s, c[N], d[N];
struct edge {
    int to, a, b;
    edge(int _t, int _a, int _b) {
        to = _t;
        a = _a;
        b = _b;
    }
};
vector<edge> graph[N];

int seen[N][2501];
int ans[N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> s;
    for(int i = 0; i < m; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        graph[u].emplace_back(v, a, b);
        graph[v].emplace_back(u, a, b);
    }

    for(int i = 1; i <= n; ++i) {
        cin >> c[i] >> d[i];
    }

    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= 2500; ++j) {
            seen[i][j] = -1000000000000000000;
        }
    }

    int ct = 0;
    priority_queue<pair<int, pair<int, int>>> pq;
    pair<int, int> st = {1, min(s, 2500LL)};
    pq.emplace(0, st);
    while(!pq.empty() && ct < n-1) {
        auto p = pq.top(); pq.pop();
        int cost = p.first;
        pair<int, int> cur = p.second;
        if(cost < seen[cur.first][cur.second]) {
            continue;
        }
        if(ans[cur.first] == 0 && cur.first > 1) {
            ans[cur.first] = -cost;
            ct++;
        }

        if(cur.second < 2500) {
            pair<int, int> nxt = {cur.first, min(2500LL, cur.second + c[cur.first])};
            int ncst = cost-d[cur.first];
            if(seen[nxt.first][nxt.second] < ncst) {
                pq.emplace(cost-d[cur.first], nxt);
                seen[nxt.first][nxt.second] = ncst;
            }
        }

        for(edge e : graph[cur.first]) {
            if(cur.second >= e.a) {
                pair<int, int> nx = {e.to, cur.second - e.a};
                int nc = cost-e.b;
                if(seen[nx.first][nx.second] < nc) {
                    pq.emplace(cost-e.b, nx);
                    seen[nx.first][nx.second] = nc;
                }
            }
        }
    }

    for(int i = 2; i <= n; ++i) {
        cout << ans[i] << '\n';
    }
    
    return 0;
}


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

int main(){
    ll n;
    cin >> n;
    ll ama;
    ama = n * (n-1) / 2;


    cout << ama << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int a[200010];
int main(){
    int n;
    cin >> n;

    for(int i = 0; i < n; i++){
      if(i%2 == 0) cin >> a[(n-1)/2 - (i+1)/2];
      else cin >> a[(n-1)/2 + (i+1)/2];
    }

    if(n%2 != 0){
      for(int i = 0; i < n; i++) cout << a[i] << " ";
    }
    else{
      for(int i = 0; i < n; i++) cout << a[n-1-i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944