akhauriyash/Code-Regression huggingface dataset:
import sys

a,v=map(int, input().split())
b,w=map(int, input().split())
t=int(input())
if b > a:
    dif = b - a
elif b < a:
    dif = a - b

if v <= w:
    print("NO")
    sys.exit(0)

nowdif = v - w
if dif <= nowdif * t:
    print("YES")
    sys.exit(0)

print("NO")


Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[100005],s,f=0,n=0,i=0,b=0;
  cin>>s;
  while(b==0){
    if(i==0){
      a[i]=s;
    }else{
      if(a[i-1]%2==1){
	a[i]=a[i-1]*3+1;
      }else{
	a[i]=a[i-1]/2;
      }
    }
    n=a[i];
    for(int j=0;j<i;j++){
      if(n==a[j]){
	b=n;
	break;
      }
    }
    i++;
  }
  cout<<i<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

void warshallFloyd(int alt[100][100], int n){
    range(k,0,n + 1){
        range(i,0,n + 1){
            range(j,0,n + 1){
                alt[i][j] = min(alt[i][j], alt[i][k] + alt[k][j]);
            }
        }
    }
}

int main(){
    int a, b, c, d;
    int n, m;
    int atl[100][100];
    rep(i,100) rep(j,100) atl[i][j] = INF;
    cin >> n >> m;
    rep(i,m){
        scanf("%d%*c%d%*c%d%*c%d", &a, &b, &c, &d);
        atl[a][b] = c;
        atl[b][a] = d;
    }
    warshallFloyd(atl, n);
    scanf("%d%*c%d%*c%d%*c%d", &a, &b, &c, &d);
    cout << c - atl[a][b] - atl[b][a] - d << endl;
}

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

int N;
int x[8];
int y[8];

double sum=0;

double dist(int i, int j) {
  return sqrt( (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) );
}

double total_length(vector<int> perm) {
  double d = 0;
  for(int i=1; i<(int)perm.size(); i++) d += dist(perm[i-1], perm[i]);
  return d;
}

int main()
{
  cin >> N;
  for (int i=0; i<N; i++) cin >> x[i] >> y[i];

  vector<int> p(N);
  iota(p.begin(),p.end(), 0);

  double l = 0;
  do {
    l += total_length(p);
  } while(next_permutation(p.begin(), p.end()));

  int kaijou = 1;
  for (int i=2; i<=N; ++i) kaijou *= i;

  cout << fixed << setprecision(10) << l / kaijou << endl;

  return 0;
}


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

int main()
{
	int a = 0;
	string A, B;
	cin >> A >> B;
	if (A.at(0) == B.at(0)) {
		a++;
	}
	if (A.at(1) == B.at(1)) {
		a++;
	}
	if (A.at(2) == B.at(2)) {
		a++;
	}
	cout << a << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v[505];

int main(){
  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  while((a-1)*ans+1 < b) ans += 1;
  cout << ans << endl;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n;
    vl p(n);
    NREP() {
        cin >> p.at(i);
    }

    vl b = p;
    sort(ALL(p));

    ll diff = 0;
    NREP() {
        if (b.at(i) != p.at(i)) diff++;
    }

    YN(diff == 0 || diff == 2)
}


Measured memory_bytes: 256
#include <stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

int main(void){
    int n, i, j;
    scanf("%d", &n);
    int a[3*n];
    for(i=0; i<3*n; i++){
      scanf("%d", &a[i]);
    }
    //end to read
    QSort(a, 0, 3*n-1);
    unsigned long long ans=0;
    for(j=0; j<n; j++){
      ans += a[3*n-2*j-2];
    }
    printf("%llu\n", ans);
    return 0;
}

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}


Measured memory_bytes: 1280
def solve(N):
    if N == 0:
        return '0'
    if N == 1:
        return '1'

    if N % 2 == 0:
        return '0'+solve(N//-2)
    if N % 2 ==1:
        return '1'+solve((N-1)//-2)

print(solve(int(input()))[::-1])


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Stack;
import java.util.Scanner;
import java.util.Queue;

/**
 * @author yoshikyoto
 */
class Main{
	static final boolean DEBUG = true;
	static Scanner sc = new Scanner(new InputStreamReader(System.in));
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String args[]) throws Exception{
		Prime.calc(999999);
		String line;
		while((line = readLine()) != null){
			p(Prime.count[parseInt(line)]);
		}
	}
	
	public static String readLine() throws IOException{return br.readLine();}
	public static int readInt(){return sc.nextInt();}
	public static void pa(Object[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(int[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(double[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(boolean[] arr){System.out.println(Arrays.toString(arr));}
	public static void p(Object o){System.out.println(o.toString());}
	public static void d(Object o){if(DEBUG)System.out.println(o.toString());}
	public static void da(int[] arr){if(DEBUG)System.out.println(Arrays.toString(arr));}
	public static void sort(int[] a){Arrays.sort(a);}
	public static int[] parseInt(String[] arr){
		int[] res = new int[arr.length];
		for(int i = 0; i < arr.length; i++)res[i] = Integer.parseInt(arr[i]);
		return res;
	}
	public static int parseInt(Object o){return Integer.parseInt(o.toString());}
	public static int digit(int n){return String.valueOf(n).length();}
	public static String reverse(String s){
		StringBuffer sb = new StringBuffer(s);
		return sb.reverse().toString();
	}
}

class Prime{
	static boolean[] a;
	static int[] count;
	public static void calc(int n){
		a = new boolean[n+1];
		a[0] = false; a[1] = false;
		for(int i = 2; i <= n; i++) a[i] = true;
		
		// ふるい
		for(int i = 2; i < (n - 3) / 2; i++)
			if(a[i]) for(int j = 2; j * i <= n; j++)
					a[j * i] = false;
		
		// 数え上げ
		count = new int[n+1];
		count[0] = 0;
		for(int i = 1; i <= n; i++){
			int gain = 0;
			if(a[i]) gain = 1;
			count[i] = count[i-1] + gain;
		}
	}
}

class MyHashMap<E> extends HashMap<E, Integer>{
	ArrayList<E> keyArray = new ArrayList<E>();
	public void add(E key){add(key, 1);}
	public void add(E key, Integer value){
		if(containsKey(key)){
			value += get(key);
		}else{
			keyArray.add(key);
		}
		put(key, value);
	}
}

Measured memory_bytes: 27176
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

const int INF = 1001001001;

int main(){
  int n, m;
  int a, b;

  cin >> n >> m;
  vector<int> G[100005];

  for (int i = 1; i <= m; i++){
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  queue<int> que;

  dist[0] = 0;
  que.push(0);

  while (!que.empty()){
    int v = que.front();
    que.pop();

    for (vector<int>::iterator it = G[v].begin(); it != G[v].end(); it++){
      if (dist[*it] != INF) continue;

      dist[*it] = dist[v] + 1;
      pre[*it] = v;
      que.push(*it);
    }
  }

  cout << "Yes" << endl;

  for (int i = 0; i < n; i++){
    if (i == 0) continue;
    int ans = pre[i];
    ans++;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 10484
//dfsの練習問題
//各々の座標をスタート地点とする。
#include <bits/stdc++.h>

using namespace std;


int main() {

	int H, W,tmp=-1;
	cin >> H >> W;
	vector<vector<char>> Map(H, vector<char>(W));
	vector<vector<int>>search(H, vector<int>(W, -1)), ans(H, vector<int>(W));//四重のvectorにしてもいい？わかりにくいじゃん…
	priority_queue<int> Ans;
	pair<int, int> current;
	queue<pair<int, int>> que;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t j = 0; j < W; j++)
		{
			cin >> Map.at(i). at(j);
		}
	}
	//それぞれのスタート地点に対し，queueが空っぽになるまで最大値を求め続ける。
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			//スタート地点が壁なら進みようがないなぁ
			if (Map.at(i).at(j)=='#')
			{
				continue;
			}
			search.at(i).at(j) = 0;
			que.push(pair<int, int>(i, j));
			do
			{
				current=que.front();
				que.pop();
				if ((current.first!=0) &&(Map.at(current.first-1).at(current.second)=='.')&&(search.at(current.first-1).at(current.second)==-1))
				{
					que.push(pair<int, int>(current.first - 1, current.second));
					search.at(current.first - 1).at(current.second) = search.at(current.first).at(current.second) + 1;
				}

				if ((current.first != H-1) && (Map.at(current.first + 1).at(current.second) == '.') && (search.at(current.first+1).at(current.second) == -1))
				{
					que.push(pair<int, int>(current.first + 1, current.second));
					search.at(current.first + 1).at(current.second) = search.at(current.first).at(current.second) + 1;
				}

				if ((current.second != 0) && (Map.at(current.first).at(current.second-1) == '.') && (search.at(current.first).at(current.second-1) == -1))
				{
					que.push(pair<int, int>(current.first, current.second-1));
					search.at(current.first).at(current.second-1) = search.at(current.first).at(current.second) + 1;
				}

				if ((current.second != W-1) && (Map.at(current.first).at(current.second + 1) == '.') && (search.at(current.first).at(current.second+1) == -1))
				{
					que.push(pair<int, int>(current.first, current.second + 1));
					search.at(current.first).at(current.second + 1) = search.at(current.first).at(current.second) + 1;
				}
				
			} while (!que.empty());
			for (size_t k = 0; k < H; k++)
			{
				for (size_t l = 0; l < W; l++)
				{
					if (search.at(k).at(l)>tmp)
					{
						tmp = search.at(k).at(l);
					}
				}
			}
			Ans.push(tmp);
			tmp = -1;
			ans.at(i).at(j) = search.at(H-1).at(W-1);
			for (size_t k = 0; k < H; k++)
			{
				for (size_t l = 0; l < W; l++)
				{
					search.at(k).at(l) = -1;
				}
			}
		}
	}
	cout << Ans.top();
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<math.h>
using namespace std;
int main()
{
    
   int x;
cin>>x;
cout<<"ABC"<<x<<endl;
    return 0;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool cmp(pair<pair<string,int>,int> a, pair<pair<string,int>,int> b) {
	if ( a.first.first == b.first.first ) return a.first.second > b.first.second;
	else return a.first.first < b.first.first;
}

bool solve() {
	lli n = 1;
	if ( cin >> n );
	else return false;
	
	vector< pair<pair<string,int>,int> > res(n);
	
	for (int i = 0; i < n; ++i) {
		cin >> res[i].first.first >> res[i].first.second;
		res[i].second = i+1;
	}
	
	sort( res.begin(), res.end(), cmp );
	
	for (int i = 0; i < n; ++i) {
		cout << res[i].second << '\n';
	}
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if(a+b+c >= 22)
        System.out.println("bust");
      	else
          System.out.println("win");
      	
    }	
}

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

using namespace std;
typedef __int128 var;

const int N = 112;
const int MOD = 998244353;

int _ad(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
int _mu(int a, int b) { return (1ll * a * b) % MOD; }

struct Num {
  var val;
  int len;
  bool operator < (const Num &t) const {
    if (val == t.val) return len < t.len;
    return val < t.val;
  }
};

char s[N];
int n, pw2[N];
map<Num, int> dp;

int solve(Num num);
var getS(var S, int l, int r);

int main() {
  scanf("%s", s);
  n = strlen(s);
  pw2[0] = 1;
  for (int i = 1; i <= n; ++i) 
    pw2[i] = _ad(pw2[i - 1], pw2[i - 1]);
  var S = 0;
  for (int i = n - 1; i >= 0; --i)
    (S <<= 1) |= (s[i] - '0');
  printf("%d\n", solve((Num) {S, n}));
  return 0;
}

int solve(Num num) {
  if (dp[num]) return dp[num];
  var K = num.val;
  int k = num.len, res = 0;
  if (!k) {
    dp[num] = 1;
    return 1;
  }
  var S = getS(K, 0, n - 1);
  for (int i = 0; i < k; ++i)
    if ((S >> i) & 1) ++res;
  res = pw2[res];
  int cnt = 0;
  for (int i = 0; i < k; ++i) {
    for (int j = i; j < k; ++j) {
      int len = (j - i + 1);
      if (j + len > k - 1) break;
      var v = getS(S, i, j);
      for (int t = i + len; t + len - 1 < k; t += len) {
        var fS = getS(S, t, t + len - 1),
            bS = getS(S, t + len, k - 1);
        v &= fS;
        res = _ad(res, _mu(pw2[cnt], _mu(
                solve((Num) {v, len}),
                solve((Num) {bS, k - (t + len)})
              )));
      }
    }
    if ((S >> i) & 1) cnt++;
  }
  dp[num] = res;
  return res;
}

var getS(var S, int l, int r) {
  return S >> l & (((var) 1 << (r - l + 1)) - 1);
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
int main(void){
    int a, b, c;
    double S, L, h;
    scanf("%d %d %d", &a, &b, &c);
    S = 0.5*a*b*sin(c*PI/180);
    L = a + b + sqrt(a*a + b*b - 2*a*b*cos(c*PI/180));
    h = (2*S)/a;
    printf("%lf\n", S);
    printf("%lf\n", L);
    printf("%lf\n", h);
    return 0;
    
}


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

using namespace std;

const int INF = 1 << 30;

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

  int ret = INF;
  for(char c = 'a'; c <= 'z'; c++) {
    if(S.find(c) == string::npos) continue;

    int res = 0;
    auto curr = S;
    while(count(begin(curr), end(curr), c) != curr.size()) {
      string next;
      for(int j = 0; j + 1 < curr.size(); j++) {
        if(curr[j] == c || curr[j + 1] == c) next += c;
        else next += curr[j];
      }
      curr.swap(next);
      ++res;
    }
    ret = min(ret, res);
  }

  cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef unsigned long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int a[maxn];

int main()
{
    int n;
    cin>>n;
    ll ans=0;
    int maxx=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(maxx>a[i]) ans+=(maxx-a[i]);
        maxx=max(a[i],maxx);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4536
#include <cstdio>
#include <cmath>

#include <algorithm>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, x;

int memo[100000];

int med(int a, int b, int c) {
	int d[3] = { a, b, c };
	std::sort(d, d + 3);
	return d[1];
}

int main() {
	scanf("%d%d", &n, &x);
	
	bool f = (x != 1 && x != 2 * n - 1);
	
	printf("%s\n", f ? "Yes" : "No");
	if(f) {
		if(n == 2) { printf("1\n2\n3\n"); }
		else {
			bool g = (x == 2);
			incII(i, 1, n - 2) {
				if(i == x - 2) { g = true; }
				printf("%d\n", i + (g ? 4 : 0));
			}
			if(x == 2) { printf("%d\n%d\n%d\n%d\n", x + 1, x, x - 1, x + 2); }
			if(x != 2) { printf("%d\n%d\n%d\n%d\n", x - 1, x, x + 1, x - 2); }
			
			incII(i, n + 3, 2 * n - 1) {
				if(i - 4 == x - 2) { g = true; }
				printf("%d\n", i + (g ? 0 : -4));
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  REP(i, n) { cout << s[i] << t[i]; }
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define B 13
#define M 9
#define S 5
void drop(int x,int y,int xy[][10]){
	if(x>-1&&x<10&&y>-1&&y<10) xy[y][x]++;
}


int main(){
	int x,y,size,max,num;
	int i,j;
	int xy[10][10];
	max=num=0;
	for(i=0;i<10;i++){
		for(j=0;j<10;j++) xy[i][j]=0;
	}
	int b[B][2] = {{0,-2},{-1,-1},{0,-1},{1,-1},{-2,0},{-1,0},{1,0},{2,0},{-1,1},{0,1},{1,1},{0,2},{0,0}};
	int m[M][2] = {{-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1},{0,0}};
	int s[S][2] = {{0,-1},{-1,0},{0,1},{1,0},{0,0}};

	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
		switch(size){
		case 1:
			for(int i=0;i<S;i++) drop(x+s[i][0],y+s[i][1],xy);
			break;
		case 2:
			for(int i=0;i<M;i++) drop(x+m[i][0],y+m[i][1],xy);
			break;
		case 3:
			for(int i=0;i<B;i++) drop(x+b[i][0],y+b[i][1],xy);
			break;
		}
	}
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			if(!xy[i][j]) num++;
			else if(xy[i][j]>max) max = xy[i][j];
		}
	}
	printf("%d\n%d\n",num,max);
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=998244353;
ll modpow(ll x,ll y){
if(y==0)
  return 1;
  else if(y%2==0){
  ll z=modpow(x,y/2);
    return (z*z)%mod;
  }else{
   ll z=modpow(x,y/2);
    return (x*((z*z)%mod))%mod;
  }
}
ll N;
ll fac[10000005];
ll rev[10000005];
ll inf[10000005];
int main(){
  cin>>N;N/=2;
  fac[0]=1;rev[0]=1;
  for(ll i=1;i<=N;i++){
  fac[i]=(i*fac[i-1])%mod;
    rev[i]=modpow(fac[i],mod-2);
  }ll a=1;
  inf[0]=1;
  for(ll i=1;i<=N;i++){
  a=(a*2)%mod;
    inf[i]=(a*((fac[N]*((rev[N-i]*rev[i])%mod))%mod))%mod;
  }ll ans=0;ll sum=0;
  for(ll i=0;i<N;i++){
  sum=(sum+inf[i])%mod;
    ans=(ans+((inf[N-1-i]*sum)%mod))%mod;
  }
  ll all=modpow(9,N);
  ans=(all-2*ans+2*mod)%mod;
  cout<<ans<<endl;
     return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k,x;
  cin >> k >> x;
  int mini;
  mini = max(-1000000, x-k+1);
  int maxi;
  maxi = min(1000000, x+k-1);
  for(int i = -1000000; i <= 1000000; i++){
    if((i >= mini && i < mini+k) || (i > maxi-k && i <= maxi)) cout << i << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,q,d[500005],f[500005],g[500005],i,s,x;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read();d[0]=read();
	for(i=1;i<=n;i++)
		g[i]=read();
	for(i=1;i<=n;i++)
		d[i]=min(d[i-1],abs(d[i-1]-g[i]));
	f[n+1]=1;
	for(i=n;i>=1;i--)
		if(f[i+1]<=g[i]/2)
			f[i]=f[i+1];
		else
			f[i]=f[i+1]+g[i];
	q=read();
	while(q--){
		x=read();
		if(f[x+1]<=d[x-1])
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll X;
    cin >> X;
    ll Money = 100;
    ll year = 0;
    while ( Money < X ){
        Money += Money / 100;
        year++;
        if ( Money >= X ){
            cout << year << endl;
            return 0;
        }
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int H, W;
    cin >> H >> W;
    for (int i=0; i<H; i++){
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
}

Measured memory_bytes: 256
n = gets.to_i
res = nil
5000.times do |a|
  break unless res.nil?
  a -= 2500
  5000.times do |b|
    break unless res.nil?
    b -= 2500
    # puts "#{a**5} - #{b**5} = #{a**5 - b**5}(#{n})"
    res = [a, b] if a**5 - b**5 == n
  end
end

res = [0, 0] if res.nil?
puts res.join(' ')

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

int main()
{
  char a[7],b[3];
  
  scanf("%s%s",a,b);
  
  int la=strlen(a),lb=strlen(b);
  int i;
  int x;
  
  x=atoi(strcat(a,b));
 
  for(i=1;i<=1000;i++)
  {
    if(i*i==x)
    {
      printf("Yes\n");
      return 0;
    }
  }
  
  printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
int main() {
    ll n, d, cnt = 0;
    cin >> n >> d;
    d *= d;
    while(n--) {
	ll x, y;
	cin >> x >> y;
	x *= x, y *= y;
	if(x + y <= d) cnt++;
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3600
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <map>
#include <string>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;
int main(){
  long double l;cin>>l;
  long double n=l/3;
  cout<<fixed<<setprecision(13)<<n*n*n;
}


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

int main()
{
    int l = 0;
    std::vector<int> seq;

    std::cin >> l;
    for (int i = 0; i < l; ++i) {
        int n=0;
        std::cin >> n;
        seq.push_back(n);
    }
    std::sort(seq.begin(), seq.end());

    bool duplicated = false;
    for (size_t i = 0; i < seq.size() - 1; ++i) {
        if (seq[i] == seq[i + 1]) {
            duplicated = true;
            break;
        }
    }
    if (duplicated) {
        std::cout << "NO" << std::endl;;
    } else {
        std::cout << "YES" << std::endl;;
    }
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A*B, C*D) << endl;
    return 0;
}

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

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<vector<char>> a(n,vector<char> (n));
    vector<vector<char>> b(m, vector<char>(m));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n;j++){
            cin >> a.at(i).at(j);
    }
    for (int i = 0; i < m; i++)
        for (int j = 0; j < m; j++){
            cin >> b.at(i).at(j);
        }

    bool exist = false; //あるかないかのチェック

    for (int i = 0; i < n;i++){
        for (int j = 0; j < n;j++){  //Aの範囲で
            if(i+m-1>=n || j+m-1>=n) //検索範囲
                continue; //次へ 

            bool match = true; // 検索元画像と同じものがないかチェック
            for (int y = 0; y < m; y++){
                for (int x = 0; x < m; x++){
                    if(a.at(i+y).at(j+x)!=b.at(y).at(x)) // 選択範囲の要素とBを比較
                        match = false;
                }
    }
    if (match) exist = true;
        }
    }
    if(exist){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
ll n;
int main(){
	cin>>n;
	for(int i=1;i<=32000;i++) 
		if(i*i>n) {cout<<(i-1)*(i-1);return 0;}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
multiset<int>st;
int main() {
	int q;
	cin >> q;
	while (q--) {
		int Q, k;
		cin >> Q >> k;
		if (Q == 0) {
			st.insert(k);
			cout << st.size() << endl;
		}
		else if (Q == 1) {
			cout << st.count(k) << endl;
		}
		else if (Q == 2) {
			st.erase(k);
		}
		else {
			int y;
			cin >> y;
			auto nowitr = st.lower_bound(k);
			auto enditr = st.upper_bound(y);
			while (nowitr != enditr) {
				cout << *nowitr << endl;
				nowitr++;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 12340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define NINF (1e15)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    ll N;
    cin >> N;
    ll ans = NINF;
    rep(i, N){
        ll a = i + 1;
        if(pow(a, 2.0) > N) break;
        if(N % a == 0){
            ans = min(ans, a + N / a - 2);
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[200];
int main()
{
    int cnt=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
        while(1)
        {
            for(int i=0; i<n; i++)
            {
                if(a[i]&1)
                {
                    cout<<cnt<<endl;
                    return 0;
                }
                a[i]=a[i]/2;
            }
            cnt++;
        }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
int main(){
    ll a, b , c , t;
    scanf("%lld%lld%lld" , &a , &b , &c);
    t = a - b;
    if( t > c ) cout << 0 << endl;
    else cout << c - t << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int max = 0;
        for(int i=1;i*i<=m;i++){
            if(m%i==0){
                int p = m/i;
                if(p >=n){
                    max = Math.max(max, i);
                    
                }
                
                p = i;
                if(p >= n){
                    max = Math.max(max, m/i);
                }
            }
        }
        System.out.println(max);
     }
}

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

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

  int res = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3840
local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local function baseneg2_tostr(t)
    if #t == 0 then
        return "0"
    else
        local r = {}
        for i=#t,1,-1 do
            table.insert(r, t[i])
        end
        return table.concat(r, "")
    end
end

local function baseneg2_to_dec(t)
    if #t == 0 then
        return 0
    else
        local n = 0
        for i=0,#t-1 do
            n = n + t[i+1]*(-2)^i
        end
        return math.floor(n)
    end
end

local function dec_to_baseneg2(n)
    dbgpr("dec_to_baseneg2", n)
    local t = {}
    local i = 1
    while n ~= 0 do
        local b = math.floor((-2)^i)
        local bb = math.floor((-2)^(i-1))
        dbgpr("ibnbb", i, b, n, bb)
        local q, r = math.abs(n // b) - 1, nil
        while true do
            dbgpr("rem", n, q, b*q, b*-q, bb)
            if n == b * q then
                q = q
                r = 0
                break
            elseif n == b * q + bb then
                q = q
                r = 1
                break
            elseif n == b * -q then
                q = -q
                r = 0
                break
            elseif n == b * -q + bb then
                q = -q
                r = 1
                break
            end
            q = q + 1
        end
        local rr = r * bb
        dbgpr("r rr", r, rr)
        n = n - rr
        dbgpr("newn", n)
        table.insert(t, r)
        i = i + 1
    end
    return t
end

local function test(n)
    local t = dec_to_baseneg2(n)
    --print("res", n, baseneg2_tostr(t))
    assert(n == baseneg2_to_dec(t))
end


test(0)
test(1)
test(-2)
test(-1)
test(-9)
test(123456789)

print(baseneg2_tostr(dec_to_baseneg2(io.read("n"))))


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int h[n];
    for (int i=0;i<n;i++) cin>>h[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for (int i=2;i<n;i++) dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
    cout<<dp[n-1]<<"\n";
	return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  vi d(n); rep(i,n) cin >> d[i];
  sort(all(d));
  int h = n/2;
  cout << d[h] - d[h-1] << endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		String s = in.readString(); 
		HashMap <Character,Character> map = new HashMap<>();
		boolean ans = true; 
		for(int i = 0; i<s.length(); i++) {
			if(map.containsKey(s.charAt(i))) {
				ans = false; 
			}
			else map.put(s.charAt(i),s.charAt(i)); 
		}
		System.out.println(ans ? "yes":"no"); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21076
// https://atcoder.jp/contests/abc178/tasks/abc178_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  ll mi_sum = INF;
  ll ma_sum = -INF;
  ll mi_diff = INF;
  ll ma_diff = -INF;

  rep(i, N) {
    ll x, y;
    cin >> x >> y;

    ll sum = x + y;
    chmin(mi_sum, sum);
    chmax(ma_sum, sum);

    ll diff = x - y;
    chmin(mi_diff, diff);
    chmax(ma_diff, diff);
  }

  ll res = abs(mi_sum - ma_sum);
  chmax(res, ma_diff - mi_diff);

  cout << res << "\n";
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define N 5020
#define int long long
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;

int n, inf = 200000000000000000;

pii v[N];

bool cmp(pii A, pii B)
{
	return A.f - B.s > B.f - A.s;
}

int dp[N][N];

int solve(int i, int qtd)
{
	if(i > n)
	{
		if(!qtd) return 0;

		return inf;
	}

	if(dp[i][qtd] != -1) return dp[i][qtd];

	int sum = solve(i + 1, qtd - 1), ans = inf;

	if(sum <= v[i].f) ans = sum + v[i].s;

	ans = min(ans, solve(i + 1, qtd));

	return dp[i][qtd] = ans;
}

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

	cin>>n;

	for(int i = 1; i <= n; i++) cin>>v[i].f>>v[i].s;

	sort(v + 1, v + n + 1, cmp);

	int opt = 0;

	memset(dp, -1, sizeof dp);

	for(int i = 0; i < N; i++)
		if(solve(1, i) < inf) opt = i;

	cout<<opt<<"\n";
}

Measured memory_bytes: 197504
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, P):
    M = 30000
    a = []
    b = []
    for i in range(1, N+1):
        a.append(i*M+1)
        b.append((N-i+1)*M + 1)
    for i, p in enumerate(P):
        a[p-1] += i

    return '\n'.join([' '.join(map(str, a)), ' '.join(map(str, b))])


def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))


if __name__ == '__main__':
    main()


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

using namespace std;
const int _max = 1000;
typedef long long ll;
int dir[4][2] = {{1,  0},{-1, 0},{0,  1},{0,  -1}};
struct Node {
    int x;
    int y;
};

int main() {
    int _;
    _=5;
    int biao;
    for(int i=1;i<=_;i++){
        int shu;
        cin>>shu;
        if(shu==0){
            biao=i;
            break;
        }
    }
    cout<<biao<<endl;

    return 0;
}

Measured memory_bytes: 3548
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>


using namespace std;

int main(void){
    char S[10];
    char T[10];
    scanf("%s %s",S,T);
    int A,B;
    scanf("%d %d",&A,&B);
    char U[10];
    scanf("%s",U);
    int i=0;
    int flg = 0;
    while(U[i]!='\0'){
        if(U[i]!=S[i]){
            printf("%d %d",A,B-1);
            return 0;
        }
        i++;
    }
    printf("%d %d",A-1,B);
    

    return 0;
}

Measured memory_bytes: 128
import math
 
n = int(input())
mod = 10 ** 9 + 7
 
ab = {}
for i in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        pass
    elif a == 0:
        b = 1
    else:
        gcd = math.gcd(a, b)
        a //= gcd
        b //= gcd
        if a < 0:
            a, b = -a, -b
    num = (a, b)
    ab.setdefault(num, 0)
    ab[num] += 1
ans = 0
if (0, 0) in ab.keys():
    temp2 = ab[(0, 0)]
    ans += temp2
    n -= temp2
s = set(ab.keys())
pairs = []
for i in ab.keys():
    if i == (0, 0):
        continue
    else:
        a, b = i[0], i[1]
        if (-b, a) in s:
            pairs.append([ab[(a, b)], ab[(-b, a)]])
temp3 = 1
for i in range(len(pairs)):
    num2 = pairs[i][0]
    num3 = pairs[i][1]
    temp3 *= (pow(2, num2, mod) + pow(2, num3, mod) - 1)
    n = n- num2 - num3
    temp3 %= mod
temp3 *= pow(2, n, mod)
temp3 -= 1
temp3 %= mod
ans += temp3
ans %= mod
print(ans)

Measured memory_bytes: 59424
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL s25,s5,s1,s2,n;

int main() {
    cin >> s25 >> s5 >> s1 >> s2 >> n;
    s5=min(s25*2,s5);
    s1=min(2*s5,s1);
    s2=min(2*s1,s2);
    LL ans=s2*(n/2)+s1*(n%2);
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);

    for(int i=1;i<=n;i++){
        int x;
        cin >> x;
        a[x-1]++;
    }

    sort(a);

    int y=0;

    for(int i=n-1;i>n-k-1;i--){
        y+=a[i];
    }

    cout << n-y << endl;
    return 0;
}

Measured memory_bytes: 1024
function main(lines) {
  const [H, W] = na();
  const [Ch, Cw] = sa().map(v => v-1);
  const [Dh, Dw] = sa().map(v => v-1);
  const maze = getLines(H);
  
  let primaryStack = [[Ch, Cw, 0]];
  let secondaryStack = [];
  let cost = 0;
  const done = Array(H).fill(0).map(_ => Array(W).fill(false));
  while (primaryStack.length) {
    const [h, w] = primaryStack.pop();
    if (h == Dh && w == Dw) return cost;
    if (!done[h][w]) {
      done[h][w] = true;
      for (let _h = h-2; _h <= h+2; _h++) {
        if (!maze[_h]) continue;
        for (let _w = w-2; _w <= w+2; _w++) {
          if (maze[_h][_w] != '.' || done[_h][_w]) continue;
          if (Math.hypot(_h-h, _w-w) <= 1) {
            primaryStack.push([_h, _w]);
          } else {
            secondaryStack.push([_h, _w]);
          }
        }
      }
    }
    if (!primaryStack.length) {
      cost++;
      [primaryStack, secondaryStack] = [secondaryStack, []];
    }
  }
  return -1;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);
const getLines = (n) => lines.slice(lineCount, lineCount += n);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 103700
#include <iostream>
#include <queue>

using namespace std;
typedef long long ll;
priority_queue<ll> que;
int main(){
	int i,n,m;
	cin >> n >> m;
	for(i=0;i<n;i++){
		ll a; cin >> a;
		que.push(a);
	}
	for(i=0;i<m;i++){
		ll x = que.top();
		que.pop();
		que.push(x/2);
	}
	ll sum = 0;
	for(i=0;i<n;i++){
		ll x = que.top();
		sum += x;
		que.pop();
	}
	cout << sum << endl;
}

Measured memory_bytes: 1400
N, M, C = map(int, input().split())
A, B = [], []
for i in range(N + 1):
    temp = map(int, input().split())
    if i == 0:
        B = list(temp)
    else:
        A.append(list(temp))
ans = 0
for i in range(N):
    t = sum([A[i][j]*B[j] for j in range(M)] + [C])
    ans += sum([A[i][j] * B[j] for j in range(M)] + [C]) > 0
print(ans)

Measured memory_bytes: 3064