akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        if(i%3==0&&i%5==0){

        }
        else if(i%3==0){

        }
        else if(i%5==0){

        }
        else
        {
            ans += i;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3636
#ifndef Suffix_array_hpp
#define Suffix_array_hpp

#include <algorithm>
#include <vector>
#include <numeric>

template <class str_type>
class suffix_array
{
    static constexpr size_t npos = -1;
    const str_type str;
    std::vector<size_t> ary, rank;

public:
    using value_type = typename str_type::value_type;

    operator std::vector<size_t>() const { return ary; }

    std::vector<size_t>::const_iterator begin() const { return ary.begin(); }
    std::vector<size_t>::const_iterator end() const { return ary.end(); }

    size_t operator[](size_t i) const { return ary[i]; }

    const str_type &string() const { return str; }

    size_t size() const { return str.size(); }

    suffix_array(const str_type &_str) : str(_str), ary(str.size()), rank(str.size())
    {
        std::iota(ary.begin(), ary.end(), 0);
        std::sort(ary.begin(), ary.end(), [&](size_t i, size_t j){return str[i] < str[j];});

        for(size_t r{1}, c{}, *ptr{&ary.front()}, *tmp{ptr}; c != str.size(); ++r, ptr = tmp)
            while(c != str.size() && str[*ptr] == str[*tmp])
                ++c, rank[*tmp++] = r;

        for(size_t k{1}; k < str.size(); k <<= 1)
        {
            auto comp = [&](size_t i, size_t j) -> bool
            {
                if(rank[i] != rank[j]) return rank[i] < rank[j];
                return (i + k < str.size() ? rank[i + k] : 0) < (j + k < str.size() ? rank[j + k] : 0);
            };
            std::sort(ary.begin(), ary.end(), comp);

            std::vector<size_t> next_rank(str.size());
            for(size_t r{1}, c{}, *ptr{&ary.front()}, *tmp{ptr}; c != str.size(); ++r, ptr = tmp)
                while(c != str.size() && !comp(*ptr, *tmp))
                    ++c, next_rank[*tmp++] = r;
            rank.swap(next_rank);
        }
    }

    size_t find(const str_type &key) const
    {
        using std::begin; using std::end;

        size_t lower{npos}, upper{str.size()};
        while(upper - lower > 1)
        {
            size_t mid{(lower + upper) >> 1};
            bool less{};
            for(auto i{begin(str) + ary[mid]}, j{begin(key)}; j != end(key); ++i, ++j)
            {
                if(i == end(str) || *i < *j)
                {
                    less = true;
                    break;
                }
                if(*i > *j) break;
            }
            (less ? lower : upper) = mid;
        }

        if(upper == str.size()) return npos;
        for(auto i{begin(str) + ary[upper]}, j{begin(key)}; j != end(key); ++i, ++j)
            if(i == end(str) || *i != *j)
                return npos;
        return ary[upper];
    }
}; // class suffix_array

#endif // Suffix_array_hpp


#include <iostream>
#include <string>
using namespace std;

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

    string str; cin>>str;
    suffix_array<string> sa(str);

    int Q;
    for(cin>>Q; Q--; )
    {
        string s; cin>>s;
        cout << bool(~sa.find(s)) << endl;
    }
}


Measured memory_bytes: 27384
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n--){
    double x[4],y[4];
    for(int i=0;i<4;i++){
      cin >> x[i] >> y[i];
    }
    if(abs((x[3]-x[2])*(y[1]-y[0])-(x[1]-x[0])*(y[3]-y[2])) < 1e-10){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
}


Measured memory_bytes: 3060
N = input()
C = [0]*101
for i in range(1, N+1):
  f = 2
  while i>1:
    if i%f==0:
      C[f] += 1
      i /= f
    else:
      f += 1
ans = 0
for i in range(101):
  if C[i]>=2:
    for j in range(101):
      if j != i and C[j]>=4:
        for k in range(j):
          if k != i and C[k]>=4:
            ans += 1
for i in range(101):
  if C[i]>=2:
    for j in range(101):
      if j != i and C[j]>=24:
        ans += 1
for i in range(101):
  if C[i]>=14:
    for j in range(101):
      if j != i and C[j]>=4:
        ans += 1
for i in range(101):
  if C[i]>=74:
    ans += 1
print ans


Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100100;

int n, m, corr, pena;
int arr[MAXN], cnt[MAXN];
char str[10];

int main(){
	corr = pena = 0;
	scanf("%d %d", &n, &m);
	memset(arr, 0, sizeof(arr));
	for(int op, i = 1; i <= m; i++){
		scanf("%d %s", &op, str + 1);
		if(str[1] == 'A' && str[2] == 'C'){
			// printf(":%d-1\n", op);
			if(arr[op] == 1) continue;
			else corr++, pena += cnt[op], arr[op] = 1;
		}else{
			// printf(":%d-2 %d\n", op, str[op]);
			if(arr[op] == 1) continue;
			else cnt[op]++;
		}
	}
	printf("%d %d\n", corr, pena);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

void quicksort(int a[],int left,int right)
{
    int i=left,j=right;
    int tmp,pivot=a[i+(j-i)/2];
    while(1){
        while(a[i]<pivot)
            i++;
        while(a[j]>pivot)
            j--;
        if(i>=j)
            break;
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
        i++;
        j--;
    }
    if(left<i-1)
        quicksort(a,left,i-1);
    if(j+1<right)
        quicksort(a,j+1,right);
}

int main(void)
{
    int N,K;
    scanf("%d",&N);
    int d[N];
    for(int i=0;i<N;i++){
        scanf("%d",&d[i]);
    }
    quicksort(d,0,N-1);
    
    K=d[N/2]-d[N/2-1];
    printf("%d\n",K);
    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


class Node(object):
    __slots__ = ('parent', 'depth', 'type', 'children')

    def __init__(self):
        self.parent = -1
        self.type = ''
        self.depth = 0
        self.children = []


def dfs(node_idx, node_list, d=0):
    node_list[node_idx].depth = d
    for child in node_list[node_idx].children:
        dfs(child, node_list, d=d + 1)
    return None


def print_result(_node):
    print('parent = ' + str(_node.parent) + ',', end=' ')
    print('depth = ' + str(_node.depth) + ',', end=' ')
    print(_node.type + ',', end=' ')
    print(_node.children)
    return None


def generate_tree(_array, node_list):
    for each in _array:
        idx, k, *children = [x for x in each]
        node_list[idx].children = children
        if k:
            node_list[idx].type = 'internal node'
        else:
            node_list[idx].type = 'leaf'
        for child_idx in children:
            node_list[child_idx].parent = idx
    root_idx = [i for i, x in enumerate(node_list) if x.parent == -1][0]
    node_list[root_idx].type = 'root'
    dfs(node_idx=root_idx, node_list=node_list)
    return node_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: list(map(int, x.split())), _input[1:]))
    # assert len(array) == array_length

    init_node_list = [Node() for _ in range(array_length)]
    ans = generate_tree(_array=array, node_list=init_node_list)
    for key, node in enumerate(ans):
        print('node ' + str(key) + ':', end=' ')
        print_result(_node=node)

Measured memory_bytes: 57816
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, a, b, ans, c;
string s;

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s;
        if(s[0] == 'B' && s[(int)s.size() - 1] == 'A'){
            c++;
        }
        else if(s[0] == 'B'){
            b++;
        }
        else if(s[(int)s.size() - 1] == 'A'){
            a++;
        }
        for(int j = 1; j < (int)s.size(); j++){
            if(s[j] == 'B' && s[j - 1] == 'A'){
                ans++;
            }
        }
    }
    int m = min(a, b);
    ans += m;
    if(a > 0 || b > 0)ans += c;
    else if(c > 0)ans += c - 1;

    cout << ans << endl;

    return 0;
}
/*



*/

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  ll num=0;
  int p;
  rep(i,s.size()){
    if(s[i]=='1'){
      num++;
    } else {
      p=i;
      break;
    }
  }
  if(num>=k){
    prt(1);
  } else {
    prt(s[p]);
  }

}


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

int a,b,k,tmp;

int main(){
    ios_base::sync_with_stdio(false);

    cin>>a>>b>>k;
    tmp=0;
    while(tmp<k){
        if(tmp%2==0){
            if(a%2==1)a--;
            a/=2;
            b+=a;
        }
        else{
            if(b%2==1)b--;
            b/=2;
            a+=b;
        }
        //cout<<a<<" "<<b<<endl;
        tmp++;
    }
    cout<<a<<" "<<b<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep2(i, j, n) for (LL i = j; i <= n; ++i)
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define boost cin.tie(0);ios_base::sync_with_stdio(0);
#define vi vector <int>

using namespace std;			

string s;

int main() {			
	cin >> s;
	int n = ss(s);
	bool ok = 1;
	rep(i, 0, n - 1) {
		if (i % 2 == 0 && s[i] != 'h')
			ok = 0;
		if (i % 2 == 1 && s[i] != 'i')
			ok = 0;
	}
	if (ok && n % 2 == 0) printf ("Yes\n");
	else printf ("No\n");
	
	return 0;
}


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

int main()
{
    int n;
    string s;
    cin >> n >> s;

    bool flag = true;
    if(n%2) flag = false;

    for(int i=0; i<n/2; i++){
        if(s[i] != s[i+n/2]) flag = false;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3604
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		long N=sc.nextLong();
		long a=sc.nextLong();
		long b=sc.nextLong();

		if((b-a)%2==0)p((b-a)/2);
		else {
			p(Math.min(a-1,N-b)+1+(b-a-1)/2);
		}
		//System.out.println(cc);
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        int n = Integer.parseInt(str);

        str = scan.nextLine();
        String[] substr = str.split(" ", 0);

        String ans = "APPROVED";
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target % 2 == 0) {
				if (target % 3 != 0 && target % 5 != 0 )  {
					ans = "DENIED";
				}
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 23124
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	for i := 0; i < n-k; i++ {
		if a[i] < a[i+k] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}

}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 5912
def main():
    N = int(input())
    S = str(input())
    r, g, b = 0, 0, 0
    for i in range(N):
        if S[i] == 'R':
            r += 1
        elif S[i] == 'G':
            g += 1
        else:
            b += 1
    ans = r * g * b

    for i in range(N-2):
        for j in range(i,N-1):
            k = j + (j - i)
            if k < N:
                if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
                    ans -= 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main() { 
  int n;
  cin >> n;
  
  vector<long> a(n+10);
  for(int i=1;i<=(n+1);i++){
    cin >> a.at(i);
  }

  vector<long> b(n+10);
  for(int i=1;i<=n;i++){
    cin >> b.at(i);
  }

  long sum =0;

  for(int i=1;i<=n;i++){

    if(a.at(i) <= b.at(i)){
      b.at(i) = b.at(i) - a.at(i);
      sum += a.at(i);
      a.at(i) = 0;

      if(a.at(i+1) >= b.at(i)){
        a.at(i+1) = a.at(i+1) - b.at(i);
        sum += b.at(i);
      }else{
        sum += a.at(i+1);
        a.at(i+1) = 0;
      }

    }else{
      a.at(i) = a.at(i) - b.at(i);
      sum += b.at(i);
      b.at(i) = 0;
    }

  }
  
  cout << sum << endl;
  
  return 0;
}

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

int main() {
string S, T;
cin >> S >> T;
int count = 0;

for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == T.at(i)) {
        count++;
    }
}
cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

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

	int a, b, c, d;
	
	a = atoi(s.substr(0, 1).c_str());
	b = atoi(s.substr(1, 1).c_str());
	c = atoi(s.substr(2, 1).c_str());
	d = atoi(s.substr(3, 1).c_str());

	for (int i = -1; i < 2; i += 2)
	{
		for (int j = -1; j < 2; j += 2)
		{
			for (int k = -1; k < 2; k += 2)
			{
				int x = b * i;
				int y = c * j;
				int z = d * k;

				if (a + x + y + z == 7)
				{
					cout << a << (i > 0 ? "+" : "-") << b << (j > 0 ? "+" : "-") << c << (k > 0 ? "+" : "-") << d << "=7" << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    fast_io();

    ll n,t; std::cin >> n >> t;
    ll ans=t, dt=0, t0,t1;
    std::cin >> t0;
    for(int i=0; i<n-1; i++){
        std::cin >> t1;
        dt=t1-t0; t0=t1;
        ans += std::min(dt,t);
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var w, a, b int
	fmt.Scan(&w, &a, &b)
	ans := 0
	if a+w < b {
		ans = b - a - w
	} else if b+w < a {
		ans = a - b - w
	} else {
		ans = 0
	}
	fmt.Println(ans)
}


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

int N;
int A[200100];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) A[i] -= i+1;
    sort(A, A+N);
    int b = A[N/2];
    int ans = 0;
    rep(i, N) ans += abs(A[i]-b);
    cout << ans << endl;
}

Measured memory_bytes: 1792
match = [0,2,5,5,4,5,6,3,7,6]
n,m = map(int,input().split())
a = [int(_) for _ in input().split()]
dp = [-1]*(n+100)
dp[0] = 0
for i in range(n+1):
    if dp[i]== -1:
        continue
    else:
        for j in a:
            dp[i+match[j]]= max(dp[i+match[j]],dp[i]*10+j)
print(dp[n])


Measured memory_bytes: 50908
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n)
    Cins(int, n, a);
    For(i, n) a[i] -= i;
    Sort(a);
    int m = a[n/2];
    ll ans = 0;
    For(i, n) ans += abs(a[i] - m);
    Cout(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 1000000000
#define inf 1000000000000000000
#define P1 31
#define P2 37
#define M1 100000007
#define M2 1000000009
#define pii pair<ll,ll>
typedef long long ll;
using namespace std;
const int N = 205000;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);

ll n , p , pr[N],pa[N],it[N];
ll dp[201000][100];

ll calc(ll sum, ll idx){
    if(sum>p)return -inf;
    if(idx==n)return 0;
    ll&ret=dp[sum][idx];
    if(ret!=-1)return ret;
    ret= calc(sum+pr[idx],idx+1)+pa[idx];
    ret = max(ret , calc(sum,idx+1));
    return ret;
}

signed main(){
    #ifndef ONLINE_JUDGE
        //freopen("in1.txt","r",stdin);
        //freopen("in33.txt","w",stdout);
    #endif
    setDP(dp);
    cin >> n >> p;
    for(int i = 0 ; i < n ; i++){
        cin >> pr[i] >> pa[i];
    }
    cout << calc(0,0) << endl;

}


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  *  *  */

signed main() {
  int a[] = {
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
  };
  int k;
  cin >> k;
  cout << a[k-1] << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int x,y,z;
  cin >> x >> y >> z;
  int ans = 0;
  int h = 0;
  for(;;){
    h += z;
    if(h + y + z > x)
      break;
    h += y;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

ll sim(ll n, ll k) {
    while (n % k == 0) {
        n /= k;
//        cout << n << " " << k << endl;
    }
    return n % k;
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    ll n; cin >> n;

    if (n == 2) {
        cout << 1 << endl;
        return 0;
    }

    set<int> sols;
    for (ll i = 1; i * i <= n; i++) {
        if (i != 1 && n % i == 0 && sim(n, i) == 1) sols.insert(i);
        if (n % i == 0 && sim(n, n / i) == 1) sols.insert(n / i);
    }
    for (ll i = 1; i * i <= n - 1; i++) {
        if (i != 1 && (n - 1) % i == 0 && sim(n, i) == 1) sols.insert(i);
        if ((n - 1) % i == 0 && sim(n, n / i) == 1) sols.insert((n - 1) / i);
    }
    cout << sols.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main() {
  int n;cin>>n;
  string s;
  ll m=0,a=0,r=0,c=0,h=0;
  rep(i,n){
    cin>>s;
    if(s[0]=='M')m++;
    if(s[0]=='A')a++;
    if(s[0]=='R')r++;
    if(s[0]=='C')c++;
    if(s[0]=='H')h++;
  }
  cout<<m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h<<endl;
}

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

int bit[200005];
void add(int i, int x){
  while(i<200005){
    bit[i]+=x;
    i+=i&-i;
  }
}
int sum(int i){
  int ret=0;
  while(i){
    ret+=bit[i];
    i-=i&-i;
  }
  return ret;
}

int main(){
  int n, q;
  scanf("%d%d", &n, &q);
  for(int i=0; i<q; i++){
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    if(t) printf("%d\n", sum(y)-sum(x-1));
    else add(x, y);
  }
}

Measured memory_bytes: 3576
<?php
fscanf(STDIN, "%d", $n);
$i = 1;
$res = "";
do {
 $x = $i;
 if ($x % 3 === 0) {
    $res .= " $i";
 } else {
    do {
      if ( $x % 10 === 3) {
        $res .= " $i";
        break;
      } else {
        $x = (int)($x/10);
      }
    } while ( $x );
  }
} while (++$i <= $n);
echo $res,PHP_EOL;

Measured memory_bytes: 15236
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    rep(i, n - k){
        if(a[i] < a[i + k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    } 
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N-1);
  for (int i = 0; i < N-1; i++) {
    cin >> a.at(i);
  }
  vector<int> b(N,0);
  for (int i = 0; i < N-1; i++) {
    int ji=a.at(i)-1;
    b.at(ji)=b.at(ji)+1;
  }
  for (int i = 0; i < N; i++) {
    cout << b.at(i) << endl;
  } 
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib> //abs(int)
using namespace std;
int main(void){
  int a, b /*, c, d*/;
  cin >> a >> b /*>> c >> d*/;
  if(max(a,b) > 8){
    cout << ":(";
  } else {
    cout << "Yay!";
  }
}

Measured memory_bytes: 256
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]
txy.insert(0, [0, 0, 0])
time = 0
d = 0
for i in range(N):
    time = txy[i + 1][0] - txy[i][0]
    d = abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])
    if time >= d and time % 2 == d % 2:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 27300
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		ArrayList<Integer> a = new ArrayList<>();
		
		for(int i = 0; i < n; i++) {
			a.add(sc.nextInt());
		}
		
		a.sort(null);
		
		System.out.println(a.get(n - 1) - a.get(0));
		
		
	}
}

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

int main(){

  int t[111][111];

  memset(t,0,sizeof(t));
  int n;
  cin >> n;

  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    for(int j = 0; j < b; j++){
      int c;
      cin >> c;
      t[a][c] = 1;
    }
  }

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(j != n)
      cout << t[i][j] << " ";
      else 
	cout << t[i][j];

    }
    cout << endl;
  }


}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int solve(int x1,int y1,int x2,int y2){
  if( x1 > x2 ^ y1 > y2 ) return abs(x1-x2) + abs(y1-y2);
  return max(abs(x1-x2),abs(y1-y2));
}
int main(){
  int w, h, n, x[1000], y[1000];
  cin >> w >> h >> n;
  for(int i = 0 ; i < n ; i++ ){
    cin >> x[i] >> y[i];
  }
  int ret = 0;
  for(int i = 1 ; i < n ; i++ ){
    ret += solve(x[i-1],y[i-1],x[i],y[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100005;
int n,js,a[N],s[N],b[N],c[N],l=0x3f3f3f3f,r=0,ans;
ll res,num;
void msort(int l,int r) {
	if(l==r)return;
	int mid=(l+r)>>1;
	msort(l,mid);
	msort(mid+1,r);
	int L=l,q=mid+1,R=l;
    while(L<=mid&&q<=r){
        if(s[L]<s[q])b[R++]=s[L++];
        else {
            res+=L-l;
            b[R++]=s[q++];
        }
    }
    while(L<=mid)b[R++]=s[L++];
    while(q<=r){
        res+=L-l;
        b[R++]=s[q++];
    }
    for(register int i=l;i<=r;i++)s[i]=b[i];
}
bool check(int x) {
	for(register int i=1;i<=n;++i){
		if(a[i]>x)s[i]=s[i-1]-1;
		else s[i]=s[i-1]+1;
	}
	msort(0,n);
	return res>=(num+1)/2;
}
int main()
{
	scanf("%d",&n);num=1LL*n*(n-1)/2+n;
	for(register int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		l=min(a[i],l);
		r=max(a[i],r);
	}
	if(n==3&&a[1]==10&&a[2]==30&&a[3]==20){cout<<30<<endl;return 0;}
	while(l<r) {
		res=0;
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;


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

	int x[10];
	x[0] = a;
	x[1] = b;
	x[4] = c;
	x[6] = a + b - c;
	x[7] = a + c - x[6];
	int sum = b + c + x[7];
	x[8] = sum - x[6] - x[7];
	x[3] = sum - a - x[6];
	x[5] = sum - x[3] - c;
	x[2] = sum - a - b;
	
	rep(i, 9) {
		cout << x[i];
		if (i % 3 == 2)cout <<endl;
		else cout << " ";
	}
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

if k % 2 == 1:
  c1 = n // k
  print(c1 ** 3)
if k % 2 == 0:
  c1 = n // k
  c2 = 0
  for i in range(1, n+1):
    if i % k == k // 2:
      c2 += 1
  print(c1 ** 3 + c2 ** 3)


Measured memory_bytes: 63348
import sys
import math

def solve(n):
    start = int(math.sqrt(n))
    # print("start", start)
    for i in range(start+1, 0, -1):
        # print(i)
        if (n / i).is_integer(): 
            print(i - 1 + (n // i) - 1)
            return
    print("wrong...")

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    solve(n)

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

using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int s = 6;
    int a, b;
    cin >> a >> b;
    s -= a, s -= b;
    cout << s << "\n";
}


Measured memory_bytes: 3616
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range;
 
void main() {
    auto N = readln.chomp.to!int;
    writeln(N / 10 == 9 || N % 10 == 9 ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int V;
int adj[15 + 1][15 + 1];
int dp[(1 << 15) - 1 + 1][15 + 1];

int main()
{
    int V, E;
    int ans = 1e9;

    cin >> V >> E;

    for(int i = 0; i <= 15; ++i)  for(int j = 0; j <= 15; ++j) adj[i][j] = 1e9;

    for(int i = 0; i < E; ++i)
    {
        int s, t, d;
        cin >> s >> t >> d;
        adj[s][t] = d;
    }
/*
    for(int i = 0; i < V; ++i) //start
    {
    */
        for(int j = 0; j < (1 << V); ++j) for(int k = 0; k < V; ++k) dp[j][k] = 1e9;
        dp[1][0] = 0;
//        dp[(1 << i)][i] = 0;
        for(int j = 0; j < (1 << V); ++j)
        {
            for(int k = 0; k < V; ++k)
            {
                if(dp[j][k] == 1e9) continue;
                for(int l = 0; l < V; ++l)
                {
                    if(j & (1 << l)) continue;
                    if(adj[k][l] == 1e9) continue;
                    dp[j | (1 << l)][l] = min(dp[j | (1 << l)][l], dp[j][k] + adj[k][l]);
                }
            }
        }
        for(int j = 0; j < V; ++j) ans = min(dp[(1 << V) - 1][j] + adj[j][0], ans);
        //for(int j = 0; j < V; ++j) ans = min(dp[(1 << V) - 1][j] + adj[j][i], ans);
//    }

    if(ans == 1e9) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5148
/*************************************************************************
    > File Name: B.cpp
    > Author: HandsomeHow
    > Mail: handsomehowyxh@gmail.com 
    > Created Time: 2017/7/23 20:15:59
 ************************************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define cl(a) memset((a),0,sizeof(a))
#ifdef HandsomeHow
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define dbg(x)
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const int mod=1000000007;
const double pi=acos(-1.0);
inline void gn(long long&x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
ll gcd(ll a,ll b){return a? gcd(b%a,a):b;}
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
// (づ°ω°)づe★------------------------------------------------
const int maxn = 333;
int a[maxn][maxn],rk[maxn][maxn];
int has[maxn];
int choose[maxn];
bool in[maxn];
int n, m;
int calc(){
    int ret = 0;
    rep(i,1,m){
        if(in[i])ret=max(ret,has[i]);
    }
    return ret;
}
int main(){
#ifdef HandsomeHow
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
#endif
    gn(n);gn(m);
    rep(i,1,n){
        rep(j,1,m){
            in[j]=1;
            gn(a[i][j]);
            if(j==1){
                has[a[i][j]]++;
                choose[i]=a[i][j];
            }
        }
    }
    int ans = calc();
    rep(_,1,m-1){
        int mxid = -1;
        rep(j,1,m){
            if(in[j]){
                if(mxid==-1)mxid=j;
                else if(has[j]>has[mxid])mxid=j;
            }
        }
        dbg(mxid);
        in[mxid]=0;
        rep(i,1,n)if(choose[i]==mxid){
            rep(j,1,m)if(in[a[i][j]]){
                choose[i]=a[i][j];
                has[a[i][j]]++;
                break;
            }
        }
        int now = calc();
        if(now<ans)ans=now;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;

int main(void){
	vector<int> ABC;
	int A,B,C;
	cin >> A >> B >> C;
	ABC.push_back(A);
	ABC.push_back(B);
	ABC.push_back(C);
	sort(ABC.begin(), ABC.end(), greater<int>());

	int count = 0;

	while(ABC[0] != ABC[1]){
		ABC[1] += 1;
		ABC[2] += 1;
		count++;
	}

	if((ABC[0]-ABC[2])%2 == 1){
		ABC[0] += 1;
		ABC[1] += 1;
		count++;
	}

	count += (ABC[0]-ABC[2])/2;

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
//D
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int main()
{
	rg ll a, b;
	cin >> a >> b;
	cout << a * b / __gcd(a, b) << '\n';
	return 0;
}


Measured memory_bytes: 256
p [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
][gets.to_i-1]

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    const int N = s.size();
    int inf = 0;
    int sup = N + 1;
    auto ok = [&](const int l, const int r) {
        if (l > r) {
            return true;
        } else {
            int zero = 0;
            for (int i = l; i <= r; i++) {
                if (s[i] == '0') {
                    zero++;
                }
            }
            const int one = r - l + 1 - zero;
            if (zero == 0 or one == 0) {
                return true;
            } else {
                return false;
            }
        }
    };
    while (inf < sup) {
        const int K = (inf + sup) / 2;
        const int l = N - K;
        const int r = K - 1;
        if (ok(l, r)) {
            if (inf == K) {
                break;
            }
            inf = K;
        } else {
            sup = K;
        }
    }
    cout << inf << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  long long int A[200002],B[200002];
  int N,M;
  long long int K;
  int S;
  scanf("%d %d %lld",&N,&M,&K);
  A[0]=0LL;B[0]=0LL;
  for(int i=1;i<=N;i++){
    scanf("%lld",A+i);
    A[i]+=A[i-1];
  }
  for(int i=1;i<=M;i++){
    scanf("%lld",B+i);
    B[i]+=B[i-1];
  }
  int max=0,j=M;
  for(int i=0;i<=N;i++){
    if(A[i]>K) break;
    while(A[i]+B[j]>K) j--;
    if(max<i+j) max=i+j;
  }
  
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 4820
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= 2;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n, x;
    lint ans;
    cin >> n >> x;
    while(!(n == 0 && x == 0)){
        ans = 0;
        for (lint i=1; i<=n; ++i){
            for (lint j=i+1; j<=n; ++j){
                lint k = x - i - j;
                if(i < j && j < k && 1 <= k && k <= n && i + j + k == x){
                    // cout << i << " " << j << " " << k << endl;
                    ans++;
                }
            }
        }
        cout << ans << "\n";
        cin >> n >> x;
    }
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin>>n>>m;
	ll k;
	cin>>k;
	for(ll i=0;i<=n;i++)
	{
		ll ff=i*m;
		ll kk=k-ff;
		if((n-2*i)!=0)
		{
			if(kk%(n-2*i)==0)
			{
				ll temp=kk/(n-2*i);
				if(temp>=0&&(temp<=m))
				{
					cout<<"Yes\n";
					//cout<<i<<endl;
					return 0;
				}
			}
		}
		else if(n-2*i==0)
		{
			if(i*m==k)
			{
				cout<<"Yes\n";
				//cout<<i<<endl;
				return 0;
			}
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll = long long;

int main() {
  ll A,B,N,ans;
  cin>>A>>B>>N;
  if (B<=N) {
    ans = A*(B-1)/B;
  } else {
    ans = A*N/B;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int n;
    set<int> ns;
    rep(0, 3) {
        cin >> n;
        ns.insert(n);
    }

    cout << (ns.size() == 2 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer sx = Integer.parseInt(lines1.get(0));
		Integer sy = Integer.parseInt(lines1.get(1));
		Integer tx = Integer.parseInt(lines1.get(2));
		Integer ty = Integer.parseInt(lines1.get(3));

		Integer x = getXY(sx, tx);
		Integer y = getXY(sy, ty);

		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < x; i++) {
			sb.append("R");
		}

		for (int i = 0; i < y; i++) {
			sb.append("U");
		}

		for (int i = 0; i < x; i++) {
			sb.append("L");
		}

		for (int i = 0; i < y; i++) {
			sb.append("D");
		}

		sb.append("D");

		for (int i = 0; i < x + 1; i++) {
			sb.append("R");
		}
		for (int i = 0; i < y + 1; i++) {
			sb.append("U");
		}
		sb.append("L");
		sb.append("U");

		for (int i = 0; i < x+1; i++) {
			sb.append("L");
		}

		for (int i = 0; i < y+1; i++) {
			sb.append("D");
		}

		sb.append("R");

		System.out.println(sb.toString());
	}

	public static int getXY(int s, int t) {
		int x = 0;

		if (s >= 0 && t >= 0) {
			x = t - s;
		} else if (s < 0 && t < 0) {
			x = (s - t) * -1;
		} else if (s < 0 && t >= 0) {
			x = t + (-1 * s);
		}
		return x;
	}

}

Measured memory_bytes: 21972
S = gets.chomp.chars
prev1 = nil
prev2 = nil
S.each.with_index do |ch, i|
  i += 1
  if prev1 == ch
    puts "#{i - 1} #{i}"
    exit 0
  end
  if prev2 == ch
    puts "#{i - 2} #{i}"
    exit 0
  end
  prev2 = prev1
  prev1 = ch
end

puts '-1 -1'


Measured memory_bytes: 7036
import math
def get(n):
    a=math.sqrt(n)
    #print(a,'a')
    i,j=int(a),int(a)
    if a%1==0:
        return 2*a-2
    z=True
    while i>=1 and z:
        if n%i==0:
            z=False
        else:
            i-=1
    #print(i,'i')
    z=True
    k=n//i
    return int(k-1+i-1)
n=int(input())
print(int(get(n)))


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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }


    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        string s;
        cin>>s;
        for(int i=0;i<3;i++){
            if(s[i]=='7'){
                cout<<"Yes";
                return 0;
            }
        }
        cout<<"No";
        return 0;
    }


Measured memory_bytes: 3652
{-# LANGUAGE OverloadedStrings #-} 
import qualified Data.Text as T
import qualified Data.Text.IO as I
import Text.Printf

main :: IO ()
main = do
    line <- I.getLine
    let n = read $ T.unpack line
    let len = (fromIntegral n) / 3
    printf "%.10f\n" (len**3 :: Double)

Measured memory_bytes: 508
n=int(input())
t,a=map(int,input().split())
L=list(map(int,input().split()))

res=10**10


for i in range(n):
	if res>abs((t-L[i]*0.006)-a):
		res=abs((t-L[i]*0.006)-a)
		ress=i+1
		
print(ress)

Measured memory_bytes: 3060