akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;

/**
 *
 * @author luiscastillo
 */
public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine();
        String t = sc.nextLine();

        int[][] memo = new int[s.length() + 1][t.length() + 1];
        int max = 0;
        StringBuilder result = new StringBuilder();
        for (int i = 1; i <= s.length(); i++) {
            for (int j = 1; j <= t.length(); j++) {
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    memo[i][j] = memo[i - 1][j - 1] + 1;
                } else {
                    memo[i][j] = Math.max(memo[i - 1][j], memo[i][j - 1]);
                }
                max = Math.max(max, memo[i][j]);
            }
        }

        int i = s.length(), j = t.length();
        while (i > 0 && j > 0) {
            if (s.charAt(i - 1) == t.charAt(j - 1)) {
                result.append(s.charAt(i - 1));
                i--;
                j--;
            } else {
                if (memo[i][j] == memo[i - 1][j]) {
                    i--;
                } else {
                    j--;
                }
            }
        }
        System.out.println(result.reverse());

    }

}


Measured memory_bytes: 87096
/**
 * @Author:      G_bg
 * @DateTime:    2019-09-28 20:01:25
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
int main(int argc, const char *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin >> n;
    cout << fixed << setprecision(10) << (n+1)/2*1.0/n << endl;
    return 0;
}

Measured memory_bytes: 256
def kaibun(s):
    flg = False
    if len(s) % 2 == 0:
        if s[0:int((len(s)/2))] == s[int(len(s)/2):len(s)][::-1]:
            flg =True
    else:
        
        if s[0:int((len(s)-1)/2)] == s[int((len(s)+1)/2):len(s)][::-1]:
            flg =  True
    return flg



s = input()
ans = "No"



if kaibun(s):
    if kaibun(s[0:int((len(s)-1)/2)]) and kaibun(s[int((len(s)+1)/2):len(s)]):
        ans = "Yes"
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int MimoriSuzuko(const int* FuzitaSaki, int KatouEmiri) {
	int MidorikawaHikaru = FuzitaSaki[0];
	int TaketatuAyana;
	for (TaketatuAyana = 1; TaketatuAyana < KatouEmiri; TaketatuAyana++) {
		if (FuzitaSaki[TaketatuAyana] < MidorikawaHikaru) {
			MidorikawaHikaru = FuzitaSaki[TaketatuAyana];
		}
	}
	return MidorikawaHikaru;
}

int main(void) {
	int KitamuraEri[6];
	int AsumiKana;
	int KugimiyaRie = 0;
	for (AsumiKana = 0; AsumiKana < 6; AsumiKana++) {
		if (scanf("%d", &KitamuraEri[AsumiKana]) != 1) return 1;
		KugimiyaRie += KitamuraEri[AsumiKana];
	}
	printf("%d\n", KugimiyaRie - MimoriSuzuko(KitamuraEri, 4) - MimoriSuzuko(KitamuraEri + 4, 2));
	return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    void solve() {
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int D = in.nextInt();
        int E = in.nextInt();
        int F = in.nextInt();

        double maxDensity = 0;
        int swMax = 0;
        int sugarMax = 0;
        for(int i = 0; 100*i*A <= F; i++){
            for(int j = 0; 100*(i*A+j*B) <= F; j++){
                int water = 100*(i*A+j*B);
                int sugarLimit = (i*A+j*B)*E;

                for(int k = 0; k*C <= sugarLimit && water + k*C <= F; k++){
                    for(int l = 0; k*C + l*D <= sugarLimit && water + k*C + l*D <= F; l++){

                        int sugar = k*C + l*D;
                        double tmpDens = (double)sugar/(sugar+water);

                        if(tmpDens > maxDensity){
                            maxDensity = tmpDens;
                            swMax = sugar+water;
                            sugarMax = sugar;
                        }
                    }
                }
            }
        }

        if(sugarMax == 0){
            System.out.println(100*A + " " + sugarMax);
        }
        else {
            System.out.println(swMax + " " + sugarMax);
        }
    }


    FastScanner in;
    PrintWriter out;

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


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

  i64 cnt = 0;
  REP(i, L - 2) {
    if (s.substr(i, 3) == "ABC") {
      cnt++;
      i += 2;
    }
  }
  cout << cnt << endl;

  return 0;
}

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

int n, ans = 0;
set<vector<int> > s;
vector<int> a;

int main(){
	scanf("%d", &n);
	a = vector<int>(3);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &a[0], &a[1], &a[2]);
		sort(a.begin(), a.end());
		if (s.find(a) != s.end()) {
			ans++;
		}
		else {
			s.insert(a);
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 2912
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int dif = n - m;
		long ans = 0;
		if(dif < 0) {
			dif= dif*-1;
		}
		if(dif > 1) {
			System.out.println(ans);
		}else{
			if(dif == 0) {
				ans = 2;
			}else {
				ans = 1;
			}
			for(int i = 2; i < n+1; i++) {
				ans = ans * i % 1000000007;
			}
			for(int i = 2; i < m+1; i++) {
				ans = ans * i % 1000000007;
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int R;
    cin >> R;
    if (R >= 2800)
    {
        cout << "AGC" << endl;
    }
    else if (R >= 1200)
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
}

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

using namespace std;

class Solution {
public:
	void solve() {
		int n, m;
		cin >> n >> m;
		for(int i = 0; i < 100000; i++){
			if((i * 108)/100-i == n && (i * 110)/100-i == m){
				cout << i << endl;
				return;
			}
		}
		cout << -1 << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int result[100] = {};
	int pos = 0;
	while (1) {
		int n;
		int s[101] = {};
		int mini = 1001;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		pos++;
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		result[pos] = (total - maxi - mini) / (n - 2);
	}
	FOR(i, 1, pos) {
		cout << result[i] << endl;
	}

}


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

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

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1000005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

struct Combination{
    vector<long long> fac, finv, inv;
    Combination(int n=1001001):fac(n+1), finv(n+1), inv(n+1) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    long long operator()(int n, int k) const {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

int main(){
    int r[2], c[2];
    cin >> r[0] >> c[0] >> r[1] >> c[1];

    Combination com(2 * MAX);
    auto f = [&](int n, int m) {
        return (mint)com(n + 1, m + 1);
    };
    auto calc = [&](int m, int r, int l) {
        return f(r, m) - f(l, m);
    };

    mint ans = 0;
    for (int i = c[0]; i <= c[1]; ++i) {
        ans += calc(i, r[1] + i, r[0] + i - 1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 50164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,x,y,z,m,n;
    cin>>a>>b>>c>>d;
    m = max((a*d),(a*c));
    n = max(b*c,b*d);

    cout<< max(m,n);

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =1e6+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
//F题：C（k+s）里面选k个 *每个可能情况26种qpow(26,k) - 重复出现的字母（没想到） 

char s[MAXN];
ll fac[MAXN*2],inv[MAXN*2];
ll qpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=(ans*a)%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans%mod;
}
ll C(int i,int n)
{
	return fac[n]*inv[n-i]%mod*inv[i]%mod;
}
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	int m=strlen(s);
	ll ans=0;
	fac[0]=1;
	for(int i=1;i<=n+m;i++) fac[i]=fac[i-1]*i%mod;
	inv[n+m]=qpow(fac[n+m],mod-2);
	for(int i=n+m-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=0;i<=n;i++)
	{  
		ans=(ans+qpow(26,i)*C(m-1,n+m-1-i)%mod*qpow(25,n-i)%mod)%mod;
	}
	printf("%lld\n",ans);
} 

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

m = [0]*n
m[-1] = a[-1]
for i in range(n-2, -1, -1):
    m[i] = max(m[i+1], a[i])

p = m[0]-a[0]
ans = 1
for i in range(1, n):
    if m[i]-a[i] == p:
        ans += 1
    elif m[i]-a[i] > p:
        ans = 1
        p = m[i]-a[i]
print(ans)


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    ll N; cin>>N;
    if(N%2){
        cout << "0\n";
    }else{
        ll ans = 0;
        ll x = 10;
        while(N>=x){
            ans += N/x;
            x *= 5;
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    ll r,g,b,n,ans=0,b2;
    cin>>r>>g>>b>>n;
    for(int i=0;i*r<=n;i++){
        for(int j=0;j*g<=n;j++){
            b2=n-i*r-j*g;
            if(b2<0)break;
            if(b2%b==0){
                //cerr<<i*r<<" "<<j*g<<" "<<b2<<endl;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()

has_red = [False] * N
has_red[0] = True
box = [1] * N
for _ in range(M):
    x, y = MAP()
    x -= 1
    y -= 1
    box[x] -= 1
    box[y] += 1
    if has_red[x]:
        has_red[y] = True
    if box[x] == 0:
        has_red[x] = False

ans = 0
for i in range(N):
    if box[i] != 0 and has_red[i]:
        ans += 1
print(ans)


Measured memory_bytes: 4724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 100010

int a[SIZE] = {0};
int main() {
   int n, cnt1 = 0, cnt0 = 0, cnt2 = 0;
   scanf("%d", &n);
   for (int i = 0 ; i < n ; ++i) {
      int j;
      scanf("%d", &j);
      while (j % 2 == 0) {
         ++a[i];
         j /= 2;
      }
      if (a[i] == 1) ++cnt1;
      else if (a[i] == 0) ++cnt0;
      else ++cnt2;
   }
   if (cnt0 > cnt2 + 1) printf("No\n");
   else {
      if (cnt0 == cnt2 + 1 && cnt1 != 0) printf("No\n");
      else printf("Yes\n"); 
   }

   return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector> 
#include <functional>
#define fx(x) fixed<<setprecision(x)
#define ll long long
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
int main() {
	fast();
	int n,ac=0,wa=0,tle=0,re=0;
	cin >> n;
	string a;
	for (int i = 0;i < n;i++) {
		cin >> a;
		if (a == "AC")
			ac++;
		else if (a == "WA")
			wa++;
		else if (a == "TLE")
			tle++;
		else if (a == "RE")
			re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int count=1;
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  REP(i,N) cin >> L[i];
  int D=0;
  REP(i,N){
    D += L[i];
	if(X-D>=0){
      ++count;
    } else break;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int a,b,c,k,r;
    cin>>a>>b>>c>>k;
    r = min(a, k);
    k -= a + b;
    if(k>0)
        r -= min(c, k);
    cout << r;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define int long long 
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn=2e5+6;
const int mod=1e9+7;
const double pi = acos(-1.0);
int n,m;
int a[maxn];
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}        
void write(int x){        
    if(x < 0) {        
        putchar('-');        
        x = -x;        
    }        
    if(x > 9)        
        write(x/10);        
    putchar(x % 10 + '0');        
    return;        
}   
signed main(){
	cin>>n;
	int x;
	for(int i=2;i<=n;i++)
	   cin>>x,a[x]++;
	for(int i=1;i<=n;i++)
	   cout<<a[i]<<" ";
	return 0;
} 


Measured memory_bytes: 5176
# pragma comment(linker, "/STACK: 2000000")
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n';
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int a,b,c;
    fi>>a>>b>>c;
    if (!(a & 1) || !(b & 1) || !(c & 1))
        return puts("0") * 0;
    fo << min({1ll * a * b,1ll * b * c,1ll * a * c}) << '\n';
    return 0;
}

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

using namespace std;

int main(){
  int k, n;
  char s[55] = {'\n'};
  cin >> n >> k;
  for(int i=0; i<n; i++){
    char temp;
    cin >> temp;
    s[i] = temp;
  }

  s[k-1] = s[k-1]+6+26;

  cout << s;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a[4][11]= {0},b[4][11]= {0},c[4][11]= {0},d[4][11]= {0},i,n,j,l,f,r,v;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d %d %d %d",&l,&f,&r,&v);
        if(l==1)
        {
           a[f][r]+=v;
        }
        if(l==2)
        {
            b[f][r]+=v;
        }
        if(l==3)
        {
            c[f][r]+=v;
        }
        if(l==4)
        {
            d[f][r]+=v;
        }
    }
    for(i=1;i<=3;i++)
    {
        for(j=1;j<=10;j++)
        {
            printf(" %d",a[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(i=1;i<=3;i++)
    {
        for(j=1;j<=10;j++)
        {
            printf(" %d",b[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(i=1;i<=3;i++)
    {
        for(j=1;j<=10;j++)
        {
            printf(" %d",c[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(i=1;i<=3;i++)
    {
        for(j=1;j<=10;j++)
        {
            printf(" %d",d[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[101][101]={};
  int n,u,k,v;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      a[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++)
      cout<<a[i+1][j+1]<<' ';
    cout<<a[i+1][n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>
#include<iomanip>

using namespace std;

typedef long long ll;

int main()
{
  int n; cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {cin >> h[i];}

  int ans = 1;
  for (int i = 1; i < n; i++){
    bool is_ok = true;
    for (int j = 0; j < i; j++)
    {
      if(h[i] < h[j]) {
        is_ok = false;
        break;
      }
    }
    if(is_ok == true) ans++;
  }

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


Measured memory_bytes: 256
s=input()

m=list(s)

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

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int l[100005], r[100005], w[100005];

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int x;
	rrep(i, n) {
		cin >> x;
		w[x] = i;
		l[i] = i-1;
		r[i] = i+1;
	}

	int ans = 0;
	rrep(i, n) {
		int b = l[w[i]], a = l[b];
		int c = r[w[i]], d = r[c];
		if(b) ans += (b - a) * (c - w[i]) * i;
		if(c != n+1) ans += (d - c) * (w[i] - b) * i;
		l[c] = b;
		r[b] = c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main()
{
	long long a,b,x,p,q;
	cin>>a>>b>>x;
	if(a%x==0)
		p=a/x;
	else 
		p=a/x+1;
	q=b/x;
	cout<<q-p+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	unsigned long a;
	string bst;
	unsigned long b;
	unsigned long ans;

	cin >> a >> bst;

	b = bst[0] - '0';
	for (int i = 1; i < bst.length(); i++) {
		if (bst[i] == '.')continue;
		b *= 10;
		b = b + bst[i] - '0';
	}

	if (b == 0) {
		ans = 0;
	}
	else {
		if (bst.length() == 3) {
			b *= 10;
		}
		ans = a * b / 100;
	}
	
	cout << ans << endl;
	return 0;
}


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

int main() {
    long long N;
    long long K;
    vector<int> S;
    cin >> N >> K;

    long long syou=N,syou2;
    long long amari=0;
    int index=1;

    if (N >= K){
        while (true){
            syou2 = syou / K;
            amari = syou % K;
            /*
            cout << "S " << syou2;
            cout << " R " << amari <<endl;
            */
            S.push_back(amari);
            index++;
            syou = syou2;
            if (syou < K){
                S.push_back(syou);
                break;
            }
        }
    }

    cout << index << endl;

    /*
    for (int i=0;i<index;++i)
        cout << S[i] << " ";
    cout << endl;
    */
}

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

int main()
{
	int n, r;
	cin >> n >> r;
	if(n < 10)
	{
		cout << r+100*(10-n);
	}
	else
	{
		cout << r;
	}
}



Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int F[110];
int P[110][20];

signed main()
{   
    int N; cin>>N;
    REP(i,N) REP(j,10){
        int t; cin>>t;
        F[i]|=t<<j;
    }
    REP(i,N) REP(j,11){
        cin>>P[i][j];
    }
    
    int ans=-1e18;
    for(int S=1;S<(1<<10);S++){
        int sum=0;
        REP(i,N){
            int c=__builtin_popcount(S&F[i]);
            sum+=P[i][c];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<n); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  arr(a,3);
  sortall(a);
  uniqueall(a);
  prt(a.size());
}


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

ll powmod(int x, int y){
  ll tmp = 1;
  for(int i = 0; i < y; i++){
    tmp *= x;
    tmp = tmp % 1000000007;
  }
  return tmp;
}

int main() {

  ll N;
  cin >> N;

  if(N == 1){
    cout << 0 << endl;
  }else{
    cout << (powmod(10, N) + 2 * 1000000007 - (2 * powmod(9, N) - powmod(8, N))) % 1000000007 << endl;
  }
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[1005][1005];

int main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    rep(i,h)rep(j,w)cin >> a[i][j];
    dp[0][0]=1;
    rep(i,h)rep(j,w){
        if(a[i][j]=='.'){
            if(i!=0)dp[i][j]+=dp[i-1][j];
            if(j!=0)dp[i][j]+=dp[i][j-1];
        }
    }
    // rep(i,h){
    //     rep(j,w){
    //         cout << dp[i][j];
    //     }
    //     cout << endl;
    // }
    cout << dp[h-1][w-1].x << endl;
}

Measured memory_bytes: 9088
#include <stdio.h>

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	if(a + b == 15){
		printf("+\n");
	}
	else if(a * b == 15){
		printf("*\n");
	}
	else{
		printf("x\n");
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		long K = long.Parse(str[2]);
		long mod = 1000000007;
		long a1 = 1;
		for(var i=0;i<K-2;i++){
			a1 = a1 * (N * M - 2 - i) % mod;
			a1 = a1 * Mpow(i+1,mod-2,mod) % mod;
		}
		long ans1 = 0;
		for(var i=1;i<=N;i++){
			ans1 += a1 * i * (N-i) * M * M % mod;
		}
		long ans2 = 0;
		for(var i=1;i<=M;i++){
			ans2 += a1 * i * (M-i) * N * N % mod;
		}
		Console.WriteLine((ans1+ans2)%mod);
	}
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n,W;
	cin>>n>>W;

	vector<ll> w(n),v(n);
	for(ll i=0;i<n;++i) cin>>w[i]>>v[i];

	ll dp[W+1][n+1];
	for(ll i=0;i<=n;++i) dp[0][i] = 0;
	for(ll i=0;i<=W;++i) dp[i][0] = 0;

	for(ll i=1;i<=W;++i){
		for(ll j=1;j<=n;++j){
			if(i >= w[j-1])
				dp[i][j] = max( dp[i-w[j-1]][j-1] + v[j-1] , dp[i][j-1] );
			else
				dp[i][j] = dp[i][j-1];
		}
	}

	cout<<dp[W][n]<<"\n";

	return 0;
}

Measured memory_bytes: 82456
/* https://atcoder.jp/contests/abc169/tasks/abc169_a */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;

#define f first
#define s second 
#define forn(i, a) for (int i = 0;i < (a);++i)
#define for1(i, b) for (int i = 1; i <= (b);++i)
#define FORd(i, a) for (int i = (a)- 1;i >= 0;--i)
#define F0Rd(i, a, b) for (int i = (a)- 1;i >= (a);--i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const ll MAX = 1e18;

int main() {
	
	int n;
	cin>>n;
	vl a(n);
	forn(i, n) {
		cin>>a[i];
	}

	forn (i, n) {
		if (a[i] == 0) {
			cout<<0<<endl;
			return 0;
		}
	}

	ll ans = 1;
	forn(i, n) {
		if (a[i] <= MAX/ans) {
			ans *= a[i];
		}
		else {
			cout<<-1<<endl;
			return 0;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N; cin >> N;
	vector<int> d(N);
	REP(i, N) scanf("%d", d.begin() + i);
	
	int ans = 0;
	REP(i, N) FOR(j, i + 1, N) ans += d[i] * d[j];
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,a,b,c,t,ak,bk;
  scanf("%ld%ld%ld",&n,&a,&b);
  c=b-a;
  if(c%2==0){
    printf("%ld",c/2);
    return 0;
  }else{
    ak=a-1; bk=n-b;
    t=ak; if(bk<ak) t=bk;
    t=t+1+(c-1)/2;
    printf("%ld",t);
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>

using namespace std;

int calc_sum(vector<string> &v, int fst, int end){

}

int main(){
    string str;
    cin >> str;
    int len = str.size();
    long long ans = 0;
    for(int i=0; i < (1<<(len - 1)); ++i){

        vector<bool> yn(len+1, false);

        for(int k=0; k<len-1; k++){
            if(i & (1 << k)) yn[k+1] = true;
        }
        long long a = 0;
        for(int j=0; j<len; j++){
            if(yn[j]){
                ans += a;
                a = 0;
            }
            a *= 10;
            a += (long long)(str[j] - '0');
        }
        ans += a;
    }

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


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int N;
vector<ll> A;
vector<vector<int>> G;

ll countPairs(const vector<ll> &g) {
  ll sum = accumulate(g.begin(), g.end(), 0ll);
  ll mx = *max_element(g.begin(), g.end());
  return sum >= mx * 2 ? sum / 2 : sum - mx;
}

ll dfs(int v, int p) {
  ll a = A[v];
  vector<ll> children;
  for (int u : G[v]) {
    if (u != p) {
      ll c = dfs(u, v);
      if (c < 0) {
        return -1;
      }
      children.push_back(c);
    }
  }
  if (children.empty()) {
    return a;
  }
  ll sum = accumulate(children.begin(), children.end(), 0ll);
  ll y = sum - a;
  ll x = a - y;
  if (x < 0 || y < 0 || countPairs(children) < y) {
    return -1;
  }
  return x;
}

bool solve() {
  if (N == 2) {
    return A[0] == A[1];
  }
  int r = -1;
  for (int v = 0; v < N; v++) {
    if (G[v].size() > 1) {
      r = v;
      break;
    }
  }
  return dfs(r, -1) == 0;
}

int main() {
  cin >> N;
  A.resize(N);
  G.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cout << (solve() ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 14464
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;
import std.container;

void main() {
  auto input = readln.split.to!(int[]);
  auto N = input[0], M = input[1];
  auto A = readln.split.to!(ulong[]);

  auto maxHeap = heapify(A);

  foreach(i; 0..M) {
    auto m = maxHeap.front();
    maxHeap.removeFront();
    maxHeap.insert(m / 2);
  }

  maxHeap.sum.writeln;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
//a 普通の刀 b 投げる刀
int main() {
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    int mx = a[n-1];
    int ans = 0;
    reverse(all(b));
    rep(i,n){
        if(b[i]<= mx || h <= 0) break;
        h-=b[i];
        ans++;
    }
    if(h <= 0) { cout << ans << endl;}
    else{
        ans += (h+mx-1)/mx;
        cout << ans << endl;
    }
    return 0;   
}

Measured memory_bytes: 4052
#include<iostream>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
using namespace std;

int main() {
	int c1x, c2x, c1y, c2y, c1r, c2r;
	
	cin >> c1x >> c1y >> c1r;
	cin >> c2x >> c2y >> c2r;

	double dist;

	dist = sqrt((c1x - c2x)*(c1x - c2x) + (c1y - c2y)*(c1y - c2y));

	if (dist > c1r + c2r)	cout << "4" << endl;
	else if (dist == c1r + c2r)	cout << "3" << endl;
	else if (dist == abs(c1r - c2r))	cout << "1" << endl;
	else if (dist < abs(c1r - c2r))	cout << "0" << endl;
	else cout << "2" << endl;

}


Measured memory_bytes: 3116
S = input()
N = len(S)
plus_flag = [0] * (N - 1)


def calc(flags):
    val = 0
    num_begin_index = 0
    num_end_index = None
    for flag_index in range(len(flags)):
        if flags[flag_index] == 0:
            continue
        num_end_index = flag_index + 1
        val += int(S[num_begin_index:num_end_index])
        num_begin_index = num_end_index
    num_end_index = len(flags) + 1
    val += int(S[num_begin_index:num_end_index])
    return val


def calc_sum(index, flag):
    plus_flag[index] = flag
    if index == len(plus_flag) - 1:
        return calc(plus_flag)
    return calc_sum(index + 1, 0) + calc_sum(index + 1, 1)


if N == 1:
    print(S)
else:
    print(calc_sum(0, 0) + calc_sum(0, 1))

Measured memory_bytes: 3064
from operator import itemgetter

n,m = map(int,input().split())
pairs = []
for i in range(m):
  ai,bi = map(int,input().split())
  pairs.append([ai,bi])

pairs.sort(key=itemgetter(1))

ans = 0
curr = [0,0]
for pair in pairs:
  if not curr[1] > pair[0]:
    ans += 1
    curr = pair

print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N), Y(N), H(N);
  for (int i = 0; i < N; i++) cin >> X.at(i) >> Y.at(i) >> H.at(i);

  for (int y = 0; y <= 100; y++) {
    for (int x = 0; x <= 100; x++) {
      int h = 0;
      for (int i = 0; i < N; i++) {
        if (H.at(i) > 0) {
          int tmp = H.at(i) + abs(y - Y.at(i)) + abs(x - X.at(i));
          if (!h) h = tmp;
          else if (h != tmp) goto NG;
        }
      }
      for (int i = 0; i < N; i++) {
        if (H.at(i) == 0) {
          if (h > abs(y - Y.at(i)) + abs(x - X.at(i))) goto NG;
        }
      }
      cout << x << " " << y << " " << h << endl;
      return 0;

      NG:;
    }
  }
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

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

	reverse(all(b));
	if(a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2])
		cout << "YES" <<endl;
	else
		cout <<"NO" <<endl;

	
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
vector<int> to[55];
vector<P> cut(55);
vector<bool> visited(55, false);
int cnt;
void rec(int cur,int ban) {
    cnt++;
    visited[cur] = true;
    for(auto v : to[cur]) {
        if(visited[v]) continue;
        if((cur==cut[ban].first&&v==cut[ban].second)||(cur==cut[ban].second&&v==cut[ban].first)) continue;
        rec(v,ban);
    }
}
int main() {
    int n, m; cin >> n >> m;

    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        cut[i] = (P){a, b};
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int ans = 0;
    rep(i, m) {
        cnt = 0;
        rep(i, n+1) visited[i] = false;
        rec(0,i);
        if(cnt != n) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N;
Graph G(100010);
ll path[100010];
ll L = 0,cnt = 0;

ll D1(){
    ll res = 1;
    ll d[100010];
    fill(d,d+100010,0);
    queue<ll> Q;
    Q.push(0);
    while(Q.size()){
        ll x = Q.front();
        ll n = G[x].size();
        d[x] = 1;
        Q.pop();
        rep(i,n){
            if(!d[G[x][i]] && path[G[x][i]] != 1){
                res++;
                Q.push(G[x][i]);
            }
        }
    }
    return res;
}

ll D2(){
    ll res = 1;
    ll d[100010];
    fill(d,d+100010,0);
    queue<ll> Q;
    Q.push(N-1);
    while(Q.size()){
        ll x = Q.front();
        ll n = G[x].size();
        d[x] = 1;
        Q.pop();
        rep(i,n){
            if(!d[G[x][i]] && path[G[x][i]] != 2){
                res++;
                Q.push(G[x][i]);
            }
        }
    }
    return res;
}

bool dfs(ll x,ll m,ll p = -1){
    
    if(x == N-1){
        cnt++;
        L = m;
        path[x] = 1;
        return true;
    }
    ll n = G[x].size();
    rep(i,n){
        if(G[x][i] == p) continue;
        if(dfs(G[x][i],m+1,x)){
            m++;
            if(cnt < L / 2) path[x] = 1;
            else path[x] = 2;
            cnt++;
            return true;
        }
    }
    return 0;
}

int main(){
    cin >> N;
    rep(i,N-1){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,1,-1);
    if(D1() > D2()){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}




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

const int maxn = 405, mod = 998244353;
typedef long long ll;
int inv[maxn];

int fpow(int x, int k)
{
    int res = 1;
    while (k) {
        if (k & 1) res = (ll)res * x % mod;
        k >>= 1; x = (ll)x * x % mod;
    }
    return res;
}

int A[maxn], B[maxn], SA, SB, f[2][maxn][maxn];

int main()
{
    inv[1] = 1;
    for (int i = 2; i < maxn; i++) inv[i] = mod - 1LL * inv[mod % i] * (mod / i) % mod;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d%d", &A[i], &B[i]), SA += A[i], SB += B[i];
    f[0][0][0] = mod - 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= SA; j++)
            for (int k = 0; k <= SB; k++)
                f[1][j][k] = f[0][j][k];
        int p = 1;
        for (int l = 0; l < B[i]; l++, p = (ll)p * A[i] % mod * inv[l] % mod)
            for (int j = A[i]; j <= SA; j++)
                for (int k = l; k <= SB; k++)
                    f[0][j][k] = (f[0][j][k] + (ll)(mod - f[1][j - A[i]][k - l]) * p) % mod;
    }
    int ans = 0;
    for (int j = 1; j <= SA; j++) {
        int p = 1, q = (ll)SA * inv[j] % mod;
        for (int k = 0; k <= SB; k++, p = (ll)p * k % mod * inv[j] % mod) ans = (ans + (ll)f[0][j][k] * p % mod * q) % mod;
    }
    printf("%d\n", ans);
	
    return 0;
}


Measured memory_bytes: 1408