akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
 
typedef struct node * Node;

Node root;

Node find(Node u, int k){
  if(u == NIL || k == u->key) return u;     
  if(k < u->key) return find(u->left,k);
  else return find(u->right,k);      
}
 
void insert(int k)
{
  Node x;
  Node y;
  Node z;
  y = NIL;
  x = root;
  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
    
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;
  
  if(y==NIL) root = z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;
}
  
void inorderTreeWalk(Node x)
{
  if(x==NIL) return;
  inorderTreeWalk(x->left);
  printf(" %d",x->key);
  inorderTreeWalk(x->right);
}
  
void preorderTreeWalk(Node x)
{
  if(x==NIL) return;
    printf(" %d",x->key);
    preorderTreeWalk(x->left);
    preorderTreeWalk(x->right);   
}
   
int main()
{
  char str[7];
  int n,i,x,key;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(str[0]=='p'){
      inorderTreeWalk(root);
      printf("\n");
      preorderTreeWalk(root);
      printf("\n");
    }
    else{
      scanf("%d",&key);
      if(find(root,key)==NIL) printf("no\n");
      else printf("yes\n");       
    }
  }
  return 0;  
}

Measured memory_bytes: 19364
#include<stdio.h>
int main(){
    int a[6], i;
    for(i = 0; i < 6; i++)
        scanf("%d",&a[i]);
    for(i = 0; i < 4; i++){
        for(int j = i + 1; j < 5; j++){
            if(a[j] - a[i] > a[5]){
                puts(":(");
                return 0;
            }
        }
    }
    puts("Yay!");
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var K = long.Parse(Console.ReadLine());

            var queue = new Queue<long>();
            for (var i = 1; i <= 9; i++)
            {
                queue.Enqueue(i);
            }

            var n = 0L;
            for (var i = 1; i <= K; i++)
            {
                n = queue.Dequeue();
                if (n % 10 != 0)
                {
                    queue.Enqueue(n * 10 + n % 10 - 1);
                }
                queue.Enqueue(n * 10 + n % 10);
                if (n % 10 != 9)
                {
                    queue.Enqueue(n * 10 + n % 10 + 1);
                }
            }
            Console.WriteLine(n);
        }
    }
}


Measured memory_bytes: 15072
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int d, n;
  cin >> d >> n;
  if (n == 100)
    n++;
  for (int i = 0; i < d; i++)
    n *= 100;
  cout << n << 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 R = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();

        int[][] field = new int[R + 1][C + 1];
        for(int i = 0; i < K; i++){
            field[sc.nextInt()][sc.nextInt()] = sc.nextInt();
        }

        long[][][] dp = new long[R + 1][C + 1][4];

        for(int i = 1; i <= R; i++){
            for(int j = 1; j <= C; j++){
                dp[i][j][0] = Math.max(dp[i - 1][j][3], dp[i][j - 1][0]);
                dp[i][j][1] = Math.max(
                        dp[i][j - 1][1],
                        Math.max(dp[i - 1][j][3], dp[i][j - 1][0]) + field[i][j]
                );
                dp[i][j][2] = Math.max(
                        dp[i][j - 1][2],
                        Math.max(dp[i - 1][j][3], dp[i][j - 1][1]) + field[i][j]
                );
                dp[i][j][3] = Math.max(
                        dp[i][j - 1][3],
                        Math.max(dp[i - 1][j][3], dp[i][j - 1][2]) + field[i][j]
                );
            }
        }
        
        System.out.println(dp[R][C][3]);

    }

}


Measured memory_bytes: 684328
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

if t1*a1+t2*a2 == t1*b1+t2*b2 or a1 == b1:
    print('infinity')
    exit()

if a1 < b1:
    a1,b1 = b1,a1
    a2,b2 = b2,a2



if a1*t1 + a2*t2 > b1*t1+b2*t2:
    print(0)
    exit()

res = 1
a = a1*t1
b = b1*t1
#Aの方が上
judge = True

c = a1*t1-b1*t1
d = -c - a2*t2 + b2*t2

if d > c:
    print(1)
    exit()

if c%d == 0:
    res -= 1

res += (c//d)*2

print(res)


Measured memory_bytes: 38388
#include<bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
  cin>>n;
  int a[n];
	for(int i=0;i<n;i++) {
     cin>>a[i]; 
    }
  sort(a,a+n);
  float avg=a[0];
  for(int i=1;i<n;i++) {
    avg=(avg+a[i])/2.0;
  }
  cout<<avg<<endl;
}

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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  int A, B;
  cin >> A >> B;
  if(B % A == 0) {
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# 初期入力
N,K = (int(x) for x in input().split(" "))
N_a = N
a =0
b =0
amari = []

while K <= N_a :
    a,b = divmod(N_a,K) 
    
    amari.append(b)
    N_a = a
amari.append(a)


print(len(amari))

Measured memory_bytes: 3064
N=int(input())
num_AC=0
num_WA=0
num_TLE=0
num_RE=0
for i in range(N):
    S=input()
    if S=="AC":
        num_AC+=1
    elif S=="WA":
        num_WA+=1
    elif S=="TLE":
        num_TLE+=1
    else:
        num_RE+=1
print("AC x ",num_AC)
print("WA x ",num_WA)
print("TLE x ",num_TLE)
print("RE x ",num_RE)

Measured memory_bytes: 9204
import fractions
from functools import reduce

n = int(input())
a = list(map(int,input().split()))

#累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))

ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)  

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

  typedef long long ll;
  typedef pair<int, int> P;
  typedef pair<ll, ll> PL;
  #define int ll

  const ll MOD = 1000000007;
  const ll INF_LL = (ll)1000000007 * 1000000007;
  const int INF_INT = (int)1000000007;
  const double PI = 3.14159265358979323846;

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

  #define FOR(i, a, b) for (int i = (a); i < (b); ++i)
  #define rep(i, n) FOR(i, 0, n)
  #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
  #define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
  #define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

  #define m0(x) memset((x), 0, sizeof((x)))
  #define m1(x) memset((x), -1, sizeof((x)))

  // xにはvectorなどのコンテナ
  #define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
  #define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
  #define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
  #define MAX(x) *max_element(ALL(x))  //最大値を求める
  #define MIN(x) *min_element(ALL(x))  //最小値を求める
  #define all(x) (x).begin(), (x).end()

  //略記
  #define pb emplace_back  // vectorヘの挿入
  #define mp make_pair     // pairのコンストラクタ
  #define F first          // pairの一つ目の要素
  #define S second         // pairの二つ目の要素

  #define BITCOUNT __builtin_popcount
  #define BITCOUNT_LL(x) __builtin_popcountll(x)

  #define perm(c)             \
    sort(all(c));             \
    for (bool c##p = 1; c##p; \
        c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

  #define BIT(n) (1LL << (n))

  #ifdef DEBUG
  #define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
  #else
  #define PRINT(A)
  #endif

  //入力高速化
  struct IoSetup {
    IoSetup() {
      cin.tie(nullptr);
      ios::sync_with_stdio(false);
      cout << fixed << setprecision(20);
    }
  } iosetup;

  template <class T>
  inline bool chmin(T &a, T b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
  }

  template <class T>
  inline bool chmax(T &a, T b) {
    if (a < b) {
      a = b;
      return true;
    }
    return false;
  }

  signed main() {
    int A,B,C; cin >> A >> B >> C;
    int K; cin >> K;
    
    int count = 0;
    while(A >= B){
      B *= 2;
      count ++;
    }
    while (B >= C) {
      C *= 2;
      count++;
    }

    if(count <= K) cout << "Yes" << endl;
    else cout << "No" << endl;

  }

Measured memory_bytes: 3644
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n;
int a[M];

int dp[M];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    rep(i,1,n+1) cin >> a[i];
    dp[0]=1;
    for(int i=1; i<=n; i++){
        dp[a[i]]+=dp[a[i]-1];
        //trace(i,a[i],dp[a[i]],dp[a[i]-1]);
    }
    int maxi=0;
    for(int i=1; i<=n; i++){
        if(dp[a[i]]) maxi=max(maxi,a[i]);
    }
    //trace(maxi);
    if(maxi==0) cout << -1;
    else cout << n-maxi;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
const int num[10]={0,2,5,5,4,5,6,3,7,6};
int n,m;
int a[15];
int dp[20005][15];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
		cin>>a[i];
	sort(a,a+m);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<m;i++)
		dp[0][i]=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			for(int k=0;k<m;k++)
				dp[i+num[a[k]]][k]=max(dp[i+num[a[k]]][k],dp[i][j]+1);
	while(n>0)
	{
		int mx=0,ma=-1;
		for(int i=0;i<m;i++)
			if(dp[n][i]>=mx)
			{
				mx=dp[n][i];
				ma=a[i];
			}
		n-=num[ma];
		cout<<ma;
	}
	return 0;
}


Measured memory_bytes: 1408
class comb():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, num + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def com(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD


n, k = list(map(int, input().split()))
MOD = 10**9 + 7

com = comb(n * 2, MOD)

ans = com.com(n * 2 - 1, n)
for i in range(k + 1, n + 1):
  t = com.com(n, i) * com.com(n - 1, i) % MOD
  ans -= t
  while ans < 0:
    ans += MOD


print(ans)



Measured memory_bytes: 119660
#include <cstdio>

const int MaxN = 200000 + 5, MaxM = 200000 + 5;
const int MaxK = 3000 + 5;
const int MaxV = 3000 + 5, MaxE = 9000000 + 5;
const int Mod = 1000000007;

struct Graph {
  int cnte;
  int Head[MaxV], Next[MaxE], To[MaxE];

  inline void addEdge(int from, int to) {
    cnte++; To[cnte] = to;
    Next[cnte] = Head[from]; Head[from] = cnte;
  }
};

int N, M, K;
int U[MaxK], V[MaxK];
int Fac[MaxN], Inv[MaxN], InvFac[MaxN];
int Ind[MaxK], Oud[MaxK], Dp[MaxK];
Graph G;

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }
inline int mul(int x, int y) { return 1LL * x * y % Mod; }
inline int pw(int x, int y) { int z = 1; for (; y; y >>= 1, x = mul(x, x)) if (y & 1) z = mul(z, x); return z; }
inline int inv(int x) { return pw(x, Mod - 2); }
inline int sep(int x, int y) { return mul(x, inv(y)); }
inline int com(int n, int m) { return mul(Fac[n], mul(InvFac[m], InvFac[n - m])); }
inline int calc(int dx, int dy) { return com(dx + dy, dx); }

void init() {
  scanf("%d %d %d", &N, &M, &K);
  for (int i = 1; i <= K; ++i)
    scanf("%d %d", &U[i], &V[i]);
  Fac[0] = 1;
  for (int i = 1; i <= N + M; ++i) Fac[i] = mul(Fac[i - 1], i);
  InvFac[N + M] = inv(Fac[N + M]);
  for (int i = N + M; i >= 1; --i) {
    Inv[i] = mul(InvFac[i], Fac[i - 1]);
    InvFac[i - 1] = mul(InvFac[i], i);
  }
}

void topSort() {
  static int que[MaxK];
  int head = 1, tail = 0;
  for (int i = 1; i <= K; ++i)
    if (Ind[i] == 0) que[++tail] = i;
  while (head <= tail) {
    int u = que[head++];
    Dp[u] = add(Dp[u], calc(U[u] - 1, V[u] - 1));
    for (int i = G.Head[u]; i; i = G.Next[i]) {
      int v = G.To[i];
      Dp[v] = sub(Dp[v], mul(Dp[u], calc(U[v] - U[u], V[v] - V[u])));
      Ind[v]--;
      if (Ind[v] == 0) que[++tail] = v;
    }
  }
}

void solve() {
  for (int i = 1; i <= K; ++i)
    for (int j = 1; j <= K; ++j) {
      if (i == j) continue;
      if (U[i] <= U[j] && V[i] <= V[j]) {
        G.addEdge(i, j);
        Ind[j]++;
        Oud[i]++;
      }
    }
  topSort();
  int ans = calc(N - 1, M - 1);
  for (int i = 1; i <= K; ++i)
    ans = sub(ans, mul(Dp[i], calc(N - U[i], M - V[i])));
  printf("%d\n", ans);
}

int main() {
  init();
  solve();
  return 0;
}


Measured memory_bytes: 40192
def main():
    # n = int(input())
    # h, w, k = map(int, input().split())
    # a = list(map(int, input().split()))
    s = input()
    ans = ""
    for i in s:
        if i == "1":
            ans += "9"
        else:
            ans += "1"
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61812
#include<cstdio>
#include<algorithm>
#include<vector>
#include <functional>
using namespace std;
 
int main(){
  int n, y, v, w, w1, i, j, k, l, ans = 0;
  vector<int> a[4];
  scanf("%d%d", &n, &y);
  for(i = 0; i < 4; i++) a[i].push_back(0);
  for(i = 0; i < n; i++){
    scanf("%d%d", &w, &v);
    if(!(i)) w1 = w;
    a[w-w1].push_back(v);
  }
  for(i = 0; i < 4; i++){
    sort(a[i].begin()+1, a[i].end(), greater<int>());
    for(j = 1; j < a[i].size(); j++) a[i][j] += a[i][j-1];
  }
  for(i = 0; w1*(i-1) <= y && i < a[0].size(); i++){
    for(j = 0; w1*i + (w1+1)*j <= y && j < a[1].size(); j++){
      for(k = 0; w1*i + (w1+1)*j + (w1+2)*k <= y && k < a[2].size(); k++){
        for(l = 0; w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l <= y && l < a[3].size(); l++){
          ans = max(ans, a[0][i] + a[1][j] + a[2][k] + a[3][l]);
        }
      }
    }
  }
  
  printf("%d", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define nl '\n'
 using namespace std;

const int mod = 998244353;
const int N = 1E5 + 1;
vector<int> g[N];
bool vis[N];
int comps;

void dfs(int node){
   vis[node] = true;
   for(int c : g[node]){
      if(!vis[c])
        dfs(c);
   }
}

int32_t main() 
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif 
  
  int n, m;
  cin >> n >> m;

  for(int i = 1; i <= m; i++){
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  for(int i = 1; i <= n; i++){
     if(!vis[i]){
        comps++;
        dfs(i);
     }
  }

  cout << comps - 1;

  return 0;
}



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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
		int v = sc.nextInt();
		int p = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = (-1)*sc.nextInt();
		Arrays.sort(a);
		for (int i = 0; i < n; i++) a[i] = (-1)*a[i];
		boolean flag = true;
		int r = n; int l = p-1;

		while(r-l > 1) {
			int mid = (r+l)/2;
			if(a[mid]+m < a[p-1]) {
				flag = false;
			}else {
				long sum = (n-mid+p-1)*m;
				for (int i = p-1; i < mid; i++) {
					sum += a[mid]+m-a[i];
				}
				if(sum < m*v) flag = false;
				else flag = true;
			}
			if(flag) l = mid;
			else r = mid;
		}

		System.out.println(l+1);
		sc.close();
	}
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int a, b; cin >> a >> b;
  if(a > 9 || b > 9)cout << -1 << endl;
  else cout << a * b << endl;
  return 0;
}


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

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	puts(abs(a-b) <= d && abs(b-c) <= d || abs(a-c) <= d ? "Yes" : "No");
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e5 + 5);
const ll MOD = (ll)(1e9 + 7);

int n;
int c[MAX_N];

map<int, ll> cnt;
ll dp[MAX_N];

ll ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    scanf("%d", &(c[i]));
  }

  c[0] = 0;

  dp[0] = 1LL;

  for (int i = 1; i <= n; ++i) {
    if (c[i - 1] != c[i]) {
      cnt[c[i]] += dp[i - 1];
      cnt[c[i]] %= MOD;
    }

    dp[i] = cnt[c[i]];
    dp[i] %= MOD;
  }

  ans = dp[n];

  printf("%lld\n", ans);

  return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

ll N, L;

void solve() {
    cin >> N >> L;
    ll a[N];
    rep(i,N) cin >> a[i];
    int flag = 0;
    int t;
    rep(i,N-1) if (a[i] + a[i+1] >= L) {
        flag = 1;
        t = i;
    }
    if (flag) {
        cout << "Possible" << endl;
        for (int i = 0; i <= t-1; ++i) cout << i+1 << endl;
        for (int i = N-2; i >= t+1; --i) cout << i+1 << endl;
        cout << t+1 << endl;
    }
    else cout << "Impossible" << endl;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
	

int32_t main() {
	boost;
	int l,r,d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i = 0;i <= r;i += d) {
		if(i>=l && i <= r)
			ans++;
	}	
	cout << ans <<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;

int main () {
  int n;
  cin >> n;
  int sum;
  int x = n / (1.08);
  sum = x * 1.08;
  if (sum == n){
    cout << x;
  } else {
    x = x + 1;
    sum = x * 1.08;
    if (sum == n){
      cout << x;
    } else {
      cout << ":(";
    }
  }

  return 0;
}

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

int main(){
  int array[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int integer;
  cin >> integer ;
  if(integer < 1 || integer > 32) return 0;
  cout << array[integer - 1] << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int x[5];
    int i;

    for (i = 0; i < 5; i++) {
        scanf("%d", &x[i]);
    }

    for (i = 0; i < 5; i++) {
        if (x[i] == 0)
            break;
    }

    printf("%d\n", i + 1);
    return 0;
}

Measured memory_bytes: 1708
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<pint> gr[100100];
lint dp[100100];
void dfs(int v,int u,lint d){
	dp[v]=d;
	rep(i,gr[v].size()){
		pint p=gr[v][i];
		if(p.fi==u) continue;
		dfs(p.fi,v,d+p.se);
	}
}
int main()
{
	int a,b,c,n,k,x,y,q;
	cin>>n;
	rep(i,n-1){
		cin>>a>>b>>c;
		gr[a].pb(mp(b,c));
		gr[b].pb(mp(a,c));
	}
	cin>>q>>k;
	dfs(k,-1,0);
	rep(i,q){
		cin>>x>>y;
		cout<<dp[x]+dp[y]<<endl;
	}
}


Measured memory_bytes: 15872
def num_of_1bit(n: int)->int:
    '''n の立っているビットを数えます。
    :param n: number
    :return: number of 1 bit
    '''
    s = 0
    while n > 0:
        s += n & 1
        n >>= 1
    return s


def diff_idx(a: int, b: int)->int:
    '''a と b のビット列を比較してビットの状態が異なる最小の
    インデックスを返します。ここで、インデックスは 2^i の i 
    に対応する。
    :param a: number 1
    :param b: number 2
    :return: index
    '''
    if a == b:
        return -1
    idx = 0
    while a > 0 or b > 0:
        if a & 1 != b & 1:
            break
        idx += 1
        a, b = a >> 1, b >> 1
    return idx


def remove_bit(n: int, idx: int)->int:
    '''n の idx 番目のビットを消去します。idx は 2^idx に対
    応します。
    ex) n = 1011011, idx = 2
    -> 101111

    :param n: number
    :param idx: index
    :return: number removed `idx`th bit
    '''
    upper = (n >> (idx+1)) << idx
    lower = n & ((1 << idx) - 1)
    return upper | lower


def insert_bit(n: int, idx: int, bit: bool)->int:
    '''n の idx 番目にビットを挿入します。
    ex) n = 101111, idx = 2, bit = True
    -> 1011111
    '''
    upper = (n >> idx) << (idx + 1)
    lower = n & ((1 << idx) - 1)
    insert = bit << idx
    return upper | insert | lower


def route(_from: int, to: int, N: int)->list:
    '''_from から to に至る N ビットの数を全て使ったルートを
    計算します。
    :param _from: start
    :param to: end
    :param N: number of bit
    :return: routes
    '''
    if N == 1:
        return [_from, to]

    di = diff_idx(_from, to)

    a = remove_bit(_from, di)
    b = remove_bit(to, di)
    c = a ^ 1

    from_bit = (_from & (1 << di)) != 0
    to_bit = (to & (1 << di)) != 0

    first_half = map(lambda x: insert_bit(x, di, from_bit), route(a, c, N-1))
    second_half = map(lambda x: insert_bit(x, di, to_bit),  route(c, b, N-1))

    return list(first_half) + list(second_half)


def diff_by_1_bit(N: int, A: int, B: int)->list:
    num_A = num_of_1bit(A)
    num_B = num_of_1bit(B)
    if abs(num_A - num_B) % 2 == 0:
        return []

    return route(A, B, N)


if __name__ == "__main__":
    N, A, B = map(int, input().split())
    ans = diff_by_1_bit(N, A, B)
    if len(ans) == 0:
        print('NO')
    else:
        print('YES')
        print(' '.join(map(str, ans)))

Measured memory_bytes: 18896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		
		if (K==1){
			
			System.out.println(0);
		}
		else{
			int even;
			int odd;
			if (K%2==0){
				even = K/2;
				odd = K/2;	
			}
			else{
				even = K/2;
				odd = K/2 + 1;
				
			}		
			System.out.println(even*odd);
			
		}
		
	}
}

Measured memory_bytes: 21844
N = int(input())
S, T = input().split()

print(''.join(S[i] + T[i] for i in range(N)))

# 上のワンライナーを長ったらしく書くとこう
# ans = str()
# for i in range(n):
#     ans += s[i]
#     ans += t[i]

# print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

typedef pair<int, int> P;
vector<int> v[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[b].push_back(a);
    }
    rep(i, N) sort(v[i].begin(), v[i].end());
    int ans = 0;
    int last = -1;
    rep(i, N) {
        if(v[i].size() == 0) continue;
        if(last < v[i].back()) {
            ans++;
            last = i - 1;
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 8048
#include<bits/stdc++.h>
using namespace std;
double dp[3001][3001];
double solve(vector<double> &ar, int i, int x)
{
    if(x==0)return 1;
    if(i==0)return 0;
    if(dp[i][x]>-0.9)return dp[i][x];
    return dp[i][x] =  ar[i]*solve(ar, i-1, x-1) + (1-ar[i])*solve(ar, i-1, x);
}
int main()
{
    int n;
    cin>>n;
    memset(dp, -1, sizeof(dp));
    vector<double> ar(n+1);
    for(int i =1; i<n+1; ++i )
    {
        cin>>ar[i];
    }
    cout<< setprecision(16) << solve(ar, n, (n+1)/2);
}

Measured memory_bytes: 74340
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define sz(x) (int)x.size()
#define aint(v) v.begin(), v.end()
#define x first
#define y second
#define in(x) cin >> x;
#define inde(x) ll (x); cin >> x;
#define rep(ai, j, k) for(ll ai=j; ai<k; ai++)
#define sep(ai, j, k) for(ll ai=j; ai>=k; ai--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inputarr(x,y) for(int ai=0; ai<y; ai++) {cin >> x[ai];}
#define inpprefixarr(arr,y) cin>> arr[0]; for(ll ai=1;ai<y;ai++) {ll temp; cin >> temp; arr[ai]= temp + arr[ai-1];}

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watcharrsz(x) cout << (#x) << " starts:\n"; for(int ai=0;ai<sz(x);ai++) {cout << x[ai]<<" ";} cout << "\n" << (#x) << "ends\n";
#define watcharr(x,n) cout << (#x) << " starts:\n"; for(int ai=1;ai<=n;ai++) {cout << x[ai]<<" ";} cout << "\n" << (#x) << "ends\n";
#define watchg(x,n,y) cout << (#x) << " starts:\n"; for(int ai=0; ai<=n; ai++) {cout << (ai) << ":"; for(int aj=0; aj<x[ai].size();aj++) {cout << x[ai][aj]<< y;} cout << "\n";}cout << "\n"<< (#x) << "ends\n";
#define watch2darr(x,m,n,y) cout << (#x) << " starts:\n"; for(int ai=1;ai<=m;ai++) { for(int aj=1;aj<=n;aj++) {cout << x[ai][aj]<< y;} cout << "\n";}cout << "\n"<< (#x) << "ends\n";

#define print(x,y) cout << (x) << y;
#define printarrsz(x,y) for(int ai=0; ai<sz(x); ai++) {cout << x[ai]<< y;} cout << "\n";
#define printarr(x,n,y) for(int ai=0; ai<n; ai++) {cout << x[ai]<< y;} cout << "\n";
#define print2darr(x,m,n,y) for(int ai=0;ai<m;ai++) { for(int aj=0;aj<n;aj++) {cout << x[ai][aj]<< y;} cout << "\n";}cout << "\n";
#define mod(x) = (x % m + m) % m;

const ll m = (ll)1000000007;
const ll N = 3e6+5;
const ll INF = 1ll<<63; 

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef set<ll> sl;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

typedef priority_queue<pll, vpll, greater <pll> > pqg;
/***************************Code Begins Here *****************************/


void solve()
{
    // Never use x,y here, try to use i,j in loops only
    inde(a)inde(b)inde(c);
    print(max(0ll,c-(a-b)),endl);
}

signed main()
{
    ios
    ll t=1;
    // cin>>t;

    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <climits>
#include <cstddef>

uint64_t dp[20001][256];
//     ^???????????????????????????i
//            ^y_i??????

int round(int x) {
  if (x < 0) {
    return 0;
  }
  if (x > 255) {
    return 255;
  }
  return x;
}

int main() {
  int N, M;
  while (std::cin >> N >> M) {
    if (N == 0 && M == 0) {
      break;
    }
    std::vector<int> x(N);
    std::vector<int> C(M);
    for (int i = 0; i < M; i++) {
      std::cin >> C[i];
    }
    for (int i = 0; i < N; i++) {
      std::cin >> x[i];
    }

    uint64_t inf = 1ull << 30;
    for(int i = 0; i < N + 1; i++) {
      for (int j = 0; j < 256; j++) {
        dp[i][j] = inf;
      }
    }
    dp[0][128] = 0;

    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 256; j++) {
        if (dp[i][j] == inf) {
          continue;
        }

        for(auto c : C) {
          int y = round(j + c);
          int diff = x[i] - y;
          int new_value = dp[i][j] + diff * diff;
          if (new_value < dp[i + 1][y]) {
            dp[i + 1][y] = new_value;
          }
        }
      }
    }

    int min = inf;
    for (int j = 0; j < 256; j++) {
      if (dp[N][j] < min) {
        min = dp[N][j];
      }
    }
    std::cout << min << std::endl;
  }
}

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

int main() {
  string s;
  cin  >> s;
  rep(i,s.size()-1){
    if(s[i] == 'A' && s[i+1] == 'C'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    int sum=0;
    scanf("%d",&n);
    int ara[n];
    for(int i=0;i<n;i++){
        scanf("%d",&ara[i]);
        sum+=ara[i];
    }
    sum-=n;
    printf("%d\n",sum);
}

Measured memory_bytes: 128
use std::collections::VecDeque;

fn main(){
  let hwn: Vec<usize> = read_vec();
  let h = hwn[0];
  let w = hwn[1];
  let n = hwn[2] as i32;

  let mut mp: Vec<Vec<i32>> = vec![vec![-1; w+2]; h+2];
  
  for i in 1 .. h+1 {
    let ts: String = read();
    let tv: Vec<char> = ts.chars().collect();
    
    for j in 1 .. w+1 {
      mp[i][j] = match tv[j-1] {
        'S' => { 0 },
        'X' => { -1 },
        '.' => { 10 },
        c => { c as i32 - 48 },
      };
    }
  }

  let mut ans: i32 = 0;
  
  for i in 1 .. n+1 {
    ans += path(&mp, i);
  }
  
  println!("{}", ans);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn find_index(v: &Vec<Vec<i32>>, x: i32) -> (usize, usize) {
  let h = v.len();
  let w = v[0].len();
  
  for i in 1 .. h-1 {
    for j in 1 .. w-1 {
      if v[i][j] == x {
        return (i, j);
      }
    }
  }
  
  (0, 0)
}

fn path(v: &Vec<Vec<i32>>, x: i32) -> i32 {
  let h = v.len();
  let w = v[0].len();
  
  let (si, sj) = find_index(v, x-1);

  let mut pv: Vec<Vec<i32>> = vec![vec![-1;w];h];

  pv[si][sj] = 0;

  let mut que: VecDeque<(usize, usize)> = VecDeque::new();
  que.push_back((si, sj));

  loop {
    match que.pop_front() {
      Some((i, j)) => {
        let d: i32 = pv[i][j];
        
        if v[i][j] == x {
          return d;
        }

        if v[i+1][j] != -1 && pv[i+1][j] == -1 {
          pv[i+1][j] = d + 1;
          que.push_back((i + 1, j));
        }
        if v[i-1][j] != -1 && pv[i-1][j] == -1 {
          pv[i-1][j] = d + 1;
          que.push_back((i - 1, j));
        }
        if v[i][j+1] != -1 && pv[i][j+1] == -1 {
          pv[i][j+1] = d + 1;
          que.push_back((i, j + 1));
        }
        if v[i][j-1] != -1 && pv[i][j-1] == -1 {
          pv[i][j-1] = d + 1;
          que.push_back((i, j - 1));
        }
        
      },
      None => {return 0; },
    }
  }
}



Measured memory_bytes: 13196
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}

int main()
{
	long long a, b,c;
	long long ans = 0;
	cin >> a >> b>>c;
	if((a%2 and b%2 and c%2)==0){
		ans=0;
	}else{
		
		if(a >b){
			if(a >c){
				ans=b*c;
			}else{
				ans=b*a;
			}
		}else{
			if(b> c){
				ans=a*c;
			}else{
				ans=b*a;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int gcd(int a,int b){
   if(a%b==0) return b;
   return gcd(b,a%b);
}

int main(void){
   int N;
   cin>>N;
   vector<long long> a(3*N);
   for(int i=0;i<3*N;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end(),greater<long long>());
   long long ans=0;
   int cnt=1;
   for(int i=0;i<N;i++){
      ans+=a[cnt];
      cnt+=2;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

void solve() {
    int n, h;
    cin >> n >> h;
    VI a(n), b(n);
    REP(i, 0, n) cin >> a[i] >> b[i];
    sort(all(a));
    reverse(all(a));
    sort(all(b));
    reverse(all(b));
    int cnt = 0;
    REP(i, 0, n) {
        if (b[i] <= a[0])
            break;
        if (h <= 0)
            break;
        ++cnt;
        h -= b[i];
    }
    cout << cnt + max(0, h + a[0] - 1) / a[0] << endl;
}

signed main() {
    solve();

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define readVarll(nam) ll nam; cin >> nam

ll x[20],y[20];
ll n;

ll calc1()
{
  ll ans = 0;

  return ans;
}

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

  ll ans = a * c;
  ans = max(a * d, ans);
  ans = max(b * c, ans);
  ans = max(b * d, ans);
  
  cout << fixed << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n;
  string s;
  cin >> n >> s;
  ll c = 0, s1=0,s2=0,s3=0;
  for(int i = 0;i<n;i++)
  {
      char p = s[i];
      if(p == 'R') s1++;
      if(p == 'G') s2++;
      if(p == 'B') s3++;
  }
  c += s1 * s2 * s3;
  for(int i = 0;i<n-2;i++)
  {
      for(int j = i+1;j<n-1;j++)
      {
          int k = 2 * j - i;
          if(k<n && s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) c--;
      }
  }
  cout << c << endl;
  return 0;
}



Measured memory_bytes: 3628
s = input()

if (s[0] == s[1] == s[2] == s[3]):
    print('No')
elif (s[0] == s[1] and s[2] == s[3]) or (s[0] == s[2] and s[1] == s[3]) or (s[0] == s[3] and s[1] == s[2]):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    map<int, int> counter;
    rep(i,N){
        counter[A[i]]++;
    }
    vector<int> char_count;
    int count = 0;
    for(auto c : counter){
        char_count.push_back(c.second);
        count++;
    }
    sort(char_count.begin(), char_count.end());

    ll ans = 0;
    rep(i,char_count.size()-1){
        if (count <= K) break;

        ans += char_count[i];
        count--;        
    }

    cout << ans << endl;


}


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


int LCS(const string& a, const string& b) {
    int ans = 0;
    const int len_a = a.length(), len_b = b.length();

    int dp[len_a + 1][len_b + 1] = {};
    for(int i=1; i<=len_a; i++) {
	for(int j=1; j<=len_b; j++) {
	    dp[i][j] = max(dp[i][j], dp[i-1][j] );
	    dp[i][j] = max(dp[i][j], dp[i][j-1] );
	    dp[i][j] = max(dp[i][j], dp[i-1][j-1] + (a[i-1] == b[j-1] ? 1 : 0) );
	}
    }
    ans = dp[len_a][len_b];
    return ans;
}

int main() {

    int N;
    cin >> N;

    for(int i=0; i<N; i++) {
	string a,b;
	cin >> a >> b;
	cout << LCS(a,b) << endl;
    }
    return 0;
}

Measured memory_bytes: 7084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int h, w;
char grid[1002][1002];
const int MOD = 1e9 + 7;
int dp[1003][1003];

int solve(int r, int c)
{
    if(r == h - 1 && c == w - 1)
        return 1;
    if(r > h || c > w || grid[r][c] == '#')
        return 0;
    int &ret = dp[r][c];
    if(~ret)
        return ret;
    ret = solve(r + 1, c) % MOD;;
    ret += solve(r, c + 1) % MOD;
    return ret % MOD;;
}

int main()
{
    IO;
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
            cin >> grid[i][j];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0) % MOD;
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	long long h,w,p,i,a,b,c,b1,c1,m,m1,m2,m3;
	cin >> h >> w;
	p=10000000000;
	for(i=h/3; i<=h/3+3; i++)
	{
		if(i!=0 && i<h)
		{
			a=i*w;
			b=(h-i)/2*w;
			c=(h*w-a-b);
			b1=(w/2)*(h-i);
			c1=h*w-a-b1;
			m=max(a,b);
			m1=min(a,b);
			m=max(m,c)-min(m1,c);
			m2=max(a,b1);
			m3=min(a,b1);
			m1=max(m2,c1)-min(m3,c1);
			m=min(m,m1);
			p=min(m,p);
		}
	}
	for(i=w/3; i<=w/3+3; i++)
	{
		if(i!=0 && i<w)
		{
			a=i*h;
			b=(w-i)/2*h;
			c=(h*w-a-b);
			b1=(h/2)*(w-i);
			c1=h*w-a-b1;
			m=max(a,b);
			m1=min(a,b);
			m=max(m,c)-min(m1,c);
			m2=max(a,b1);
			m3=min(a,b1);
			m1=max(m2,c1)-min(m3,c1);
			m=min(m,m1);
			p=min(m,p);
		}
	}
	cout << p;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    P a[n];
    rep(i, n){
        int s;
        cin >> s;
        a[i] = P(s, i);
    }
    sort(a, a + n);
    rep(i, n){
        cout << a[i].second + 1 << " ";
    }cout << endl;
}

Measured memory_bytes: 4264
#include <iostream>

using namespace std;

int main()
{
    int A , B ;
    cin >> A >> B ;

    if (( A == 1 ) && ( B != 1 ))
        cout << "Alice" ;

    else if  (( B == 1) && ( A != 1 ))
        cout << "Bob" ;

    else if  ( A > B )
        cout << "Alice" ;

    else if  ( A < B )
        cout << "Bob"  ;

    else
        cout << "Draw" ;


    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		switch (s[i]) {
		case '0':
			if (s[i + 1] == 'U') {
				cout << "nn";
				i++;
			}
			else cout << 'w';
			break;
		
			
		case '2':cout << 'k' ; break;
		case '3':cout << 's' ; break;
		case '4':cout << 't' ; break;
		case '5':cout << 'n' ; break;
		case '6':cout << 'h' ; break;
		case '7':cout << 'm' ; break;
		case '8':cout << 'y' ; break;
		case '9':cout << 'r' ; break;
		case 'T':cout << 'a' ; break;
		case 'L':cout << 'i' ; break;
		case 'U':cout << 'u' ; break;
		case 'R':cout << 'e' ; break;
		case 'D':cout << 'o' ; break;
		default:break;
		}


	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    vector<int> ord(n);
    rep(i,n)ord[i]=i;
    sort(ord.begin(),ord.end(),[&](int x,int y){
        return a[x]==a[y]?x>y:a[x]>a[y];
    });
    vector<ll> ans(n);
    int mi = n;
    rep(c,n){
        int i=ord[c];
        ll nxt=0;
        if(c+1<n)nxt=a[ord[c+1]];
        ll diff = a[i]-nxt;
        mi = min(i,mi);
        ans[mi] += diff*(c+1);
    }
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 2688