akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

    int cnt = 0;

    for (int i = 0; i < T.size(); i++) {
        char cur = T.at(i);

        if (cur == '?') {
            T.replace(i, 1, "D");
        }
    }

    cout << T << endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;

int main (void) {
  int N;
  int A[110]={0};
  int alice=0;
  int bob=0;
  cin >> N;
  for (int i=0; i<=N-1; i++) {
    cin >> A[i];
  }
  sort(A, A+110, greater<int>());
  for (int i=0; i<=N-1; i++) {
    if (i%2 == 0){
      alice= alice +A[i];
    }
    else {
      bob = bob+A[i];
    }
  }
  int ans=0;
  ans=alice - bob;
  cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
    #include<math.h>
     
    int main(void){
    int M,N;
    int i , j , k; 
      
    scanf("%d %d",&N,&M);    
   long int a[N][3];  
   long int b[8][N];
    for(i = 0;i<N;i++){
	    scanf("%ld %ld %ld",&a[i][0],&a[i][1],&a[i][2]);
      //  b[i] = a[i][0] + a[i][1] + a[i][2];
      //  printf("%d  %d  %d	%d \n",a[i][0],a[i][1],a[i][2],b[i]);
      }
    for(i = 0;i<N;i++){
        b[0][i] = a[i][0] + a[i][1] + a[i][2];
      }
    for(i = 0;i<N;i++){
        b[1][i] = -a[i][0] + a[i][1] + a[i][2];
      }
    for(i = 0;i<N;i++){
        b[2][i] = a[i][0] - a[i][1] + a[i][2];
      }
    for(i = 0;i<N;i++){
        b[3][i] = a[i][0] + a[i][1] - a[i][2];
      }
    for(i = 0;i<N;i++){
        b[4][i] = -a[i][0] - a[i][1] + a[i][2];
      }
    for(i = 0;i<N;i++){
        b[5][i] = -a[i][0] + a[i][1] - a[i][2];
      }
    for(i = 0;i<N;i++){
        b[6][i] = a[i][0] - a[i][1] - a[i][2];
      }      
    for(i = 0;i<N;i++){
        b[7][i] = -a[i][0] - a[i][1] - a[i][2];
      }      
      

   for(k=0;k<8;k++){
          long int tmp=0;
    for(i=0;i<N;i++){
    	for(j=N-1;j>i;j--){
          	if(b[k][j]>b[k][j-1]){
      		  	tmp = b[k][j];
              	b[k][j] = b[k][j-1];
              	b[k][j-1] = tmp;
            }     
        }
    } 
   }
   long int sum[8]={0};
   long int num = 0;
    for(k=0;k<8;k++){
    num = 0;
    	for(i=0;i<M;i++){
    		sum[k] = sum[k] + b[k][num];
      		num++;
    	}
    }
   
  long int max = sum[0];   
   for(i=0;i<8;i++){
	   max = ((sum[i] > max) ? sum[i] :max);
   }
      
    printf("%ld \n",max);
    return 0;
    }

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

int main() {

    string S;

    cin >> S ;

    string ans_str;

    // ビットの全組み合わせループ
    for (int tmp = 0; tmp < 1 << 3; tmp++) {

        //ビット表現(0000)
        bitset<3> s(tmp);
        //cout << s << "  -------"<<endl;

        long sum = S[0]-48;
        //cout << "sum: "<< sum << endl;

        string sum_str;
        ans_str = to_string(S[0]-48);

        for (long i = 0; i < S.size() - 1; i++) {
            sum_str = S[i+ 1];
            if (s.test(i)) {
                sum += stoll(sum_str.c_str());
                ans_str += "+" + sum_str;
            }else{
                sum -= stoll(sum_str.c_str());
                ans_str += "-" + sum_str;
            }
            //cout << "sum: "<< sum << endl;
        }
        if (sum == 7){
            //cout << S << endl;
            //
            ans_str += "=7"; 
            cout << ans_str << endl;
            return 0;

        }
    }
    //cout << ans_str << endl;

    return 0;

}

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

using namespace std;

int main(){
	int N;
	while (cin >> N, N) {
		vector<int> s;
		for (int i = 1; i < sqrt(N); i++) {
			if (N % i == 0) {s.push_back(i); s.push_back(N / i);}
		}
		int S = 0;
		for (int i = 0; i < s.size(); i++) {S += s[i];}
		S -= N;
		if (S - N) {
			if (S > N) cout << "abundant number" << endl;	
			else cout << "deficient number" << endl;
		} else {
			cout << "perfect number" << endl;	
		}
	}
	return 0;
}

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


int main()
{
	int n;
	cin >> n;
	char suit;
	int value;
	bool card[4][13];
	for(int i = 0; i < 4; i++)
		for (int j = 0; j < 13; j++)
			card[i][j] = true;
	for(int i = 0; i < n; i++)
	{
		cin >> suit >> value;
		if (suit == 'S')
			card[0][value-1] = false;
		else if (suit == 'H')
			card[1][value-1] = false;
		else if (suit == 'C')
			card[2][value-1] = false;
		else
			card[3][value-1] = false;
	}

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			if (i == 0 && card[i][j])
				cout << "S " << j + 1 << endl;
			else if (i == 1 && card[i][j])
				cout << "H " << j + 1 << endl;
			else if (i == 2 && card[i][j])
				cout << "C " << j + 1 << endl;
			else if (i == 3 && card[i][j])
				cout << "D " << j + 1 << endl;
		}
	}
			
	return 0;
}




Measured memory_bytes: 3080
m = int(input())
num_list = list(map(int,input().split()))
ans_list = [0]*m
print_list = []
for i in range(m,0,-1):
    if num_list[i-1] == 0:
        cnt = 0
        for j in range(2,m//i+1):
            cnt += ans_list[i*j-1]
        if cnt % 2 == 1:
            ans_list[i-1] = 1
            print_list.append(i)
    elif num_list[i-1] == 1:
        cnt = 0
        for j in range(2,m//i+1):
            cnt += ans_list[i*j-1]
        if cnt % 2 == 0:
            ans_list[i-1] = 1
            print_list.append(i)
            
if not print_list:
    print(0)
    
else:
    print(sum(ans_list))
    print(*print_list)

Measured memory_bytes: 14460
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int Q = scan.nextInt();
        Map<Integer, Node> map = new HashMap<>();
        Node root = new Node(1);
        map.put(1, root);
        for (int i = 1; i < N; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            if (!map.containsKey(a)) {
                Node a_n = new Node(a);
                map.put(a,a_n);
            }
            if (!map.containsKey(b)) {
                Node b_n = new Node(b);
                map.put(b,b_n);
            }
            Node a_n = map.get(a);
            Node b_n = map.get(b);
            a_n.add(b_n);
            b_n.parent(a_n);
        }
        for (int i = 0; i < Q; i++) {
            int p = scan.nextInt();
            long x = scan.nextLong();
            Node n = map.get(p);
            n.increment += x;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= N; i++) {
            Node x = map.get(i);
            sb.append(x.score());
            sb.append(" ");
        }
        System.out.println(sb.substring(0, sb.length()-1));
    }
    class Node {
        int x;
        long increment;
        long score;
        Node parent;
        List<Node> neibors;
        Node(int x) {
            this.x = x;
            this.parent = null;
            this.increment = 0;
            this.score = -1;
            this.neibors = new ArrayList<>();
        }
        void add(Node child) {
            neibors.add(child);
        }
        void parent(Node parent) {
            if (this.parent == null) {
                this.parent = parent;
            }
            if (this.parent.x != parent.x) {
                throw new Error();
            }
        }
        long score() {
            if (this.score != -1) {
                return this.score;
            }
            Node parent = this.parent;
            if (parent == null) {
                this.score = this.increment;
                return this.score;
            }
            this.score = this.increment + this.parent.score();
            return this.score;
        }
    }
}


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


//using ll = long long;
int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long min(long a, long b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}

int main(void)
{
	long a, b, c, k, num = 0, ans = 0;
	scanf("%ld%ld%ld%ld",&a,&b,&c,&k);
	ans += min(a, k);
	if (a <= k)
		num = k - a;
	if (b <= num)
		num = num - b;
	else
		num = 0;
	ans -= min(c, num);
	printf("%ld",ans);

	return 0;
}

Measured memory_bytes: 1736
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	int a, b;
	cin >> a >> b;

	if (a >= 13) {
		cout << b << endl;
	} else if (a >= 6) {
		cout << b / 2 << endl;
	} else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;  
#define min_heap(t) priority_queue<t,vector<t>,greater<t>>
#define max_heap(t) priority_queue<t>
#define ordered_set(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define orderKey order_of_key
#define findOrder find_by_order
#define F first
#define S second
#define pb emplace_back 
#define mp make_pair
#define f(i,x,y) for(i=x;i<y;i++) 
#define fo(i,x,y) for(i=x;i>=y;i--)
#define all(v) v.begin(),v.end()
#define ss(v) stable_sort(all(v))
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n' 
#define pi  3.14159265358
long long po(long long int m,long long int n){
long long i=1; 
while(n>0)
{
    if(n%2==1)
      i=(i*m);
    n=n/2;
    m=(m*m);
}
return(i);
}
void solve(void){  
    ll n,i,x;
    cin>>n;
    vector<vector<ll>>dp(n+1,vector<ll>(3,0));
    for(i=1;i<=n;i++){
        cin>>x;
        dp[i][0]=x+max(dp[i-1][1],dp[i-1][2]); 
        cin>>x;
        dp[i][1]=x+max(dp[i-1][0],dp[i-1][2]);
        cin>>x;
        dp[i][2]=x+max(dp[i-1][1],dp[i-1][0]);
    } 
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main(void){
    fastio
    ll __=1;
    //cin>> __;
    while(__--){
        solve();
    }
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    vector<ll> a, b, c;
    ll tmp;
    rep(i, n)
    {
        cin >> tmp;
        a.push_back(tmp);
    }
    rep(i, n)
    {
        cin >> tmp;
        b.push_back(tmp);
    }
    rep(i, n)
    {
        cin >> tmp;
        c.push_back(tmp);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll cnt = 0;
    rep(j, n)
    {
        auto itr_a = lower_bound(a.begin(),a.end(), b[j]);
        auto itr_c = upper_bound(c.begin(),c.end(), b[j]);
        cnt += (itr_a - a.begin()) * (c.end()-itr_c);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6424
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    int N,M; cin >> N >> M;
    int l,r,imos[N+5],a[N+5];
    fill(imos,imos+N+5,0);
    fill(a,a+N+5,0);
    for(int i = 0; i < M; i++){
        cin >> l >> r;
        a[l]++; a[r+1]--;
    }
    imos[0] = a[0];
    for(int i = 1; i < N+3; i++){
        imos[i] = imos[i-1]+a[i];
    }
    int ans = 0;
    for(int i = 0; i < N+3; i++){
        if (imos[i] >= M) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	ans = int(N * (N - 1) // 2) + int(M * (M - 1) // 2)
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			if(n==0){break;}
			int score[]=new int[n];
			for(int i = 0;i<n;i++){
				score[i]=cin.nextInt();
			}
			Arrays.sort(score);
			int sum=0;
			for(int i = 1;i<n-1;i++){
				sum+=score[i];
			}
			System.out.println(sum/(n-2));
		}
	}

}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main()
{
  int i,j;
  char s[3][3];
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
      cin>>s[i][j];
      if(i==j)
      {
        cout<<s[i][j];
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
  
   string n;
   cin >> n;
  
   //cout << n << endl;
  
  int ans = 0;
  
for(int i = 0;i<n.size();i++){
  
     //cout << n[i] << endl;
  
  int sum = 0;
    
  for(int j = 0;j<n.size();j++){
    
     if(n[i]==n[j]){
       sum = sum + 1;
     }
    
  }
  
  if(sum%2==0){
    
    ans = ans + 1;
  }
  
  
}
  
  if(ans==n.size()){
    
    cout << "Yes" << endl;
    
  }else{
    
    cout << "No" << endl;
  }
  
  
 
  return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int n = int.Parse(input[0]);
    int T = int.Parse(input[1]);
    int C = 1001;
	for(int i = 0;i<n;i++){
      string[] inputl = Console.ReadLine().Split(' ');
      int c = int.Parse(inputl[0]);
      int t = int.Parse(inputl[1]);
      if(t <= T){
        if(c<C){
        C = c;
      }}
    }
    if (C == 1001){
      Console.WriteLine("TLE");
    }
    else{
      Console.WriteLine(C);
      
    }
  }
}
      
      


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int r[300];
int vis[300];
int mapp[300][300];
int inf=0X3f3f3f3f;
int main()
{
    int n,m,R;
    while(cin>>n>>m>>R)
    {
        for(int i=0;i<=300;i++)
            vis[i]=-1;
        for(int i=0;i<R;i++)
        {
            cin>>r[i];
        }
        int a,b,c;
        int k=0;
        for(int i=1;i<=300;i++)
        {
            for(int j=1;j<=300;j++)
            {
                if(i==j) mapp[i][j]=0;
                else mapp[i][j]=inf;
            }
        }
        for(int i=1;i<=m;i++)
        {
            cin>>a>>b>>c;
            if(c<mapp[a][b]|| c<mapp[b][a])
            {
                mapp[a][b]=c;
                mapp[b][a]=c;
            }
        }
        for(int k=1;k<=n;k++)
        {
            for(int i=1;i<=n;i++)
            {
                for(int j=1;j<=n;j++)
                {
                    if(mapp[i][j]>mapp[i][k]+mapp[k][j])
                    {
                        mapp[i][j]=mapp[i][k]+mapp[k][j];
                    }
                }
            }
        }
//        for(int i=1;i<=n;i++)
//        {
//            for(int j=1;j<=n;j++)
//            {
//                cout<<"mapp["<<i<<"]"<<"["<<j<<"]"<<"="<<mapp[i][j]<<endl;
//            }
//        }
        long long  minn=0X3f3f3f3f;
        long long  sum;
        sort(r,r+R);
        do
        {
            sum=0;
            for(int i=0;i<R-1;i++)
            {
//                cout<<mapp[r[i]][r[i+1]]<<endl;
                sum+=mapp[r[i]][r[i+1]];
            }
            if(sum<minn)
                minn=sum;
        }while(next_permutation(r,r+R));
        cout<<minn<<endl;
    }
}


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

#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fi first
#define se second
#define sz size()


int main()
{	ll n;cin>>n;
	VVI dp(n+1,VI(4,0));
	VVI v(n+1,VI(2,0));
	lf(i,1,n)
	{	cin>>v[i][0]>>v[i][1];
	}
	lf(i,0,3)
	{	ll sum=0;
		lf(j,0,1)
		{	if((1<<j)&i)
			{	sum+=(v[1][j]*(-1));	
			}
			else
			{	sum+=(v[1][j]*(1));
			}
		}
		dp[1][i]=sum;
	}
	ll maxi=0;
	lf(k,2,n)
	{	lf(i,0,3)
		{	ll sum=0;
			lf(j,0,1)
			{	if((1<<j)&i)
				{	sum+=(v[k][j]*(-1));	
				}
				else
				{	sum+=(v[k][j]*(1));
				}
			}
			dp[k][i]=sum;
			maxi=max(maxi,dp[k-1][i^3]+sum);
			dp[k][i]=max(dp[k][i],dp[k-1][i]);
		}
	}
	cout<<maxi<<endl;
}	

Measured memory_bytes: 28332
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = new String[3];
		int in[] = new int[3];
		while(true){
			str = br.readLine().split(" ");
			in = parseInts(str);
			if(in[0]==-1 && in[1]==-1 && in[2]==-1) break;
			if(in[0]==-1 || in[1]==-1){
				System.out.println("F");
			}else if(in[0]+in[1]>=80){
				System.out.println("A");
			}else if(in[0]+in[1]>=65){
				System.out.println("B");
			}else if(in[0]+in[1]>=50){
				System.out.println("C");
			}else if(in[0]+in[1]>=30){
				if(in[2]>=50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else{
				System.out.println("F");
			}
		}
	}
	static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0; i<s.length; i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	}
}

Measured memory_bytes: 16940
#include<bits/stdc++.h>
using namespace std;
const int maxn=311,maxt=200011;
int n,m,t,s[maxn],w[maxn][maxn],a[maxt],b[maxt];
void init(){
    scanf("%d%d%d",&n,&m,&t);
    for (int i=1;i<=m;++i) scanf("%d",s+i);
    for (int i=1;i<=n;++i) for (int j=1;j<=m;++j) scanf("%d",&w[i][j]);
    for (int i=1;i<=t;++i) scanf("%d%d",a+i,b+i);
}
bool check(int t){
    static int sx[maxn]; memcpy(sx,s,sizeof(s));
    static int wx[maxn][maxn]; memset(wx,0,sizeof(w));
    for (int i=1;i<=t;++i){
        --sx[b[i]]; ++wx[a[i]][b[i]];
    }
    static bool vis[maxn]; memset(vis,0,sizeof(vis));
    for (int t=1;t<=n;++t){
        for (int i=1;i<=n;++i) if (!vis[i]){
			bool flag=1;
			for (int j=1;j<=m;++j) if (wx[i][j]+max(0,sx[j])<w[i][j]){flag=0; break;}
            if (flag){
				vis[i]=1;
				for (int j=1;j<=m;++j) sx[j]+=wx[i][j];
            }
        }
    }
	for (int i=1;i<=n;++i) if (!vis[i]) return true;
	return false;
}
void work(){
    int t=1,w=::t;
    while (t<=w){
		int mid=(t+w)>>1;
		if (check(mid)) w=mid-1;else t=mid+1;
    }
    printf("%d\n",w==::t?-1:w+1);
}
int main(){
	init();
	work();
	return 0;
}

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

int main(void)
{
	 int n, m, l;
	long long int A[100][100] = { {} }, B[100][100] = { {} };
	long long int C[100][100] = { {} };

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

	for (int i = 0; i < m; i++)
		for (int j = 0; j < l; j++)
			cin >> B[i][j];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < l; j++)
			for (int k = 0; k < m; k++)
				C[i][j] += A[i][k] * B[k][j];


	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			cout << C[i][j];
			if (j != l - 1) cout << " ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll x;cin>>x;
    ll ans=x/11*2;
    x%=11;

    if(x==0){
        cout<<ans<<endl;
    }else if(x<=6){
        cout<<ans+1<<endl;
    }else{
        cout<<ans+2<<endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <functional>

using namespace std;

typedef pair<int, int> P;

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0 && m == 0) {
			break;
		}
		vector< vector<P> > hyou(m+1);
		vector< vector<P> > hyou2(m+1);
		vector<int> com(n+1);
		int r;
		cin >> r;
		int t, nn, mm, s;
		for (int i = 0; i < r; i++) {
			cin >> t >> nn >> mm >> s;
			if (s == 1) {
				com[nn] = t;
			} else {
				P p;
				p.first = com[nn];
				p.second = t;
				hyou2[mm].push_back(p);
			}
		}
		for (int i = 1; i < m+1; i++) {
			if (!hyou2[i].empty()) {
				priority_queue< P, vector<P>, greater<P> > pq;
				for (int j = 0; j < hyou2[i].size(); j++) {
					pq.push(hyou2[i][j]);
				}
				while (!pq.empty()) {
					P p = pq.top();
					pq.pop();
					if (hyou[i].empty()) {
						hyou[i].push_back(p);
					} else {
						if (hyou[i][hyou[i].size()-1].second < p.first) {
							hyou[i].push_back(p);
						} else if (hyou[i][hyou[i].size()-1].second > p.second) {
						} else {
							hyou[i][hyou[i].size()-1].second = p.second;
						}
					}
				}
			}
		}
		int q;
		cin >> q;
		int ts, te;
		for (int i = 0; i < q; i++) {
			cin >> ts >> te >> mm;
			int time = 0;
			if (!hyou[mm].empty()) {
				for (int j = hyou[mm].size()-1; j >= 0; j--) {
					if (hyou[mm][j].first < te) {
						if (hyou[mm][j].second > ts) {
							time += min(te, hyou[mm][j].second) - max(ts, hyou[mm][j].first);
						} else {
							break;
						}
					}
				}
			}
			cout << time << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1580
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

ll factorial(ll n) {
    return n * (n + 1) / 2;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        string s = ins();
        mpll mp;
        ll ans = 0;
        int i = 0;

        ll a_c = 0;
        ll bc_c = 0;

        while (i < s.size()) {

            bool plus = false;
            while (i < s.size() && s[i] == 'A') {
                plus = true;
                i++;
                a_c++;
            }
            while (i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C') {
                plus = true;
                i += 2;
                bc_c++;
            }
            ans += a_c * bc_c;
            if (!plus) {
                a_c = 0;
                bc_c = 0;
                i++;
            } else {
                bc_c = 0;
            }
        }

        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

//18:10~
fn main(){
    let line = read_as_vec::<usize>();
    let (h, w) = (line[0], line[1]);
    let n: usize = read_as_vec()[0];
    let a = read_as_vec::<usize>();

    let mut c : Vec<usize> = vec![0;w*h];

    let mut j = 0;
    for i in 0..a.len(){
        //c[i+j] = i+1;
        for k in 0..a[i]{
            c[j+k] = i+1;
        }
        j += a[i];
    }

    let mut square = vec![vec![0;w];h];
    for i in 0..h{
        for j in 0..w{
            square[i][j] = c[i*w+j];
        }
    }
    for i in 0..h{
        if i%2 == 0{
            square[i].reverse();
        }
    }

    for i in 0..square.len(){
        for j in 0..square[i].len(){
            print!("{} ", square[i][j]);
        }
        println!("");
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 998244353LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> S;
    rep(i, K) {
        ll l, r;
        cin >> l >> r;
        S.emplace_back(l, r);
    }
    vector<ll> dp(N);
    dp.front() = 1;
    dp[1] = -1;
    rep(i, N - 1) {
        if(dp[i] == 0) continue;
        iter(j, S) {
            ll temp;
            temp = (i + j.first) % MOD;
            if(temp < dp.size()) {
                (dp[temp] += dp[i]) %= MOD;
            }
            temp = (i + j.second + 1) % MOD;
            if(temp < dp.size()) {
                (dp[temp] -= dp[i]) %= MOD;
                if(dp[temp] < 0) (dp[temp] += MOD) %= MOD;
            }
        }
        (dp[i + 1] += dp[i]) %= MOD;
    }
    cout << dp.back() << endl;
    return 0;
}


Measured memory_bytes: 4824
package main

import (
	"fmt"
)

func main() {
	var input string
	fmt.Scan(&input)
	// fmt.Printf("input = %s\n", input)

	var s string
	for i := 0; i < len(input); i++ {
		t := input[i : i+1]
		switch t {
		case "0", "1":
			s += t
		case "B":
			if len(s) > 0 {
				s = s[0 : len(s)-1]
			}
		}
	}
	fmt.Println(s)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  int i,j,k,count,max=0;
  cin>>S>>T;
  for(i=0;i<(int)T.size();i++){
    for(j=0+i;j<(int)S.size()-(int)T.size()+i+1;j++){
      if(T.at(i)==S.at(j)){
        count=0;
        count++;
        for(k=1;(k<(int)T.size()-i)&&(k<(int)S.size()-j);k++){
          if(T.at(i+k)==S.at(j+k)){
            count++;
          }
        }
        if(count>max){
          max=count;
        }
      }
    }
  }
  cout<<T.size()-max<<endl;
}

Measured memory_bytes: 3596
#include <cstdio>
int main()
{
    int n, t;
    bool flag = true;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &t);
        if (t % 2 == 0)
        {
            //printf("%d %d\n", t % 3, t % 5);
            if (t % 3 && t % 5)
                flag = false;
        }
    }
    flag ? puts("APPROVED") : puts("DENIED");
    return 0;
}

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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define VT(T) vector<T>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	int m1, d1, m2, d2;
	cin>>m1>>d1>>m2>>d2;
	cout<<(m1!=m2)<<endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=998244353;

LL n,s,a[3010],dp[3010][6010],rev;

LL fastpow(LL x,LL a)
{
	LL res=x,ret=1;
	while(a>0)
	{
		if((a&1)==1) ret=ret*res%MOD;
		a>>=1;
		res=res*res%MOD;
	}
	return ret;
}

int main()
{
	rev=fastpow(2,MOD-2);
	cin>>n>>s;
	rep(i,n) cin>>a[i];
	dp[0][0]=1;
	rep(i,n) dp[0][0]=dp[0][0]*2%MOD;
	rep(i,n)
	{
		rep(j,s+1)
		{
			if(dp[i][j]==0) continue;
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
			dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j]*rev%MOD)%MOD;
		}
	}
	cout<<dp[n][s]<<endl;
	return 0;
}

Measured memory_bytes: 97616
package main

import "fmt"

func main() {
  var w string
  m := map[rune]int{}
  fmt.Scan(&w)
  for i := 0; i < len(w); i++ {
    m[rune(w[i])]++
  }
  for _, v := range m {
    if v%2 == 1 {
      fmt.Println("No")
      return
    }
  }
  fmt.Println("Yes")
  return
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"
#define ALL(x) (x).begin(),(x).end()
#define EXIST(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string n;
    cin >> n;
    for(char s : n){
        if(s == '1') cout << "9";
        else cout << "1";
    }
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;


int main() {
	int n, m, l;
	int a[101][101];
	int b[101][101];
	long long c[101][101];

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

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

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

Measured memory_bytes: 1316
import heapq
import numpy as np
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
flag = np.ones((X,Y,Z),dtype=np.bool)
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
heapq.heappush(ABC,(-1 * (A[0]+B[0]+C[0]),0,0,0))
flag[0][0][0] = False
ctr = 0
while ctr < K and ABC:
    s,a,b,c = heapq.heappop(ABC)
    print(-s)
    if a+1<X and flag[a+1][b][c]:
        heapq.heappush(ABC,(-1 * (A[a+1]+B[b]+C[c]),a+1,b,c))
        flag[a+1][b][c] = False
    if b+1<Y and flag[a][b+1][c]:
        heapq.heappush(ABC,(-1 * (A[a]+B[b+1]+C[c]),a,b+1,c))
        flag[a][b+1][c] = False
    if c+1<Z and flag[a][b][c+1]:
        heapq.heappush(ABC,(-1 * (A[a]+B[b]+C[c+1]),a,b,c+1))
        flag[a][b][c+1] = False
    ctr += 1

Measured memory_bytes: 989284
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <bitset>
#include <regex>
#include <cassert>
#include <set>
#include <map>
using namespace std;
#define inf 2000000000
#define mod 1000000007

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n,a=100,cnt=0;
	cin >> n;
	while (true) {
		if (a >= n) break;
		a = a + (a / 100);
		cnt++;
	}

	cout << cnt;
}

Measured memory_bytes: 3652
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
vi v[N];
ll cc[N];
ll dp[N];
ll dfs(ll node){
    ll temp=1,sexy=0;
    if(dp[node]!=0) return dp[node];
    for(auto i:v[node]){
        sexy=max(sexy,dfs(i));
    }
    temp+=sexy;
    return dp[node]=temp;
}
void solve(){
    ll n,m,a,b;
    cin>>n>>m;
    rep(i,1,m){
        cin>>a>>b;
        v[a].pb(b);
        cc[b]++;
    }
    ll ans=0;
    rep(i,1,n){
        if(cc[i]==0){
            ans=max(ans,dfs(i));
        }
    }
    cout<<ans-1;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 12032
def calc(c, cnt):
    r = [i % 2 for i in c]
    if sum(r) > 0:
        print(cnt)
        return 1
    else:
        for k, num in enumerate(c):
            c[k] = num / 2
        cnt += 1
        if calc(c, cnt) == 1:
            return 1
        

N = int(input())
c = [int(i) for i in input().rstrip().split(' ')]
calc(c, 0)


Measured memory_bytes: 3188
fun main(args:Array<String>) {
    val (H,W)=readLine()!!.split(" ").map(String::toInt)
    val blocks=(1..H).map{readLine()!!}.map {
      it.map {c->
        if(c=='#') {true} else {false}
      }
    }
    blocks.indices.map{
      Pair(it,blocks[it])
    }.map {
      val (i,row) = it
      (0.until(row.size)).map {j->
       if(blocks[i][j]) {
         "#"
       } else {
        val num = 
        listOf(Pair(i-1,j-1),Pair(i-1,j),Pair(i-1,j+1),
        Pair(i,j-1),Pair(i,j+1),
        Pair(i+1,j-1),Pair(i+1,j),Pair(i+1,j+1))
        .filter {pair->
          pair.first >=0 && pair.first <H && pair.second >=0 && pair.second < W
        }.map {pair->
          blocks[pair.first][pair.second]
        }.filter {isMine-> isMine}.size
        "${num}"
       }
      }
      .joinToString("")
    }.forEach {
      println(it)
    }
  }


Measured memory_bytes: 39536
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

void funcA() {

  int x;
  cin >> x;

  if (x >= 30) cout << "Yes";
  else cout << "No";
}

void funcB() {

  double n;
  double d;
  cin >> n >> d;
  vector<vector<double>> zahyo(n, vector<double>(2));

  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    zahyo[i][0] = x;
    zahyo[i][1] = y;
  }

  int count = 0;
  for (int i = 0; i < n; ++i) {
    double length = sqrt(pow(zahyo[i][0], 2) + pow(zahyo[i][1], 2));
    if (length <= d) ++count;
  }

  cout << count;


}

void funcC() {

  int k;
  cin >> k;
  int count = 0;

}

void funcD() {

  int n;
  cin >> n;
  int countR = 0;
  vector<char> color(n);
  for (int i = 0; i < n; ++i) {
    cin >> color[i];
    if (color[i] == 'R') ++countR;
  }
 

  int countW = 0;
  for (int i = 0; i < countR; ++i) {
    if (color[i] == 'W') ++countW;
  }

  cout << countW;

}

int main() {

  //funcA();
  //funcB();
  //funcC();
  funcD();

  return 0;
}

Measured memory_bytes: 3560
import bisect
N,M,K=map(int,input().split())
A=[int(x) for x in input().split()]
B=[int(y) for y in input().split()]
ans=0
a_nowtime=0
B_time=[0]*M
kari=0#time
for j in range(M):
    kari+=B[j]
    B_time[j]=kari
kari=0#numofbookofa+b
a_nowtime=0
for i in range(N+1):
    time=K-a_nowtime
    num=bisect.bisect_right(B_time,time)
    kari=i+num
    ans=max(ans,kari)
    if i==N:
        break
    a_nowtime+=A[i]

    if a_nowtime>K:
        break

print(ans)

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  ll A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  ll diff = abs(A-B);
  ll diffV = V-W;
  if(T*diffV >= diff){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  string s, t;
  std::cin >> s >> t;
  int Ns = s.size();
  int Nt = t.size();
  int dp[Ns + 1][Nt + 1] = {};
  REP(i, Ns) {
    REP(j, Nt) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
        dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
      }
    }
  }
  string ans = "";
  int x = Ns;
  int y = Nt;
  while (x > 0 && y > 0) {
    if (dp[x][y] == dp[x - 1][y]) {
      x--;
    } else if (dp[x][y] == dp[x][y - 1]) {
      y--;
    } else {
      x--;
      y--;
      ans = s[x] + ans;
    }
  }
  std::cout << ans << '\n';
  // REP(i, Ns + 1) {
  //   REP(j, Nt + 1) { std::cout << dp[i][j] << ' '; }
  //   std::cout << '\n';
  // }
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;


int main(void){
	int n;
	cin>>n;
	ll a[n],ans=0;
	rep(i,n){
		cin>>a[i];
		a[i]-=(i+1);
	}
	sort(a,a+n);
	//rep(i,n)cout<<a[i]<<endl;
	rep(i,n)ans+=abs(a[i]-a[(n+1)/2-1]);
	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string s, t;
    cin >> s >> t;

    set<char> necessaryChars;
    for (const auto ch : t)
    {
        necessaryChars.insert(ch);
    }

    const LLONG len = s.length();
    map<char, vector<LLONG>> positionMap;
    for (int i = 0; i < len; ++i)
    {
        positionMap[s[i]].push_back(i);
    }
    for (const char key : t)
    {
        if (positionMap.find(key) == positionMap.end())
        {
            cout << -1 << endl;
            return 0;
        }
    }

    map<pair<int, char>, int> curChar2stepMap;
    for (const auto &nes : necessaryChars)
    {
        int cur = 0;
        for (const auto pos : positionMap[nes])
        {
            for (; cur <= pos; ++cur)
            {
                curChar2stepMap[{cur, nes}] = pos - cur;
            }
        }
        for (cur = positionMap[nes].back() + 1; cur < len; ++cur)
        {
            curChar2stepMap[{cur, nes}] = len + positionMap[nes].front() - cur;
        }
    }

    LLONG ans = 0;
    LLONG cur = 0;
    for (const char key : t)
    {
        const int step = curChar2stepMap[{cur, key}];
        ans += step + 1;
        cur = ans % len;
    }
    cout << ans << endl;
}


Measured memory_bytes: 163904
#include<stdio.h>
#include<algorithm>
using namespace std;
#define MAXN 100
#define MAXW 10000

struct Item {
    int value, weight;
};

Item item[MAXN];
int C[MAXN][MAXW+1];
int N, W;

void knapsack() {
    for (int i=0; i<N; i++) {
        C[i][0] = 0;
    }

    for (int i=1; i<=W; i++) {
        if (i>=item[0].weight) C[0][i] = item[0].value;
        else C[0][i] = 0;
    }

    for (int i=1; i<N; i++) {
        for (int j=1; j<=W; j++) {
            if (j>=item[i].weight) C[i][j] = max(C[i-1][j], C[i-1][j-item[i].weight] + item[i].value);
            else C[i][j] = C[i-1][j];
        }
    }

    printf("%d\n", C[N-1][W]);
}

int main() {
    int val, wei;

    scanf("%d %d", &N, &W);

    for (int i=0; i<N; i++) {
        scanf("%d %d", &val, &wei);
        item[i].value = val;
        item[i].weight = wei;
    }

    knapsack();

    return 0;
}


Measured memory_bytes: 6664
#include <iostream>
#include <algorithm>
 
using namespace std;
 
static const int N = 100;
 
int main() {
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    for (int i = 1; i<= n; i++) {
        cin >> p[i-1] >> p[i];
    }
 
    for( int i = 1; i <= n; i++ ) m[i][i]=0;
    for( int l = 2; l <= n; l++ ) {
        for(int i = 1; i <= n-l+1; i++) {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for( int k = i; k <= j - 1; k++ ) {
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
 
    cout << m[1][n] << endl;
 
    return 0;
}
 

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

int main(){
  int64_t N; cin >> N;
  vector<int64_t> A(N);
  for(int64_t i=1; i<N; i++){
    cin >> A.at(i);
    A.at(i)--;
  }
  vector<int64_t> ans(N);
  for(int64_t i=1; i<N; i++){
    ans.at(A.at(i))++;
  }
  for(int64_t i=0; i<N; i++){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 6388
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int[] group = {-1, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
    String ans = "No";
    if(group[x] == group[y]) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
words = ['dreameraser', 'dreamerase', 'dreamer', 'eraser', 'dream', 'erase']

s = gets.chomp

while s != ""
  ok = false
  words.each{|w|
    if s.start_with?(w)
      ok = true
      s.slice!(0, w.size())
      break
    end
  }
  if !ok
    puts "NO"
    exit
  end
end

puts "YES"


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

int main() {
	// your code goes here
	long int t,k,sum,i;
	cin>>t>>k;
	long int a[t];
	for(i=0;i<t;i++)
	{
	    cin>>a[i];
	}
	sort(a,a+t);
	sum=0;
	for(i=0;i<k;i++)
	{
	    sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<vector<ll>> jobs(M+1);

    rep (i, N) {
        ll a, b;
        cin >> a >> b;
        if (a > M) {
            continue;
        }

        jobs[M-a].push_back(b);
    }

    priority_queue<ll> pq;
    ll ans = 0;

    rrep (i, M) {
        for (auto j : jobs[i]) {
            pq.push(j);
        }
        
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }

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

Measured memory_bytes: 5632
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

#define set fixed << setprecision(6)
#define area pow(r, 2) * M_PI
#define length r * 2 * M_PI

int main() {
	double r; cin >> r;
	cout << set << area << " " << length << endl;
	return 0;
}


Measured memory_bytes: 3200