akhauriyash/Code-Regression huggingface dataset:
//list index out of range エラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  int N,M;
  int A;
  cin >> N >> M;
  rep1(i, M){
    cin >> A;
    N -= A;
    if(N<0){
      N = -1;
      break;
    }

  }


  cout << N;
}


Measured memory_bytes: 3604
n,m=map(int,input().split())
P=[]
Q=[]
c=0

for i in range(n):
    P.append(input().split())
    
for j in range(m):
    b=int(input())
    Q.append(b)
    
for k in range(n):
    for l in range(m):
        a=P[k]
        c+=int(a[l])*Q[l]
    print(c)
    c=0


Measured memory_bytes: 6248
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static final int INF = 2000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		TreeMap<Integer, LinkedList<Point>> map = new TreeMap<Integer, LinkedList<Point>>();
		while(true){
			int w = Integer.parseInt(sc.next());
			int h = Integer.parseInt(sc.next());
			if(w == 0 && h == 0){
				break;
			}
			
			Point start = null, goal = null;
			int max = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					String s = sc.next();
					if(s.equals("S")){
						start = new Point(0, i, j);
						LinkedList<Point> temp = new LinkedList<Point>();
						temp.add(start);
						map.put(0, temp);
					}else if(s.equals("G")){
						goal = new Point(INF, i, j);
					}else if(s.matches("[0-9]+")){
						int num = Integer.parseInt(s);
						max = max < num ? num : max;
						if(map.containsKey(num)){
							map.get(num).add(new Point(INF, i, j));
						}else{
							LinkedList<Point> temp = new LinkedList<Point>();
							temp.add(new Point(INF, i, j));
							map.put(num, temp);
						}
					}
				}
			}
			LinkedList<Point> temp = new LinkedList<Point>();
			temp.add(goal);
			map.put(max + 1, temp);
			System.out.println(fm(map));
			map.clear();
		}
		sc.close();
	}
	static int fm(TreeMap<Integer, LinkedList<Point>> map){
		int m = 1;
		LinkedList<Point> from = map.get(0);
		LinkedList<Point> to = null;
		while(true){
			if(!map.containsKey(m)){
				break;
			}
			to = map.get(m);
//			System.out.print(m+":");
			for(Point p : to){
				for(Point s : from){
					int temp = Math.abs(p.x - s.x) + Math.abs(p.y - s.y);
					p.c = p.c > temp + s.c ? temp + s.c : p.c;
				}
//				System.out.print("[" + p.c + "]");
			}
//			System.out.println();
			from = to;
			m++;
		}		
		return map.get(m - 1).get(0).c;
	}
}
class Point{
	int c;
	int x;
	int y;
	Point(int c, int y, int x){
		this.c = c;
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 71992
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a + b, min(a + c , b + c)) << endl;
	return 0;
}


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

string O,E,P;

int main(){
 
cin>>O>>E;

P=O+E;

for(int i=0; i<O.size(); i++){
	P[2*i]=O[i];
}
for(int i=0; i<E.size(); i++){
	P[2*i+1]=E[i];
}

cout<<P<<endl;

return 0;
 
}

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

int main(){
  while(1){
    int N;
    cin >> N ;
    if(N==0){
      break;
    }
    int str[11][6]={0};
    for(int i=N-1;i>=0;i--){
      for(int j=0;j<5;j++){
        cin >> str[i][j];
      }
    }
    int score=0;
    for(int i=0;i<10;i++){
//    for(int q=0;q<N;q++){
//     for(int w=0;w<5;w++){
//       cout << str[q][w];
//     }
//     cout << endl;
//    }
//    cout << endl;
      for(int j=0;j<N;j++){
        int a=str[j][0];
        int ch=0;
        for(int k=0;k<=5;k++){
          if(a==str[j][k]&&a!=0){
            ch++;
          }else{
            if(ch>=3){
              for(int l=k-1;l>=k-ch;l--){
                score+=str[j][l];
                str[j][l]=0;
              }
              break;
            }else{
              a=str[j][k];
              ch=1;
            }
          }
        }
      }
      for(int j=0;j<N;j++){
        for(int k=0;k<N;k++){
          for(int l=0;l<5;l++){
            if(str[k][l]==0){
              str[k][l]=str[k+1][l];
              str[k+1][l]=0;
            }
          }
        }
      }
    }
//    for(int q=0;q<N;q++){
//     for(int w=0;w<5;w++){
//       cout << str[q][w];
//     }
//     cout << endl;
//    }
    cout << score << endl;
  }
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

struct Range { int left; int right; };

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

    int H, W; cin >> H >> W;
    vector<Range> walls(H);
    REP(y, H) {
        int A, B; cin >> A >> B; --A; --B;
        walls[y] = { A, B };
    }

    set<pair<int, int>> end_and_starts;
    multiset<int> x_dists;

    REP(x, W) {
        end_and_starts.insert({x, x});
        x_dists.insert(0);
    }

    REP(y, H) {
        auto wall = walls[y];
        auto lo = end_and_starts.lower_bound({ wall.left, 0 });
        auto hi = end_and_starts.lower_bound({ wall.right+1, 0 });
        if (lo != hi) {
            int max_start = -1;
            for (auto it = lo; it != hi; ) {
                max_start = max(max_start, it->second);
                int x_dist = it->first - it->second;
                it = end_and_starts.erase(it);
                x_dists.erase(x_dists.find(x_dist));
            }
            if (wall.right != W-1) {
                int new_end = wall.right + 1;
                end_and_starts.insert({ new_end, max_start });
                x_dists.insert(new_end - max_start);
            }
        }
        if (x_dists.empty()) {
            cout << "-1\n";
        } else {
            int min_x_dist = *x_dists.begin();
            cout << min_x_dist + y + 1 << '\n';
        }
    }
}


Measured memory_bytes: 23096
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, m;
	int i, j;
	int a, b;
	int count;
	int list[501][501];
	int friend[501];

	while (1){
		scanf("%d", &n);
		scanf("%d", &m);

		if (n == 0 && m == 0){
			break;
		}

		memset(list, 0, sizeof(list));
		memset(friend, 0, sizeof(friend));
		count = 0;

		for (i = 0; i < m; i++){
			scanf("%d %d", &a, &b);
			list[a][b] = 1;
			list[b][a] = 1;
		}

		for (i = 2; i <= n; i++){
			if (list[1][i] == 1){
				friend[i] = 1;

				for (j = 2; j <= n; j++){
					if (list[i][j] == 1){
						friend[j] = 1;
					}
				}
			}
		}

		for (i = 2; i <= n; i++){
			if (friend[i] == 1){
				count++;
			}
		}

		printf("%d\n", count);
	}

	return (0);
}

Measured memory_bytes: 1592
#include <cstdio>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

struct K {
  ll a, b;
};

K vs[100000+10];
pair<ll,int> ps[200000+10];

int main(void) {
  int n;
  ll h;
  scanf("%d%lld", &n, &h);
  REP(i, n) {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    ps[2*i] = make_pair(a, 0);
    ps[2*i+1] = make_pair(b, 1);
  }
  sort(ps, ps + 2*n);
  ll rest = h;
  ll res = 0;
  for(int i = n*2-1; i >= 0; --i) {
    if(rest <= 0) {
      break;
    }
    if(ps[i].second == 1) {
      ++res;
      rest -= ps[i].first;
    } else {
      res += (rest + ps[i].first - 1) / ps[i].first;
      rest = 0;
    }
    // cerr << res << " " << rest << endl;
  }
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        Map<String, List<Integer>> Name_PointsMap = new HashMap<>();
        Map<Integer, Integer> Point_NoMap = new HashMap<>();
        List<String> cityList = new ArrayList<>();

        for (int i = 1; i <= N; i++) {
            String name = sc.next();
            int point = sc.nextInt();
            Point_NoMap.put(point, i);
            List<Integer> pointList = Name_PointsMap.get(name);
            if (Objects.isNull(pointList)) {
                pointList = new ArrayList<>();
            }
            pointList.add(point);
            Name_PointsMap.put(name, pointList);
            if (!cityList.contains(name)) {
                cityList.add(name);
            }
        }
        Collections.sort(cityList);
        for (String city : cityList) {
            List<Integer> points = Name_PointsMap.get(city);
            Collections.sort(points, Collections.reverseOrder());
            for (int pointss : points) {
                System.out.println(Point_NoMap.get(pointss));
            }
        }

    }
}


Measured memory_bytes: 21844
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
using namespace std;

#define int long long
#define INF 1e18
#define EPS 1e-9
#define NIL -1
#define N 100

signed main() {
    int n, m; cin >> n >> m;
    vector<int> v[n], p(m), y(m);
    for(int i = 0; i < m; i++) {
        int tmp_p; cin >> tmp_p; tmp_p--;
        p[i] = tmp_p;
        cin >> y[i];
        v[p[i]].push_back(y[i]);
    }

    for(int i = 0; i < n; i++) {
        sort(v[i].begin(), v[i].end());
    }

    for(int i = 0; i < m; i++) {
        int ans = (p[i] + 1) * 1000000 + (int)(lower_bound(v[p[i]].begin(), v[p[i]].end(), y[i]) - v[p[i]].begin()) + 1;
        cout << setfill('0') << setw(12) << ans << endl;
    }
}


Measured memory_bytes: 8576
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int h,n,a;
  cin >> h;
  cin >> n;

  int sum = 0;
  rep(i,n)
  {
    cin >> a;
    sum += a;
  }

  cout << ((h <= sum) ? "Yes" : "No" );


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int s;
	int ans=0;
	cin>>s;
	for( ; ; )
	{
		if(s==1)
		{
		ans++;
		break;
		}
		if(s==0)
		break;
		if(s%10==1)
		{
			s/=10;
			ans++;
			continue;
		}
		else
		{
		s/=10;
		continue;
		}
	}
	cout<<ans;
	return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int x0, y0, x1, y1, x2, y2, x3, y3;
	cin >> x0 >> y0 >> x1 >> y1;
	x2 = x1 - (y1 - y0);
	y2 = y1 + (x1 - x0);
	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	cout << x2 << ' ' << y2 << ' ' <<   x3 << ' ' << y3 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        

        
        if(S.equals("ABC")){
        	System.out.println("ARC");
        }else{
        	System.out.println("ABC");
        }
        
	}
}

        
        

Measured memory_bytes: 35628
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll N;
ll X;
vll L;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> X;

    rep(ni,N){
        cin >> ltmp;
        L.push_back(ltmp);
    }
    ll D = 0;
    ll ans = 1;
    rep(ni,N){
        D+=L[ni];
        if(D>X) break;
        ans++;
    }
    cout << ans << endl;   

}

Measured memory_bytes: 3668
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, m = load_list()

A = load_list()

s = sum(A)

c = 0
for a in A:
    if a >= s * (1 / (4 * m)):
        c += 1

if c >= m:
    print('Yes')
else:
    print('No')

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

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

#define MOD 1000000007

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

ll digit(ll a) {
    ll sum = 0;
    while(a) sum += a % 10, a /= 10;
    return sum;
}

int main(void) {
    ll N;
    ll mini = LONG_LONG_MAX;
    cin >> N;
    rep2(i, 1, N) {
        ll j = N - i;
        mini = min(mini, digit(i) + digit(j));
    }
    cout << mini << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x),b(y),c(z);
  REP(i,x)cin >> a[i];
  REP(i,y)cin >> b[i];
  REP(i,z)cin >> c[i];
  vector<ll> ab;
  REP(i,x)REP(j,y)ab.push_back(a[i]+b[j]);
  sort(ALL(ab),greater<ll>());
  vector<ll> abc;
  REP(i,min(k,x*y))REP(j,z)abc.push_back(ab[i]+c[j]);
  sort(ALL(abc),greater<ll>());
  REP(i,k)cout << abc[i] << endl;


  

  return 0;
}


Measured memory_bytes: 43368
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
  int value;
  char symbol;
}DATA;

int partition(DATA *,int,int);
void quicksort(DATA *,int,int);
void merge(DATA *,int,int,int);
void mergeSort(DATA  *,int,int);

int n;
DATA leftDATA[100000/2+2],rightDATA[100000/2+2];

int main(){
  int i,tmp;
  DATA arr[100000],babble[100000];

  scanf("%d",&n);
  if(n>100000) exit(2);
  for(i=0;i<n;i++){
    scanf(" %c %d",&arr[i].symbol,&arr[i].value);
    babble[i].value=arr[i].value;
    babble[i].symbol=arr[i].symbol;
  }
  mergeSort(babble,0,n);
  quicksort(arr,0,n-1);
  for(i=0;i<n;i++){
    if(babble[i].value != arr[i].value || babble[i].symbol != arr[i].symbol){
      printf("Not stable\n");
      break;
    }
  }
  if(i==n) printf("Stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",arr[i].symbol,arr[i].value);
  }
  return 0;
}

int partition(DATA arr[],int left,int right){
  int i,le;
  DATA tmp;
  le=left;
  for(i=left;i<right;i++){
    if(arr[i].value<=arr[right].value){
      tmp=arr[le];
      arr[le]=arr[i];
      arr[i]=tmp;
      le++;
    }
  }
  tmp=arr[le];
  arr[le]=arr[right];
  arr[right]=tmp;
  return le;
}

void quicksort(DATA arr[],int left,int right){
  int base;
  if(left<right){
    base = partition(arr,left,right);
    quicksort(arr,left,base-1);
    quicksort(arr,base+1,right);
  }
}

void mergeSort(DATA arr[],int le,int ri){
  int mid;
  if(le+1<ri){
    mid = (le+ri)/2;
    mergeSort(arr,le,mid);
    mergeSort(arr,mid,ri);
    merge(arr,le,mid,ri);
  }
}

void merge(DATA arr[],int le,int mid,int ri){
  int i,j,k;
  
  for(k=0;k<mid-le;k++){
    leftDATA[k]=arr[le+k];
  }
  for(k=0;k<ri-mid;k++){
    rightDATA[k]=arr[mid+k];
  }
  leftDATA[mid-le].value = rightDATA[ri-mid].value = 999999999;
  i=0;
  j=0;
  for(k=le;k<ri;k++){
    if(leftDATA[i].value<=rightDATA[j].value){
      arr[k] = leftDATA[i];
      i++;
    }else{
      arr[k] = rightDATA[j];
      j++;
    }
  }
  
}



Measured memory_bytes: 4140
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> A(1<<N);
  for(int i=0;i<(1<<N);i++) std::cin >> A[i];
  vvi dp1 = vv(1<<N, N+1, 0, int);
  vvi dp2 = vv(1<<N, N+1, 0, int);
  for(int i=0;i<(1<<N);i++) dp1[i][0] = A[i], dp2[i][0] = 0;
  for(int j=0;j<N;j++){
    for(int i=0;i<(1<<N);i++){
      if(i&(1<<j)){
        dp1[i][j+1] = max(dp1[i &~(1<<j)][j], dp1[i][j]);
        dp2[i][j+1] = max({min(dp1[i &~(1<<j)][j], dp1[i][j]), dp2[i &~(1<<j)][j], dp2[i][j]});
      }
      else dp1[i][j+1] = dp1[i][j], dp2[i][j+1] = dp2[i][j];
    }
  }
  int ans = 0;
  for(int i=1;i<(1<<N);i++){
    ans = max(ans, dp1[i][N] + dp2[i][N]);
    std::cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 65536
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int w,h,n;
  cin>>w>>h>>n;
  int d[w];
  memset(d,0,sizeof(d));
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    d[x]=max(d[x],y);
  }
  int ans=w,k=0;
  for(int i=w-1;i>=0;i--){
    ans=min(ans,i+k);
    k=max(k,d[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3860
import sys, math
from functools import lru_cache
from itertools import accumulate
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

N, A, B, C, D = mi()
S = input()
f = (not '##' in S[A-1:C]) and (not '##' in S[B-1:D])
if C > D:
    f = f and ('...' in S[B-2:D+1])

print('Yes' if f else 'No')


Measured memory_bytes: 9824
#include <iostream>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;

int main()
{
    long long n,k,i;
    cin>>n>>k;
    long long s[n+5];
    for(i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n);
    long long sum=0;
    for(i=0;i<k;i++)
        sum=sum+s[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;


class Solve
{
  public Solve() { }
  public static int Main()
  {
    new Solve().calc();
    return 0;
  }


  Scanner cin;

  void calc()
  {
    cin = new Scanner();
    uint X = cin.nextUInt();
    uint count500 = X / 500;
    X -= 500 * count500;
    uint count5 = X / 5;

    uint result = count500 * 1000 + count5 * 5;

    Console.WriteLine(result.ToString());

  }
}
class Modulo
{
  private const int M = 1000000007;
  private readonly int[] m_facs;
  public int Mul(int a, int b)
  {
    return (int)(Math.BigMul(a, b) % M);
  }
  public Modulo(int n)
  {
    m_facs = new int[n + 1];
    m_facs[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
      m_facs[i] = Mul(m_facs[i - 1], i);
    }
  }
  public int Fac(int n)
  {
    return m_facs[n];
  }
  public int Pow(int a, int m)
  {
    switch (m)
    {
      case 0:
        return 1;
      case 1:
        return a;
      default:
        int p1 = Pow(a, m / 2);
        int p2 = Mul(p1, p1);
        return ((m % 2) == 0) ? p2 : Mul(p2, a);
    }
  }
  public int Div(int a, int b)
  {
    return Mul(a, Pow(b, M - 2));
  }
  public int Ncr(int n, int r)
  {
    if (n < r) { return 0; }
    if (n == r) { return 1; }
    int res = Fac(n);
    res = Div(res, Fac(r));
    res = Div(res, Fac(n - r));
    return res;
  }
}

class Scanner
{
  string[] s;
  int i;

  char[] cs = new char[] { ' ' };

  public Scanner()
  {
    s = new string[0];
    i = 0;
  }

  public string next()
  {
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }

  public int nextInt()
  {
    return int.Parse(next());
  }
  public uint nextUInt()
  {
    return uint.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0)
  {
    int[] Array = new int[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextInt() + add;
    }
    return Array;
  }

  public long nextLong()
  {
    return long.Parse(next());
  }

  public ulong nextULong()
  {
    return ulong.Parse(next());
  }

  public long[] ArrayLong(int N, long add = 0)
  {
    long[] Array = new long[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextLong() + add;
    }
    return Array;
  }

  public double nextDouble()
  {
    return double.Parse(next());
  }


  public double[] ArrayDouble(int N, double add = 0)
  {
    double[] Array = new double[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}


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

using namespace std;

typedef long long ll;

struct prze
{
    ll il, x;
};

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector<prze> P;
    for (int l = 0; l < n; )
    {
        int p = l;
        while (p < n && a[p] == a[l])
            ++p;
        --p;
        if (a[l] == 0)
            P.push_back({p - l + 1, 0});
        else
            for (int i = 0; i < p - l + 1; ++i)
                P.push_back({1, a[l]});
        l = p + 1;
    }
    ll odp = 0;
    for (int i = 0; i < P.size(); ++i)
    {
        ll x = P[i].x, s = P[i].x;
        int kon = i;
        for (int j = 1; i + j < P.size() && j < 70; ++j)
        {
            if (x != s)
                break;
            x ^= P[i + j].x;
            s += P[i + j].x;
            ++kon;
        }
        if (x != s)
            --kon;
        ll ile = 0;
        for (int j = i; j <= kon; ++j)
            ile += P[j].il;
        if (P[i].x != 0)
            odp += ile;
        else
            for (int j = 0; j < P[i].il; ++j)
                odp += ile - j;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 8048
import sys
readline = sys.stdin.readline
from bisect import bisect

A, B, Q = map(int, readline().split())
S = [int(readline()) for i in range(A)]
T = [int(readline()) for i in range(B)]
ans = []
INF = 10**18
for i in range(Q):
    x = int(readline())
    p = bisect(S, x-1)
    lp = x - S[p-1] if p >= 1 else INF
    rp = S[p] - x if p < A else INF
    q = bisect(T, x-1)
    lq = x - T[q-1] if q >= 1 else INF
    rq = T[q] - x if q < B else INF
    ans.append("%d\n" % (min(max(lp, lq), max(rp, rq), lp*2+rq, lp+rq*2, lq*2+rp, lq+rp*2)))
sys.stdout.writelines(ans)

Measured memory_bytes: 76124
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
INF = 10 ** 18
#
N, K = map(int, input().split())

cnt = [0] * (N + 1)
for i in range(2 * K):
    q = input()
    if i % 2:
        lst = list(map(int, q.split()))
        for l in lst:
            cnt[l] = 1
    
ans = 0        
for i in range(1, N + 1):
    if cnt[i] == 0:
        ans += 1
#print(cnt)
print(ans)

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int u[100005];

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

	int n, k; cin >> n >> k;
	if (n % 2 == 1) {
		for (int j = 1; j <= k; j++) {
			cout << j << " " << (2 * k + 1 - j) << endl;
		}
	} else {
		int mx = 0;
		for (int j = 1, dist = k; dist > 0; j++, dist -= 2) {
			cout << j << " " << j + dist << endl;
			mx = max(mx, j + dist);
		}
		for (int j = mx + 1, dist = k - 1; dist > 0; j++, dist -= 2) {
			cout << j << " " << j + dist << endl;
		}
	}
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int n, t;
    cin >> n;
    int mn = INT_MAX;
    int ret = -INT_MAX;
    for (int i=0; i<n; ++i) {
        cin >> t;
        ret = max(ret, t - mn);
        mn = min(mn, t);
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 1e6+5;


void solve() {

  int d;
  cin>>d;
  vi c(d);
  vvi a(d,vi(27));
  rep(i,0,d)
    cin>>c[i];
  rep(i,0,d)
    fr(j,1,26)
      cin>>a[i][j];
  
  rep(i,0,d){
    int x = 1;
    fr(j,2,26)
       if(a[i][j]+c[j]>a[i][x]+c[x])
          x=j;
    cout<<x<<' ';
  }
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}







int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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


Measured memory_bytes: 3756
lit=[]
for aa in range(10):
	lit.append(input())
	try:
		lit[aa]=int(lit[aa])
	except ValueError:
		lit[aa]=list(lit[aa])
		del lit[aa][-1]
		lit[aa] = ''.join(lit[aa])
		lit[aa]=int(lit[aa])
print(sum(lit))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll n, k;
	cin >> n >> k;
	
	if(n == 0)
		cout << 1 << endl;
	else{
		ll ans = 0;
		while(n){
			ans++;
			n /= k;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct shain{
	int bangou;
	double uriage;
}shain;

int main(void){
	int data_n,i,j,flag,kaburi,hyouji;
	int bangou,tanka,suuryou;
	shain men[4001];
	
	while(1){
		scanf("%d",&data_n);
		if(data_n == 0) break;
		kaburi = 0;
		hyouji = 0;
		for(i=0;i < 4001;i++){
			men[i].bangou = 0;
			men[i].uriage = 0.0;
		}
		for(i=0;i < data_n;i++){
			scanf("%d %d %d",&bangou,&tanka,&suuryou);
			for(j=0;j <= i;j++){
				if(men[j].bangou == bangou){
					flag = 1;
					kaburi++;
					men[j].uriage += 1.0*tanka*suuryou;
				}
			}
			if(flag != 1){
				men[i].bangou = bangou;
				men[i].uriage = 1.0*tanka*suuryou;
			}
			flag = 0;
		}
		j = i;
		for(i=0;i < j;i++){
			if(men[i].uriage >= 1000000.0){
				printf("%d\n",men[i].bangou);
				hyouji++;
			}
		}
		if(hyouji == 0) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 676
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

ans = 0
for i in range(N-1, -1, -1):
    if A[i+1] - B[i] >= 0:
        d = B[i]
    else:
        d = A[i+1]
    A[i+1] -= d
    B[i] -= d
    ans += d

    if A[i] - B[i] >= 0:
        d = B[i]
    else:
        d = A[i]
    A[i] -= d
    B[i] -= d
    ans += d
print(ans)


Measured memory_bytes: 18624
import sys
input = sys.stdin.readline

def main():
    o = input().strip()
    e = input().strip()

    for i in range(len(e)):
        print("{}{}".format(o[i], e[i]), end="")
    
    if len(o) != len(e):
        print(o[-1])
    else:
        print()

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
p = [[0 for i in range(14)] for j in range(14)]
c, m = 0, 0
while True:
    try:
        x, y, size = map(int,input().split(','))
    except:
        break
    x += 2
    y += 2
    p[x][y] += 1
    p[x - 1][y] += 1
    p[x + 1][y] += 1
    p[x][y - 1] += 1
    p[x][y + 1] += 1
    if size > 1:
        p[x - 1][y - 1] += 1
        p[x - 1][y + 1] += 1
        p[x + 1][y - 1] += 1
        p[x + 1][y + 1] += 1
        if size > 2:
            p[x - 2][y] += 1
            p[x + 2][y] += 1
            p[x][y - 2] += 1
            p[x][y + 2] += 1
for i in range(2, 12):
    for j in range(2, 12):
        if p[i][j] == 0:
            c += 1
        elif p[i][j] > m:
            m = p[i][j]
print(c)
print(m)

Measured memory_bytes: 7712
function main(input) {
    const numbers = input.split("\n")[0].split(" ").map( v => Number(v));
    const list = JSON.parse(JSON.stringify(input.split("\n")));
    list.shift();
    const listSorted = list.sort();

    console.log(listSorted.join(''));
}


// let input = "3 3" + '\n' +
// "dxx" + '\n' +
// "axx" + '\n' +
// "cxx"

// main(input);
main(require("fs").readFileSync("/dev/stdin","utf8"));
  

Measured memory_bytes: 29548
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
  
	//出力
	console.log((tmp[0]%2==1&&tmp[1]%2==1)? "Odd" : "Even");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void solve() {
    int n;
    cin >> n;

    set<string> s;

    for (int i = 0; i < n; i++) {
        string cur;
        cin >> cur;
        s.insert(cur);
    }

    cout << s.size() << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 19204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, j, n) for (int i = j; i < (n); ++i);
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	int n; cin >> n;
	vector<ll> v(n);
	rep(i, n) cin >> v[i];
	vector<ll> param1(n), param2(n);
	param1[0] = -1;
	param2[0] = 1;
	if (n % 2 == 0) {
		param1[1] = 1;
		param2[1] = -1;
	}
	else {
		param1[1] = -1;
		param2[1] = 1;
	}
	for (int i = 2; i < n; ++i) {
		if (i % 2 == 0) {
			param1[i] = 2;
			param2[i] = -2;
		}
		else {
			param1[i] = -2;
			param2[i] = 2;
		}
	}
	sort(param1.begin(), param1.end());
	sort(param2.begin(), param2.end());
	ll ans = 0;
	ll tmpans = 0;
	sort(v.begin(), v.end());
	rep(i, n) {
		tmpans += v[i] * param1[i];
	}
	ans = max(ans, tmpans);
	tmpans = 0;
	rep(i, n) {
		tmpans += v[i] * param2[i];
	}
	ans = max(ans, tmpans);
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  while(std::cin >> n, n){
    int pprev = 0, tprev = 0, p, t;
    int flag = -1;
    int dp[4][n + 10];//所持数，バルーンid
    for (int i = 0; i < 4; i++) 
      for (int j = 0; j < n + 1; j++) 
        dp[i][j] = 1e9;
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      std::cin >> p >> t;
      for (int j = 1; j < 4; j++) {
        if(j*abs(p - pprev) <= t - tprev)
          dp[j][i] = min(dp[j][i], dp[j - 1][i - 1] + abs(p - pprev));
        if(p + j*pprev <= t - tprev)
          dp[1][i] = min(dp[1][i], dp[j - 1][i - 1] + p + pprev);
        // dp[0][i] = min(dp[0][i], dp[j][i] + p);
      }
      if(p + 4*pprev <= t - tprev)
        dp[1][i] = min(dp[1][i], dp[3][i - 1] + p + pprev);        
      pprev = p;
      tprev = t;
    }
    int ans = 1e9;
    for (int i = 0; i < 4; i++) {
      ans = min(ans, dp[i][n] + p);
    }
    // for (int i = 0; i < 4; i++) {
    //   for (int j = 0; j <= n; j++) {
    //     if(dp[i][j] == 1e9) std::cout << setw(4) << -1 << " ";
    //     else std::cout << setw(4) << dp[i][j] << " ";
    //   }
    //   std::cout <<  std::endl;
    // }
    if(ans != 1e9){
      std::cout << "OK " << ans << std::endl;      
    }else{
      std::cout << "NG ";
      for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 4; j++) {
          if(dp[j][i] != 1e9){
            std::cout << i + 1 << std::endl;
            i = -1e9;
            j = 1e9;
          }
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3100
import math
MOD=10**9+7

def comb(n,r):
  nPr=1
  fact_r=1
  for i in range(r):
    nPr*=n-i
    fact_r*=r-i
  return nPr//fact_r

N,M=map(int,input().split())
fact={}
for i in range(2,int(math.sqrt(M))+1):
  if M==1:
    break
  while(M%i==0):
    M//=i
    if not i in fact:
      fact[i]=1
    else:
      fact[i]+=1  
if M!=1:
  fact[M]=1
  
#print(fact)
answer=1
for r in fact.values():
  answer*=comb(N+r-1,r)
  answer%=MOD
  
print(answer)

Measured memory_bytes: 3064
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, k: usize, a: [u128; n]};

    for i in k..n {
        if a[i] > a[i - k] {
            println!("Yes")
        } else {
            println!("No")
        }
    }
}


Measured memory_bytes: 7284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
const int mod = INF;
const int MAX = 1 << 25;
ll dp[200005][35];
int main()
{
	ios_base::sync_with_stdio(0);
	int n , t;
	cin >> n >> t;
	vector<pair<ll , ll> > p;
	vector<int> zh;
	for(int i = 0; i < n; i++)
	{
		int a , b;
		cin >> a >> b;
		if(a == 0)
			zh.pb(b);
		else
			p.pb({a , b});
	}
	sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) >
			(p2.x * (p1.y + 1));});
	sort(zh.begin() , zh.end());
	ll sum = 0;
	for(auto &x : zh)
	{
		sum += x + 1;
		x = sum;
	}
	for(int i = 0; i <= n; i++)
		for(int j = 0; j < 35; j++)
			dp[i][j] = INF;
	
	dp[0][0] = 0;
	n = sz(p);
	for(int j = 0; j < 34; j++)
	{
		for(int i = 0; i < n; i++)
		{
			
			dp[i + 1][j] = min(dp[i + 1][j] , dp[i][j]);
			dp[i + 1][j + 1] = min(dp[i + 1][j + 1] , (dp[i][j] + 1) * (p[i].x + 1) + p[i].y);
			
		}
	}
			
	int ans = 0;
	for(int j = 0; j < 34; j++)
		if(dp[n][j] <= t)
		{
			int v = (upper_bound(zh.begin() , zh.end() , t - dp[n][j]) - zh.begin());
			ans = max(ans , j + v);
		}
	cout << ans;
}


Measured memory_bytes: 58988
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var v = firstLine[0];
            var e = firstLine[1];
            var inf = long.MaxValue / 2;
            var dp = new long[v + 1, v + 1];
            for (var i = 0; i < v + 1; i++)
            {
                for (var j = 0; j < v + 1; j++)
                {
                    if (i != j)
                    {
                        dp[i, j] = inf;
                    }
                    else
                    {
                        dp[i, j] = 0;
                    }
                }
            }
            for (var i = 0; i < e; i++)
            {
                var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
                dp[line[0] + 1, line[1] + 1] = line[2];
            }

            for(var i = 1; i <= v; i++)
            {
                for(var j = 1; j <= v; j++)
                {
                    for(var k = 1; k <= v; k++)
                    {
                        dp[j, k] = Min(dp[j, k], dp[j, i] + dp[i, k]);
                    }
                }
            }

            for(var i = 1; i <= v; i++)
            {
                if(dp[i, i] < 0)
                {
                    WriteLine("NEGATIVE CYCLE");
                    return;
                }
            }

            for(var i = 1; i <= v; i++)
            {
                for(var j = 1; j <= v; j++)
                {
                    Write(dp[i, j] < (long)20000000 * 100000 ? $"{dp[i, j]}" : "INF");
                    if(j != v)
                    {
                        Write(" ");
                    }
                }
                WriteLine();
            }
        }
    }
}



Measured memory_bytes: 20536
def main():
    x = int(input())
    k = 0
    y = 100
    for i in range(100000000):
        k = k + 1
        hukuri = int(y * 0.01)
        y = y + hukuri
        if y >= x:
            print(k)
            break
if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
X = int(input())
for i1 in range(100):
    for i2 in range(10):
        for i3 in range(10):
            for i4 in range(10):
                for i5 in range(10):
                    for i6 in range(10):
                        ans = i1*100+i2*101+i3*102+i4*103+i5*104+i6*105
                        if ans == 0:
                            continue
                        if X%ans == 0:
                            print(1)
                            exit()
print(0)

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

vector<ll> a(100001);
int n;

int binarySearch(ll key){
  ll left = 0;
  ll right = n;
  while(left < right){
    ll mid = (right + left)/2;
    if(key == a[mid]){
      return 1;
    }else if(key<a[mid]){
      right = mid;
    }else{
      left = mid + 1;
    }
  }
  return 0;
}

int main(){
  cin >> n;
  rep(i,n) cin >> a[i];
  int q; cin >> q;
  int sum = 0;
  rep(i,q){
    ll key; cin >> key;
    if(binarySearch(key)) sum++;
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3456
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(S.charAt(0) == S.charAt(1) && S.charAt(1) == S.charAt(2)) {
        	System.out.println("No");
        }else {
        	System.out.println("Yes");
        }
	}
}

Measured memory_bytes: 35476
n = int(input())

ans = 0
flag = 0
for i in range(n,1000): 
    s = str(i)
    n_list = list(s)
    if n_list[0] == n_list[1] and n_list[1] == n_list[2] and flag == 0:
        flag = 1
        ans = i
        
print(ans)

Measured memory_bytes: 9056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	int[] oneDigitArr = {1,2,3,4,5,6,7,8,9};
	
	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int k = fs.nextInt();
		if(k <= 9){
			System.out.println(oneDigitArr[k-1]);
			return;
		}
		
		TreeSet<Long> lunlunTree = new TreeSet<>();
		for(int i = 0; i < 9; i++){
			lunlunTree.add(new Long(oneDigitArr[i]));
		}
		
		
		int lunlunSize = 9;
		
		while(lunlunSize < k){
			
			long firstElm = lunlunTree.first();
			lunlunTree.remove(firstElm);
			
			long firstDigit = firstElm % 10;
			
			if(firstDigit > 0){
				lunlunTree.add(firstElm*10+firstDigit - 1);
				lunlunSize++;
				if(lunlunSize == k){
					break;
				}
			}
			
			lunlunTree.add(firstElm*10+firstDigit);
			lunlunSize++;
			if(lunlunSize == k){
				break;
			}
			
			if(firstDigit < 9){
				lunlunTree.add(firstElm*10+firstDigit+1);
				lunlunSize++;
				if(lunlunSize == k){
					break;
				}
			}
		}
		System.out.println(lunlunTree.last());
		
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 29184