akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define from1(obj) obj.begin() + 1, obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbp(p) cerr << #p << ":(" << p.first << ", " << p.second << ") "
#define dbpl(p) cerr << #p << ":(" << p.first << ", " << p.second << ")\n"
#define dbt3(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ") "
#define dbt3l(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ")\n"
#define dbt4(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ") "
#define dbt4l(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ")\n"
#define dbv(vec) cerr << #vec << ":{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"
#define dbvv(vv) cerr << #vv << ":{\n"; for (auto vec : vv) { cerr << "{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"; } cerr << "}\n"
#define dbm(map) cerr << #map << ":{ "; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "}\n"
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pil = pair<int, ll> ; using pll = pair<ll, ll>; using pli = pair<ll, int>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mll = map<ll, ll>; using mli = map<ll, int>;

int main() {
	const int x = 1e6;
	vi T, U;	
	for (int n = 1; ; n++) {
		int Tn = n * (n + 1) * (n + 2) / 6;
		// db(n); dbl(Tn);
		if (Tn > x) break;
		T.push_back(Tn);
		if (Tn % 2) U.push_back(Tn);
	}
	// dbv(T); dbv(U);
	// db(T.size()); dbl(U.size());
			
	vi dp(x + 1); // dp[j]:jを作るのに必要な正四面体数の個数(i番目の正四面体数T[i]までで作る場合)
	vi ep(x + 1); // dp[j]:jを作るのに必要な奇数の正四面体数の個数(i番目の奇数の正四面体数U[i]までで作る場合)
	rep(j, x + 1) { dp[j] = j; ep[j] = j; }
	// dbv(dp);
	for (int i = 0; i < T.size() and T[i] <= x; i++) {			
		rep(j, x + 1 - T[i]) {				
			dp[j + T[i]] = min(dp[j + T[i]], dp[j] + 1);				
		}
		// db(i); dbl(T[i]); dbv(dp);
	}
	// dbv(ep);
	for (int i = 0; i < U.size() and U[i] <= x; i++) {
		rep(j, x + 1 - U[i]) {
			ep[j + U[i]] = min(ep[j + U[i]], ep[j] + 1);
		}
		// db(i); dbl(U[i]); dbv(ep);
	}
	while (true) {
		int y; cin >> y;
		if (!y) break;
		cout << dp[y] << " " << ep[y] << endl;
	}
}


Measured memory_bytes: 10512
import sys
import math
import heapq
import bisect
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

X,N=LI()
L=LI()
L.sort()

# print(L)

for i in range(1000):
    ip=bisect.bisect_left(L, X+i)
    im=bisect.bisect_left(L, X-i)
    # print(i)

    res = None
    if ip >= 0 and ip < N:
        if L[ip] != X+i:
            res = X+i
    else:
        res = X+i

    if im >= 0 and im < N:
        if L[im] != X-i:
            res = X-i
    else:
        res = X-i

    if res != None:
        print(res)
        exit()


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    double v;
    while(cin >> v) {
        double t = v / 9.8;
        double y = t * t * 4.9;
        int n = 1;
        while(n * 5 - 5 < y) n++;
        P(n);
    }
    return 0;
}

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

#define int long long
#define fs first
#define sc second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define len(v) ((int)v.size())
#define vc vector
#define pr pair
#define endl "\n"
#define endd "\n"; return 0;
#define all(v) v.begin(), v.end()

using namespace std;

const int MAXN = 1e5;
const int INF = 1e10;
const int MOD = 1e9 + 7;

main() {
    ios_base::sync_with_stdio(0);
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 0; i < 100000; i++){
        if ((a * i) % b == c){
            cout << "YES" << endd;
        }
    }
    cout << "NO";
}


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

int n;
int a[2002];
int m[2][2002];

int main() {
  cin>>n>>a[0]>>a[1];
  for (int i=0; i<n; i++) cin>>a[i+2];

  for (int i=n+1; i>1; i--) {
    m[0][i] = abs(a[i-1] - a[n+1]);
    for (int j=n+1; j>i; j--) {
      m[0][i] = max(m[1][j], m[0][i]);
    }
    m[1][i] = abs(a[i-1] - a[n+1]);
    for (int j=n+1; j>i; j--) {
      m[1][i] = min(m[0][j], m[1][i]);
    }
  }
  cout<<m[0][2]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
const double PI = acos(-1);

int main(){
	double R;
	cin >> R;
	double ans = 2 * PI * R;
	//cout << ans << endl;
	printf("%.20lf",ans);
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll a, b, x;
  cin >> a >> b >> x;
  a--;
  ll mi = a/x+1;
  ll pl = b/x+1;
  // cerr << a << " " << b << " " << mi << " " << pl << endl;
  ll ans;
  if(a != -1)ans = pl - mi;
  else ans = pl;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <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...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll D, c[33], s[444][33], t[444], last[33] = {};
set<ll> s1[33], s2[33];

// vector<ll> score(ll t[]) {
//     ll i, j, sc = 0;
//     vector<ll> v;
//     v.pb(0);
//     for (i = 1; i <= D; i++){
//         sc += s[i][t[i]];
//         last[t[i]] = i;
//         for (j = 1; j <= 26;j++)
//             sc -= c[j] * (i - last[j]);
//         v.pb(sc);
//     }
//     return v;
// }

ll cost(ll k, ll dis){
    return k * dis * (dis - 1) / 2;
}

ll eval(ll d, ll q){
    ll bq = t[d];
    ll b = *s1[bq].upper_bound(d);
    ll a = *s2[bq].upper_bound(-d);
    ll sc = 0;
    sc -= s[d][bq];
    sc += s[d][q];
    ll l = d + a, r = b - d;
    sc += cost(c[bq], l);
    sc += cost(c[bq], r);
    sc -= cost(c[bq], l + r);
    b = *s1[q].upper_bound(d);
    a = *s2[q].upper_bound(-d);
    l = d + a, r = b - d;
    sc -= cost(c[q], l);
    sc -= cost(c[q], r);
    sc += cost(c[q], l + r);
    return sc;
}

int main(){
    ll i, j;
    cin >> D;
    for (i = 1; i <= 26;i++)
        cin >> c[i];
    for (i = 1; i <= D;i++)
        for (j = 1; j <= 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= 26; i++){
        s1[i].insert(D + 1);
        s2[i].insert(0);
    }
    for (i = 1; i <= D;i++){
        ll ma = -1e15, p;
        for (j = 1; j <= 26; j++){
            if(c[j]*(i-last[j])+s[i][j]>ma){
                ma = c[j] * (i - last[j]) + s[i][j];
                p = j;
            }
        }
        t[i] = p;
        last[p] = i;
    }
    for (i = 1; i <= D;i++){
        s1[t[i]].insert(i);
        s2[t[i]].insert(-i);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand365(1, 365);
    ll INF = 1e9;
    double start_temp = 3000, end_temp = 0;
    for (i = 0; i < 500000; i++){
        ll ma = -1e15, p;
        ll d = rand365(mt);
        for (j = 1; j <= 26; j++){
            if(j!=t[d]){
                ll sc = eval(d, j);
                if(sc > ma){
                    ma = sc;
                    p = j;
                }
            }
        }
        double temp = start_temp + (end_temp - start_temp) * i / 100000;
        double prob = exp(ma / temp);
        if (prob > (rand() % INF) / (double)INF){
            s1[t[d]].erase(d);
            s2[t[d]].erase(-d);
            s1[p].insert(d);
            s2[p].insert(-d);
            t[d] = p;
        }
    }
    for (i = 1; i <= D;i++)
        cout << t[i] << endl;
}

Measured memory_bytes: 4492
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

struct edge{
	int a,b,c;
};

int main(){
	int n,m;
	cin>>n>>m;
	
	vector<edge> v(m);
	vvi d(n,vi(n,INF));
	REP(i,m){
		cin>>v[i].a>>v[i].b>>v[i].c;
		v[i].a--, v[i].b--;
		d[v[i].a][v[i].b]=d[v[i].b][v[i].a]=v[i].c;
	}
	
	REP(k,n)REP(i,n)REP(j,n){
		chmin(d[i][j],d[i][k]+d[k][j]);
	}
	
	int ans=0;
	REP(i,m){
		if(v[i].c>d[v[i].a][v[i].b]) ans++;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        ans=True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    ans=False
        if ans:
            print('Yes')
            exit(0)

print('No')

Measured memory_bytes: 3064
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<math.h>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	string str;
	int i;
	getline(cin,str);
	REP(i,str.size()){
		str[i]=(str[i] - 'A' - 3 + 26) % 26 + 'A';
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1168
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"YES"<<"\n"
#define         no             cout<<"NO"<<"\n"
#define         vcl            vector<ll>
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         sc             second
#define         spc            ' '
#define         nn             '\n'
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){Faysal

    ll ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    int aa[33]={0,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};
    cin>>k;
    cout<<aa[k]<<endl;
    return 0;
}


Measured memory_bytes: 256
def execute(X, K, D):
    for i in range(K):
        if X > 0:
            X -= D
        else:
            X += D

    return abs(X)

def execute2(X, K, D):
    T = int(abs(X) / D)
    if X > 0:
        if K < T:
            return X - K * D
        else:
            Y = X - T * D
            if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
    else:
        if K < T:
            return (X + K * D) * -1
        else:
            Y = X + T * D
            if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y


if __name__ == '__main__':
    X, K, D = map(int, input().split())
    print(execute2(X, K, D))

Measured memory_bytes: 9216
#include <iostream>

int main(void) {
    int D, N;

    std::cin >> D >> N;

    if(D == 0) {
        if(N <= 99)
            std::cout << N << std::endl;
        else
            std::cout << 101 << std::endl;
    }
    else if(D == 1) {
        if(N <= 99)
            std::cout << N * 100 << std::endl;
        else
            std::cout << 101 * 100 << std::endl;
    }
    else {
        if(N <= 99)
            std::cout << N * 10000 << std::endl;
        else
            std::cout << 101 * 10000 << std::endl;
    }
}


Measured memory_bytes: 256
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {

	static char[] xx = new char[] {'S','H','C','D'};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			if(n == 0 && x == 0) break;
			int count = 0;
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}

	}
}

Measured memory_bytes: 19652
/*input
aabaaa
aa
*/
#include <iostream>

  void computeLPSArray(std::string * pattern, int M, int * lps) {
    int len = 0;
    lps[0] = 0;
    int i = 1;
    while (i < M) {
      if ((*pattern)[i] == (*pattern)[len]) {
        len++;
        lps[i] = len;
        i++;
      } else {
        if (len != 0) {
          len = lps[len - 1];
        } else {
          lps[i] = 0;
          i++;
        }
      }
    }
  }

void KMPSearch(std::string *pattern, std::string *string) {
  int M = pattern->length();
  int N = string->length();
  int lps[M];
  computeLPSArray(pattern, M, lps);
  int i = 0;
  int j = 0;
  while (i < N) {
    if ((*pattern)[j] == (*string)[i]) {
      j++;
      i++;
    }
    if (j == M) {
      std::cout << i - j << std::endl;
      j = lps[j - 1];
    }

    else if (i < N && (*pattern)[j] != (*string)[i]) {
      if (j != 0)
        j = lps[j - 1];
      else
        i = i + 1;
    }
  }
}

int main() {
  std::string pattern, string;
  getline(std::cin, string);
  getline(std::cin, pattern);
  KMPSearch(&pattern, &string);
  return 0;
}


Measured memory_bytes: 3996
import numpy as np
from heapq import heappush, heappop

n, m, s, t = map(int, input().split())
G = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    G[u].append((v, a, b))
    G[v].append((u, a, b))


def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (n+1)
    dist[start] = 0
    q = [(0, start)]
    while q:
        d, v = heappop(q)
        if dist[v] < d:
            continue
        for w, *a in G[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1, w))
    return dist


d1 = np.array(dijkstra(s, 0))
d2 = np.array(dijkstra(t, 1))

# print(d1)


d = []
for i in range(n+1):
    d.append(d1[i]+d2[i])


ans = []
B = 10**15
for i in range(n):
    B = min(B, d[n-i])
    ans.append(B)
ans = ans[::-1]

for i in range(n):
    print(10**15-ans[i])


Measured memory_bytes: 71564
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

    if n == 1:
        print(1)
    else:
        L = []
        for i in range(n):
            L.append(list(range(A[i] - 1, A[i] + 2)))

        ma = L[-1][-1]
        mi = L[0][0]
        res = [0] * (ma - mi + 1)
        for l in L:
            for i in l:
                res[i - mi] += 1

        print(max(res))


if __name__ == '__main__':
    resolve()


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

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

  ll A, B; cin >> A >> B;
  ll C, K; cin >> C >> K;
  ll ans;
  if (A >= K) ans = K;
  else if (A + B >= K) ans = A;
  else ans = A - (K - A - B);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら降順)
    return *((int*)b)- *((int*)a);
}

int main(){
    int A,B;

    scanf("%d %d%*c",&A,&B);
    if((A+B) % 2 == 0){
        printf("%d\n",(A+B)/2);
    }
    else
    {
        puts("IMPOSSIBLE");
    }
    
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <stack>
#define INF (1LL<<60)
using namespace std;

typedef long long Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void visit(const Graph & g, int v, int u,
    Edges& brdg, vector< vector<int> >& tecomp,
    stack<int>& roots, stack<int>& S, vector<bool>& inS,
    vector<int>& num, int& time) {
  num[v] = ++time;
  S.push(v); inS[v] = true;
  roots.push(v);
  for(auto &e: g[v]) {
    int w = e.dst;
    if (num[w] == 0)
      visit(g, w, v, brdg, tecomp, roots, S, inS, num, time);
    else if (u != w && inS[w])
      while (num[roots.top()] > num[w]) roots.pop();
  }
  if (v == roots.top()) {
    brdg.push_back(Edge(u, v, 1));
    tecomp.push_back(vector<int>());
    while (1) {
      int w = S.top(); S.pop(); inS[w] = false;
      tecomp.back().push_back(w);
      if (v == w) break;
    }
    roots.pop();
  }
}
void bridge(const Graph& g, Edges& brdg, vector< vector<int> >& tecomp) {
  const int n = g.size();
  vector<int> num(n);
  vector<bool> inS(n);
  stack<int> roots, S;
  int time = 0;
  for(int u=0;u<n;u++) if (num[u] == 0) {
    visit(g, u, n, brdg, tecomp, roots, S, inS, num, time);
    brdg.pop_back();
  }
}

int main(){
	int i,V,E,start,goal,s,t,e;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d",&V,&E);
		Graph g(V);
		for(i=0;i<E;i++)scanf("%d%d",&s,&t),g[s-1].push_back(Edge(s-1,t-1,1)),g[t-1].push_back(Edge(t-1,s-1,1));
		Edges brdg;
		vector< vector<int> >tecomp;
		bridge(g,brdg,tecomp);
		printf("%d\n",brdg.size());
	//}
}

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

string solve(string s)
{
    auto result = string();
    for (auto c : s)
    {
        if (c == '0') result += '0';
        else if (c == '1') result += '1';
        else if (c == 'B')
        {
            if (!result.empty())
                result.pop_back();
        }
        else throw invalid_argument("Invalid command: " + to_string(c));
    }
    return result;
}

int main()
{
    string s; cin >> s;
    cout << solve(s) << endl;
}


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

const int N = 100005;
int n, q;
vector<long long> s;
long long ans[N], cnt[N];

int main() {
	scanf("%d%d", &n, &q);
	s.push_back(n); long long x;
	while (q--) {
		scanf("%lld", &x);
		while (s.size() && s.back() >= x) s.pop_back();
		s.push_back(x);
	}
	cnt[s.size() - 1] = 1;
	for (int i = s.size() - 1; i >= 0; i--) {
		long long t = s[i];
		while (t > s[0]) {
			int v = lower_bound(s.begin(), s.end(), t) - s.begin() - 1;
			cnt[v] += t / s[v] * cnt[i];
			t %= s[v];
		}
		ans[t] += cnt[i];
	}
	for (int i = n - 1; i >= 1; i--)
		ans[i] += ans[i + 1];
	for (int i = 1; i <= n; i++) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 4212
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int a,b;cin >> a >> b;
    int ans = 0;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1;;i++){
        ans += a;
        if(ans>=b){
            ans = i;
            break;
        }
        ans--;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <set>

using namespace std;

int N;

int main() {
  scanf("%d", &N);

  for (int n = 1; n <= N; n++) {
    set<pair<int, pair<int, int> > > ans;
    for (int x = 1; x*x <= n; x++) {
      for (int y = x; y*y <= n; y++) {
        for (int z = y; z*z <= n; z++) {
          long long k = x*x + y*y + z*z + x*y + y*z + z*x;
          if (k == n) {
            ans.insert(make_pair(x, make_pair(y, z)));
            ans.insert(make_pair(x, make_pair(z, y)));
            ans.insert(make_pair(y, make_pair(z, x)));
            ans.insert(make_pair(y, make_pair(x, z)));
            ans.insert(make_pair(z, make_pair(x, y)));
            ans.insert(make_pair(z, make_pair(y, x)));
          } else if (k > n) {
            break;
          }
        }
      }
    }
    printf("%d\n", ans.size());
  }
}


Measured memory_bytes: 3700
n = int(input())
s = input()
r, g, b = [], [], []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
lr, lg, lb = len(r), len(g), len(b)
ans = lr * lg * lb

for i in r:
    for j in g:
        a = 2 * j - i
        c = 2 * i - j
        if 0 <= a and a <= n-1 and s[a] == 'B':
            ans -= 1
        if 0 <= c and c <= n-1 and s[c] == 'B':
            ans -= 1
        if (i + j) % 2 == 0 and s[int((i + j) / 2)] == 'B':
            ans -= 1
print(ans)


Measured memory_bytes: 69556
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

int dp[100005][3];
void solve(){	
	int n;
	cin>>n;
	int mat[n][3];
	FOR(i, 0, n) {
		cin>>mat[i][0]>>mat[i][1]>>mat[i][2];
	}
	dp[0][0] = mat[0][0], dp[0][1] = mat[0][1], dp[0][2] = mat[0][2];
	FOR(i, 1, n){
		dp[i][0] = mat[i][0]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = mat[i][1]+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = mat[i][2]+max(dp[i-1][0], dp[i-1][1]);
	}
	int res=-1;
	FOR(i, 0, 3){
		res = max(res, dp[n-1][i]);
	}
	cout<<res<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}


Measured memory_bytes: 4992
'use strict'
 
function main(s) {
  let n = s.split("\n")[0].split('');
  let init = n.slice(0)[0];
  let end = n.slice(-1)[0];
  let num = n.length - 2;
  console.log(`${init}${num}${end}`);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

 //最大公約数求める関数
auto my_gcd(auto n , auto m){
  if(n < m){
    auto tmp = n;
    n = m;
    m = tmp;
  }
  auto l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int N,X;cin >> N >> X;
vector<int> A(N);
vector<int> B(N);
rep(i,N){
	cin >> A[i];
	B[i] = abs(X - A[i]);
}
int ans = B[0];
rep(i,N){
	ans = my_gcd(ans , B[i]);
}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		double a = scn.nextDouble();
      double b = scn.nextDouble();
      double h = scn.nextDouble();
      double m = scn.nextDouble();
      double hh = h*30 + m/2;
      double mm = m*6;
      double x = Math.abs(hh - mm);
      if(x > 180){
        x = 360 - x;
      }
 
      double cosx = Math.cos(Math.toRadians(x));
      double ans2 = a*a + b*b - 2*a*b*cosx;
      double ans = Math.sqrt(ans2);
      System.out.println(ans);
	}
}


Measured memory_bytes: 37388
using System;
using System.Collections.Generic;
using System.Linq;

namespace Volume0_0018
{
	class Program
	{
		static void Main(string[] args)
		{
			List<int> vs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

			Console.WriteLine(string.Join(" ", vs.OrderByDescending(x => x).Select(x => x.ToString())));
		}
	}
}



Measured memory_bytes: 18324
n,k = map(int, input().split())
a=list(map(int,list(input().split())))

exist = [1]
#exist.append(a[0])
ex = {}
ex[1] = 0
#ex[a[0]] = 0
if k == 1:
    print(a[0])
    exit()

cnt = 0
while(True):
    if a[exist[-1]-1] in ex:        
        idx = exist.index(a[exist[-1]-1])
        exist.append(a[exist[-1]-1])
        break
    ex[a[exist[-1]-1]] = 0
    exist.append(a[exist[-1]-1])
    
    cnt += 1
    if cnt-1 >= k-1:
        print(exist[-1])
        exit()


#k = k-idx
d = (k-idx) % (cnt-idx+1)

print(exist[d+idx])


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

vector<ll>par(2e5+10);
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=i;
  }
}

ll root(ll x) {
  if(par[x]==x) {
    return x;
  }
  else {
    return par[x]=root(par[x]);
  }
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

void unite(ll x, ll y) {
  if(same(x,y)) return;
  par[root(x)]=root(y);
}

int main() {
  ll n;
  cin >> n;
  vector<pll> x(n);
  vector<pll> y(n);
  for(ll i=0;i<n;i++) {
    ll tx, ty;
    cin >> tx >> ty;
    x[i]=pll(tx,i);
    y[i]=pll(ty,i);
  } 
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  init(n);
  priority_queue<pair<ll,pll>, vector<pair<ll,pll>>, greater<pair<ll,pll>>> q;
  for(ll i=0;i<n-1;i++) {
    q.push(pair<ll,pll>(x[i+1].first-x[i].first,pll(x[i].second,x[i+1].second)));
    q.push(pair<ll,pll>(y[i+1].first-y[i].first,pll(y[i].second,y[i+1].second)));
  }
  ll ans=0;
  while(q.size()) {
    auto p=q.top();
    q.pop();
    ll d=p.first;
    ll p1=p.second.first;
    ll p2=p.second.second;
    if(!same(p1,p2)) {
      ans+=d;
      unite(p1,p2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <numeric>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    vector<int> plus (n) ;
    vector<int> mi(n) ;
    int h ;
    for (int i = 0; i < n; i++)
    {
        cin >> h ;
        plus.at(i) = h + i+1 ;
        mi.at(i) = i+1 - h ;
    }
    vector<int> mtable(n) ;
    for (int i = 0; i < n; i++)
    {
        if (mi.at(i) > 0)
        {
            mtable.at(mi.at(i)) ++ ;
        }
        
    }
    int64_t ans = 0 ;
    for (int i = 0; i < n; i++)
    {
        if (mi.at(i) > 0)
        {
            mtable.at(mi.at(i)) --; 
        }
        if (plus.at(i) < n)
        {
            ans += mtable.at(plus.at(i)) ;
        }
        
    }
    
    cout << ans << endl ;
}

Measured memory_bytes: 5572
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>
#include <map>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<string, PII> PSI;
typedef pair<vector<int>, vector<int>> PVV;
const int INF = 1 << 29;	// 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策

const int MAX_N = 1e+5, MAX_M = 1e+5;
const int MOD = 1000000007;

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

void solve()
{
	LL A, B, C, D;
	LL CD_lcm;
	LL C_num, D_num, CD_num;

	cin >> A >> B >> C >> D;

	C_num = (LL)(B / C) - (LL)((A - 1) / C);
	D_num = (LL)(B / D) - (LL)((A - 1) / D);
	CD_lcm = C * D / gcd(C, D);
	CD_num = (LL)(B / CD_lcm) - (LL)((A - 1) / CD_lcm);

	cout << (B - A + 1) - ((C_num + D_num) - CD_num) << endl;
}

int main(void)
{
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	ll N, M;
	cin >> N >> M;
	vector<ll> H(N);
	rep(i,N) cin >> H.at(i);
	vector<ll> J(N);
	rep(i,N) J.at(i) = 0;
	ll A, B;
	
	ll count = 0;
	rep(i,M)
	{
		cin >> A >> B;
		A--;
		B--;
		if(H.at(A)>H.at(B)) J.at(B)++;
		else if(H.at(A)<H.at(B)) J.at(A)++;
		else
		{
		    J.at(A)++;
		    J.at(B)++;
		}
	}

	rep(i,N) if(J.at(i) == 0) count++;
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<string> s(n);
    for(auto&i:s)cin>>i;
    string t;
    cin>>t;
    int l=0,r=0;
    for(auto i:s){
        auto p=regex_replace(i,regex("\\?"),"a");
        auto q=regex_replace(i,regex("\\?"),"z");
        if(p<=t) l++;
        if(t<=q) r++;
    }
    for(int i=n+1-r;i<=l+1;i++){
        cout<<i<<(i==l+1?"\n":" ");
    }
}


Measured memory_bytes: 896
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;


    ll first = A * B;
    ll second = C * D;
    cout << max(first, second) << endl;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextStrArray();
  var N = one[0];
  var H = one[1];
  var alist = new Array(N);
  var blist = new Array(N);
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    alist[i] = tmp[0];
    blist[i] = tmp[1];
  }
  blist.sort(function(a,b){
  	return b - a;
  });
  var amax = Math.max.apply(null,alist);
  var output = 0;
  for(var i = 0; i < N; i++){
    if(blist[i] >= amax){
       H -= blist[i];
       output++;
       if(H <= 0){
          myout(output);
         return;
       }
    }
  }
  output += Math.ceil(H / amax);
  myout(output);
}

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

int main(){
	int N, K, index = -1, result = 300000001;
	cin >> N >> K;
	vector<int> x = vector<int>(N, 0);
	for(int n = 0; n < N; n++){
		cin >> x[n];
		if(index == -1 && x[n] > 0)index = n;
	}
	if(index == -1){
		index = N;
	}
	for(int n = 0; n <= index && n + K - 1 < N; n++){
		if(n + K - 1 < index - 1){ continue;}
		if(x[n] < 0){
			if(x[n + K - 1] < 0){
				if(result > - x[n]){
					result = - x[n];
				}
			}else{
				if(result > x[n + K - 1] - x[n] - x[n]){
					result = x[n + K - 1] - x[n] - x[n];
				}else if(result > x[n + K - 1] - x[n] + x[n + K -1]){
					result = x[n + K - 1] - x[n] + x[n + K - 1];
				}
			}
		}else{
			if(result > x[n + K -1]){
				result = x[n + K - 1];
			}
		}
		
	}
	cout << result;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	ll n;
	cin>>n;
	vector<ll> d(n,0);
	vector<vector<ll> > g(n);
	for(int i=0;i<n-1;i++){
		int s,t;
		cin>>s>>t;
		s--,t--;
		g[s].push_back(t);
		g[t].push_back(s);
		d[s]++;
		d[t]++;
	}
	vector<bool> used(n,true);
	ll res = 0;
	vector<ll> ans(n,0);
	ll m = 0;
	priority_queue<ll,vector<ll>,greater<ll> > c;
	for(ll i=0;i<n;i++){
		ll tmp;
		cin>>tmp;
		m = max(m,tmp);
		c.push(tmp);
	}
	priority_queue< ll,vector<ll>,greater<ll> > q;
	for(ll i=0;i<n;i++){
		if(d[i]==1){
			q.push(i);
		}
	}

	while(!q.empty()){
		ll now = q.top();
		q.pop();
		ans[now] = c.top();
		res+=c.top();
		c.pop();
		for(ll i = 0;i<g[now].size();i++){
			int next = g[now][i];
			d[next]--;
			if(d[next]==1){
				q.push(next);
			}
		}
	}
	cout<<res-m<<endl;
	cout<<ans[0];
	for(ll i=1;i<n;i++){
		cout<<' '<<ans[i];
	}
	cout<<endl;

	return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(100 + " " + 100);
		boolean[][] x = new boolean[100][100];
		int a = 1, b = 1;
		LOOP:for(int i = 0; i < 100; i+=2) {
			for(int j = 0; j < 100; j+=2) {
				if(a == A)
					break LOOP;
				x[i][j] = true;
				a++;
			}
		}
		LOOP:for(int i = 51; i < 100; i+=2) {
			for(int j = 0; j < 100; j+=2) {
				if(b == B)
					break LOOP;
				x[i][j] = true;
				b++;
			}
		}
		for(int i = 0; i < 100; i++) {
			for(int j = 0; j < 100; j++) {
				if(i < 50) {
					if(x[i][j])
						System.out.print(".");
					else
						System.out.print("#");
				}
				else {
					if(x[i][j])
						System.out.print("#");
					else
						System.out.print(".");
				}
			}
			System.out.println();
		}
	}

}

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

int main(){
    int x;
    cin>>x;
    int n=2;
    vector<int>ans;
    while(ans.size()<x){
        bool ng=false;
        for(int j=2; j<=sqrt(n); ++j){
            if(n%j==0)ng=true;
        }
        if(!ng)if(n%5==1)ans.push_back(n);
        n++;
    }
    rep(i,x)cout<<ans[i]<<" ";
}

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

a=[0]*n
b=[0]*n
c=[0]*n
dp=[ [0]*n for _ in range(3)]

for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())

dp[0]=[a[0], b[0], c[0]]
for i in range(1,n):
    a[i]=a[i]+max(b[i-1], c[i-1])
    b[i]=b[i]+max(a[i-1], c[i-1])
    c[i]=c[i]+max(a[i-1], b[i-1])

n=n-1

print(max(a[n], b[n], c[n]))

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

using namespace std;

const int max_n = 1000111, mod = 998244353;

int mul(int x, int y) {
    return (1LL * x * y) % mod;
}

int power(int a, int b) {
    if (b == 0) {
        return 1 % mod;
    }
    if (b % 2 == 0) {
        return power(mul(a, a), b / 2);
    }
    return mul(a, power(a, b - 1));
}

int inv(int x) {
    return power(x, mod - 2);
}

const int max_f = 2000222;

int f[max_f], rf[max_f];

void get_all_f() {
    f[0] = rf[0] = 1;
    for (int i = 1; i < max_f; ++i) {
        f[i] = mul(i, f[i - 1]);
    }
    rf[max_f - 1] = inv(f[max_f - 1]);
    for (int i = max_f - 2; i > 0; --i) {
        rf[i] = mul(i + 1, rf[i + 1]);
    }
}

int get_c(int n, int k) {
    if (n < k) {
        return 0;
    }
    return mul(f[n], mul(rf[k], rf[n - k]));
}

int n, m;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    get_all_f();
    cin >> n >> m;
    int ans = 0;
    int in = inv(n - 1);
    for (int cnt = 0; cnt <= min(m, n); ++cnt) {
        if ((m - cnt) % 2) {
            continue;
        }
        int x = m + (m - cnt) / 2;
        int add = mul(get_c(n, cnt), get_c(x + n - 1, n - 1));
        //cout << cnt << ": " << add << endl;
        ans += add;
        ans %= mod;

        int sum = 0;
        /*for (int bad = m + 1; bad <= x; ++bad) {
            sum += get_c(x - bad + n - 2, n - 2);
            sum %= mod;
        }*/
        if (m + 1 <= x) {
            sum = mul(n + x - 2 - m, f[n + x - m - 3]);
            sum = mul(sum, in);
            sum = mul(sum, rf[n - 2]);
            sum = mul(sum, rf[x - m - 1]);
        }

        int del = mul(cnt, get_c(x - m + n - 2, n - 2));
        del += mul(n, sum);
        del %= mod;
        del = mul(del, get_c(n, cnt));
        ans += mod - del;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
sx, sy, tx, ty = map(int, input().split())
directions = ['U', 'D', 'L', 'R']

print(directions[0] * (ty - sy), end='')
print(directions[3] * (tx - sx), end='')
print(directions[1] * (ty - sy), end='')
print(directions[2] * (tx - sx), end='')
print(directions[2], end='')
print(directions[0] * (ty - sy + 1), end='')
print(directions[3] * (tx - sx + 1), end='')
print(directions[1], end='')
print(directions[3], end='')
print(directions[1] * (ty - sy + 1), end='')
print(directions[2] * (tx - sx + 1), end='')
print(directions[0])


Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>

int search(const std::vector<bool>& adj, std::vector<int>& cand,
    int start, int end) {
  int cnt = 0;
  if (start == end) {
    cnt++;
  } else {
    for (int i=start; i<end; i++) {
      if (adj[cand[start-1]*end+cand[i]]) {
        std::swap(cand[start], cand[i]);
        cnt += search(adj, cand, start+1, end);
        std::swap(cand[start], cand[i]);
      }
    }
  }
  return cnt;
}

int main() {
  int N, M, a, b;
  std::cin >> N >> M;
  std::vector<bool> adj(N*N, false);
  for (int i=0; i<M; i++) {
    std::cin >> a >> b;
    adj[(a-1)*N+(b-1)] = true;
    adj[(b-1)*N+(a-1)] = true;
  }
  
  std::vector<int> cand(N);
  std::iota(std::begin(cand), std::end(cand), 0);
  std::cout << search(adj, cand, 1, N) << std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    int n;
    int total=0;

    cin>>n;
    vector<int> b(n);
    FOR(i,1,n-1){
        cin>>b[i];
    }
    total+=b[1]+b[n-1];
    FOR(i,1,n-2){
       total+=min(b[i],b[i+1]);
    }
    cout<<total<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	ar := make([]int, 11)
	ar[a]++
	ar[b]++
	ar[c]++
	if ar[5] == 2 && ar[7] == 1 {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


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

int main(){
    stack<int> t;
    while (1){
	int n;
	cin >> n;
	if (cin.eof()) break;
	if (n == 0){
	    cout << t.top() << endl;
	    t.pop();
	}
	else t.push(n);
    }
}

Measured memory_bytes: 0