akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e6 + 10;
int n, m, k, cnt, ans;
char mz[10][10], tmp[7][7];
bool vis[2][10];
void dfs(int r, int c) {
	if (r == n + 1 && c == m + 1) {
		for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)tmp[i][j] = mz[i][j];
		for (int i = 1; i <= n; i++) {
			if (vis[0][i]) {
				for (int j = 1; j <= m; j++)tmp[i][j] = '.';
			}
		}
		for (int j = 1; j <= m; j++) {
			if (vis[1][j]) {
				for (int i = 1; i <= n; i++)tmp[i][j] = '.';
			}
		}
		int ct = 0;
		for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)if (tmp[i][j] == '#')ct++;
		if (ct == k)ans++;
		return;
	}
	if (r == n + 1) {
		vis[1][c] = 1;
		dfs(r, c + 1);
		vis[1][c] = 0;
		dfs(r, c + 1);
	}
	else {
		vis[0][r] = 1;
		dfs(r + 1, c);
		vis[0][r] = 0;
		dfs(r + 1, c);
	}
}
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf(" %c", &mz[i][j]);
			if (mz[i][j] == '#')cnt++;
		}
	}
	dfs(1, 1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3824
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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 all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,C;
  cin>>A>>B>>C;
  if(C-(A-B)>=0)
    cout<<C-(A-B)<<endl;
  else
    cout<<0<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  int n,d;
  cin>>n>>d;
  int ans=n/(d*2+1);
  if(n%(d*2+1)!=0)ans++;
  cout<<ans<<endl;
  
	return 0;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            // ostr << " " << *itr;
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]={x,y}; v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n, k, c;
    cin >> n >> k >> c;
    vc s(n);
    cin >> s;

    ll p=0, q=n-1;
    vll l, r, v;
    REP(i,k){
        while(s[p]=='x') p++;
        l.emplace_back(p+1);
        p+=c+1;
        while(s[q]=='x') q--;
        r.emplace_back(q+1);
        q-=c+1;
    }
    sort(r);
    // set_intersection(all(l), all(r), back_inserter(v));
    REP(i,k) if(l[i]==r[i]) cout << l[i] << endl;
    return 0;
}


Measured memory_bytes: 5092
(defun main ()
  (let ((k (read))
        (a (read))
        (b (read))
        (ans "NG"))
    (loop :while (<= a b)
       :do (progn (when (zerop (rem a k))
                    (setf ans "OK")
                    (return))
                  (incf a)))
    (format t "~a~%" ans)))

(main)


Measured memory_bytes: 23432
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;

///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// ⸜( ⌓̈ )⸝ ///
int main() {
    string S;
    cin >> S;
    if (S[S.length() - 1] != 's'){
        S += 's';
    }else{
        S += "es";
    }
    cout << S << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int N; 
ll Z, W; 
std::vector<ll> a;
std::vector<ll> dp[2];

// maenohito < k made hiita
ll sol(int k, int z, int w, bool isX) {
  if ( k >= N ) return std::abs(z-w);
  if ( dp[isX][k] != -1e11 ) return dp[isX][k];

  ll has = 0;
  if ( isX ) {
    has = -1e10;
    for(int i=k; i<N; i++) chmax(has, sol(i+1, a[i], w, !isX));
  }
  else {
    has =  1e10;
    for(int i=k; i<N; i++) chmin(has, sol(i+1, z, a[i], !isX));
  }
  return dp[isX][k] = has;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::cin >> N;  a.resize(N); dp[0].resize(N+1, -1e11); dp[1].resize(N+1, -1e11);
  std::cin >> Z >> W;
  rep(i,N) std::cin >> a[i];

  std::cout << sol(0, Z, W, true) << std::endl;
  
  return 0;
}


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

using namespace std;

int main()
{
   int n;
   cin>>n;
   int A[n];
   for(int i=0;i<n;i++)
   cin>>A[i];
   bool b=1;
   int tot=0;
   for(int i=1;i<n;i++)
   {
       if(b==1 && A[i]==A[i-1])
       {
           tot++;
           b=0;
       }
       else b=1;
   }
   cout<<tot;
   return 0;
}

Measured memory_bytes: 256
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        // final String N = sc.next();
        final int R = sc.nextInt();
        final int G = sc.nextInt();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println(G * 2 - R);

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int b;
    cin >> b;
    int k;
    cin >> k;
    long long s = 0;
    long long s2 = 0;
    vector <int> d(b);
    for(int i = 0; i < b; ++i)cin >> d[i];
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());
    for(int i = 0; i < b; ++i){
        int c = d[i]; 
        s += c;
        if(i < k){
            s2 += c;
        }
    }
    cout << s-s2 << '\n';
}


Measured memory_bytes: 1024
/* ex4_3
   kohei_suzuki */

#include <stdio.h>

/* プロトタイプ宣言 */
int snowfall(int height1, int height2);

int main(void){

    int low_height, high_height;
    int ans;
    scanf("%d %d",&low_height, &high_height) ;

    ans = snowfall(low_height, high_height);
    printf("%d\n",ans);
}

/* 関数の定義 */
int snowfall(int height1, int height2){
    int diff, snow_height=0;


    for(diff = height2 - height1; diff !=0; diff--){
        snow_height += diff;
    }
    snow_height = snow_height - height2;
    return snow_height;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    string s[n];
    rep(i, n) {
        cin >> s[i];
    }
    vector<P> v[4];
    rep(i, n) {
        int now = 0, mn = 0;
        rep(j, s[i].size()) {
            if (s[i][j] == '(')
                now++;
            else
                now--;
            mn = min(mn, now);
        }
        if (mn == 0)
            v[0].emplace_back(abs(mn), now);
        else if (now >= 0)
            v[1].emplace_back(abs(mn), now);
        else if (now != mn)
            v[2].emplace_back(abs(mn), now);
        else
            v[3].emplace_back(abs(mn), now);
    }
    int now = 0;
    rep(i, v[0].size()) {
        now += v[0][i].second;
    }
    sort(ALL(v[1]));
    rep(i, v[1].size()) {
        if (now - v[1][i].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        now += v[1][i].second;
    }
    rep(i, v[2].size()) {
        if (now - v[2][i].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        now += v[2][i].second;
    }
    rep(i, v[3].size()) {
        if (now - v[3][i].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        now += v[3][i].second;
    }
    if (now == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 42476
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	ans := -1
	for i := 1; i*i <= m; i++ {
		if m%i != 0 {
			continue
		}

		if i*n <= m && i > ans {
			ans = i
		}
		j := m / i
		if j*n <= m && j > ans {
			ans = j
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2!=0)
  {
    cout<<"No"<<endl;
    return 0;
  }
  string t;
  for (int i = 0; i < n/2; ++i)
  {
    t+=s[i];
  }
  if(s==t+t)
  {
    cout<<"Yes";
  }
  else cout<<"No";
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b = 0,c = 0;
  rep(i,3){
    cin >> a;
    if(a == 5){
      ++b;
    }
    else++c;
  }
  if(b == 2 && c == 1) cout << "YES"<<endl;
  else cout << "NO"<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int a, b, c;

  scanf("%d%d%d", &a, &b, &c);

  if(a >= b){
    if(a >= c){
      printf("%d", b + c);
    }else{
      printf("%d", b + a);
    }
  }else if(b >= a){
    if(b >= c){
      printf("%d", a + c);
    }else{
      printf("%d", a + b);
    }
  }else if(c >= a){
    if(c >= b){
      printf("%d", b + a);
    }else{
      printf("%d", a + c);
    }
  }
  printf("\n");
  
}


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

using namespace std;

const int N = 1e5 + 5;
int n, m, deg[N], p[N];
vector <int> ad[N];

main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n + m - 1; ++i) {
		int u, v;
		cin >> u >> v;
		ad[u].push_back(v);
		deg[v]++;
	}
	queue <int> q;
	for(int i = 1; i <= n; ++i) if(!deg[i]) q.push(i);
	while(!q.empty()) {
		int u = q.front(); q.pop();
		for(auto &v : ad[u]) {
			deg[v]--;
			if(!deg[v]) {
				p[v] = u;
				q.push(v);
			}
		}
	}
	for(int i = 1; i <= n; ++i) cout << p[i] << '\n';
}

Measured memory_bytes: 7040
#include<iostream>
#include<set>
#define LL long long
using namespace std;
int N;
LL K;
int A[200010];
int trace[200010];
int main() {
    cin >>N >> K;
    for(int i=1; i<=N; i++) {
        cin>>A[i];
    }

    set<int> s;

    // 找到环始点
    s.insert(1);
    int i=1;
    for(;;) {
       i = A[i];
       if(s.count(i)) break; 
       s.insert(i);
    }
//    cout <<"loop start:"<< i << endl;

    // 计算环长度
    LL len = 0; trace[0] = i;
    int j = i;
    for(;;) {
        j=A[j];
        trace[++len] = j;
        if(j==i) break;
    }
//    cout<<"loop size:" << len << endl;

    // 计算1到环始点的个数
    LL t = 0;
    if(i!=1) {
        j=1; t = 1;
        for(;;) {
            j=A[j];
            if(j==i) break;
            ++t;
        }
    }
 //   cout << "1-loop:" << t << endl;

    // 计算答案
    if(K<=t) {
        j=1;
        for(;;) {
            j=A[j];
            --K;
            if(K==0) {
                cout <<j<<endl;
                break;
            }
        }
    }else {
        cout << trace[(K-t)%len]<< endl;
    }
    return 0;
}

Measured memory_bytes: 13736
#include <iostream>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

struct Vec2 {
  int x;
  int y;
};

int max_dist(vector<vector<char>> &m, Vec2 &msize, Vec2 src) {
  if (m[src.y][src.x] == '#') {
    return -1;
  }

  vector<vector<bool>> visited(msize.y, vector<bool>(msize.x, false));
  queue<pair<Vec2, int>> q;
  q.push({{src.x, src.y}, 0});

  int ans = -1;
  while (!q.empty()) {
    auto pos = q.front().first;
    auto depth = q.front().second;
    q.pop();

    if (visited[pos.y][pos.x]) {
      continue;
    }
    visited[pos.y][pos.x] = true;
    ans = max(ans, depth);

    // up, down, left, right
    if (pos.y > 0 && m[pos.y - 1][pos.x] == '.') {
      q.push({{pos.x, pos.y - 1}, depth + 1});
    }
    if (pos.y < m.size() - 1 && m[pos.y + 1][pos.x] == '.') {
      q.push({{pos.x, pos.y + 1}, depth + 1});
    }
    if (pos.x > 0 && m[pos.y][pos.x - 1] == '.') {
      q.push({{pos.x - 1, pos.y}, depth + 1});
    }
    if (pos.x < m[0].size() - 1 && m[pos.y][pos.x + 1] == '.') {
      q.push({{pos.x + 1, pos.y}, depth + 1});
    }
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int h, w;
  cin >> h >> w;

  vector<vector<char>> m(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> m[i][j];
    }
  }

  int ans = 0;
  Vec2 msize{w, h};
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      ans = max(ans, max_dist(m, msize, {j, i}));
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep( i, begin, end ) for( int i = begin; i < end; i++ ) 
using namespace std;
 
map< string, string > member;
set< string > membership ;
set< string > characters;
 
void dfs( string group ){
    if( characters.count( group ) )
        return;
    characters.insert( group );
	string membergroup = member[ group ];
    rep( i, 0, membergroup.size() ) {
        if( membergroup[ i ] == '.' || membergroup[ i ] == ',') {
            membergroup[ i ] = ' ';
        }
    }
    stringstream ss(membergroup);
    for( string membergroup; ss >> membergroup; ) {
        if( member.count( membergroup ) ) {
            dfs( membergroup );
        }
        else {
            membership.insert( membergroup );
        }
    }
}
 
int main() {
    int n;
    while( cin >> n ) {
        if( n == 0 )
            break;
        string firstgroup;
        cin.ignore();
        member.clear();
        membership.clear();
        characters.clear();
        rep( i, 0, n ) {
            string input;
            getline( cin, input );
            string group = input.substr( 0, input.find( ':' ) );
            if( i == 0 ) {
                firstgroup = group;
            }
            member[ group ] = input.substr( input.find( ':' ) + 1 );
        }
        dfs( firstgroup );
        cout << membership.size() << endl;
    }
  
    return 0;
}

Measured memory_bytes: 3316
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map(String::toInt)
    val absset = readLine()!!.split(" ").map(String::toInt).map { Math.abs(it - x) }.toSet()

    val ans = absset.reduce { a, b -> gcd(a, b) }
    println(ans)
}

var memo: MutableMap<Pair<Int, Int>, Int> = mutableMapOf()
fun gcd(a: Int, b: Int): Int {
    if (b == 0) return a

    val pair = Pair(b, a % b)
    return if (memo.containsKey(pair)) {
        memo[pair]!!
    } else {
        val r = gcd(b, a % b)
        memo[pair] = r
        r
    }
}

Measured memory_bytes: 87324
n = int(input())
arr = [int(x) for x in input().split()]
m = {}
total = 0
for i, x in enumerate(arr):
    if m.get(x):
        m[x] += 1
    else:
        m[x] = 1
    total += x
for _ in range(int(input())):
    b, c = [int(x) for x in input().split()]
    if m.get(c):
        q = 1
    else:
        m[c] = 0
    if m.get(b):
        q = 1
    else:
        m[b] = 0
    total = total - (b*m[b]) + (c*m[b])
    m[c] += m[b]
    m[b] = 0
    print(total)


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

int main() {
	string s;
    getline(cin,s);
    int sum=0;
   for(int i=0;i<s.size();i++){
        int digit = s[i]-'0';
      sum+= digit;
  }
  
  if(sum%9==0){
      cout<<"Yes";
   }
  else{
      cout<<"No";
  }
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) b.rbegin(),v.rend()
typedef long long ll;
//isPrime
//modpow modinv
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n){
    cout << "x";
  }
  cout << endl;
}


Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

ll n,s=0;cin>>n;
s+=(n/500)*1000;
n=n%500;
s+=(n/5)*5;
cout<<s;

return 0;
}

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

#define f(i,a,b) for( ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based



using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 3e5+1;
const ll inf = 1e9;
const ll mod = 998244353;


int main(){
	fastio;
	string s;
	cin >> s;
	if(s[sz(s)-1] == 's' ) cout << s+"es"<< endl;
	else cout << s + "s" << endl;

	return 0;
} 

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int s=0;
    for(int i=0;i+1<n;i++)
    {
        for(int j=i+1;j<n;j++)
        s+=a[i]*a[j];
    }
    cout<<s;
}

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

del_A = [0]

for i in range(N):
    del_A.append(del_A[i] + A[i])

ans = 10**10

for i in range(1,N):
    x = del_A[i]
    y = del_A[-1] - x

    tmp = abs(x-y)

    ans = min(tmp,ans)
print(ans)


Measured memory_bytes: 24824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll a, b;
  cin >> a >> b;
  string s = to_string(b);
  ll n = a*pow(10, s.size()) + b;
  ll p = (ll)pow(n, 0.5);
  if (n == p*p) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 5001;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int mx = INF;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] <= mx) ans++;
		mx = min(a[i], mx);
	}
	cout << ans;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	solve();
}

Measured memory_bytes: 1792
#include<stdio.h>
using namespace std;
int main()
{
   int A, B;
   char op;
   scanf("%d %c %d", &A, &op, &B);
   if(op == '+'){
    printf("%d\n", A+B);
   }
   else if(op == '-'){
    printf("%d\n", A-B);
   }
   return 0;
}


Measured memory_bytes: 128
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll N;
int main() {
    cin>>N;
    ll A=N;
    ll B=0;
    while(A!=0){
    	B+=A%10;
    	if(A<10)break;
    	A=A/10;
    }

    if(N%B==0)cout<<"Yes"<<endl;
    if(N%B!=0)cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#pragma warning( disable:4996 )
using namespace std;
typedef long long ll;
typedef long long Int;
#define MOD 1000000007

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if ((a == b && a!=c) || (b == c && a!=c) || (c == a && a!=b)) {
		printf("Yes\n");
		
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
a,b,c,d=map(int,input().split())

if a<=c:
  num1=c
  
else:
  num1=a
  
if b<=d:
  num2=b
  
else:
  num2=d
  
if num1<=num2:
  print(num2-num1)
  
else:
  print(0)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

const long long mod = 1e9 + 7;

 
int main() {
	long long n, c = 0;
	cin >> n;
	vector<long long> l(n);
	for(int i = 0; i < n; ++i) cin >> l[i];
	sort(l.begin(), l.end());
	for(int i = 0; i < n; ++i)
	    for(int j = i + 1; j < n; ++j)
		    for(int z = j + 1; z < n; ++z){
			    if((l[i] < l[j] + l[z]) && (l[j] < l[i] + l[z]) && (l[z] < l[i] + l[j])) c++;
				else break;
			}
	cout << c;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double distance(double x1, double y1, double x2, double y2) {
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1,2));
}
int main(void){
    // Here your code !
    int x1, y1, x2, y2;
    double xa, ya;
    cin >> x1 >> y1 >> x2 >> y2;
    int n;
    cin >> n;
    int x[n], y[n];
    double cos;
    for(int i=0;i<n;i++) {
        cin >> x[i] >> y[i];
        if(x[i] == x1 && y[i] == y1) {
            cout << x1 << " " << y1 << endl;
            continue;
        }
        if(x[i] == x2 && y[i] == y2) {
            cout << x2 << " " << y2 << endl;
            continue;
        }
        cos = (pow(distance(x[i], y[i], x1, y1), 2) + pow(distance(x2, y2, x1, y1), 2) - pow(distance(x[i], y[i], x2, y2), 2)) / (2 * distance(x[i], y[i], x1, y1) * distance(x1, y1, x2, y2));
        xa = x1 + (x2 - x1) * (distance(x1, y1, x[i], y[i]) * cos) / (distance(x1, y1, x2, y2));
        ya = y1 + (y2 - y1) * (distance(x1, y1, x[i], y[i]) * cos) / (distance(x1, y1, x2, y2));
        if(xa > -0.00000001 && xa < 0) {
            xa = 0;
        }
        if(ya > -0.00000001 && ya < 0) {
            ya = 0;
        }
        cout << fixed
             << setprecision(10)
             << xa
             << " "
             << ya << endl;
    }
    
}

Measured memory_bytes: 3276
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
char c;
int i,j,t,sum;
vector<int>ans,a;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>c,a.pb((c-'0')),cin>>c,a.pb((c-'0')),cin>>c,a.pb((c-'0')),cin>>c,a.pb((c-'0'));
	for(i=0;i<2;i++)
	 for(j=0;j<2;j++)
	  for(t=0;t<2;t++)
	  {
	  	sum=a[0];
	  	if(!i)sum-=a[1];
	  	else sum+=a[1];
	  	if(!j)sum-=a[2];
	  	else sum+=a[2];
	  	if(!t)sum-=a[3];
	  	else sum+=a[3];
	  	if(sum==7)
		{
		  	ans.pb(i),ans.pb(j),ans.pb(t);
		  	for(i=0;i<4;i++)
			{
				cout<<a[i];
			  	if(i<3 && !ans[i])cout<<'-';
			  	else if(i<3)cout<<'+';
			}
			cout<<"=7"<<endl;
			return 0;
		}
	  }
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int X = sc.nextInt();
    int Y = sc.nextInt();
    int Z = sc.nextInt();

    sc.close();

    int result = (X - Z) / (Y + Z);

    System.out.println(result);

  }

}

Measured memory_bytes: 22996
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] org = new int[]{1, 4, 7, 9};
		int[] arr = new int[4];
		for (int i = 0; i < 4; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		for (int i = 0; i < 4; i++) {
			if (arr[i] != org[i]) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


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

struct UnionFind {
    std::vector<int> par;
  	std::vector<int> rank;
    UnionFind(int n) : par(n), rank(n) {
        for(int i = 0; i < n; i++){
          par[i] = i;
          rank[i] = 0;
        }
    }

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

    void unite(int x, int y) {
        int rx = root(x); 
        int ry = root(y);
        if (rx == ry) return;
      	if (rank[rx] < rank[ry]) {
          par[rx] = ry;
        } else {
          par[ry] = rx;
        }
      	if (rank[rx] == rank[ry]) {
          rank[rx]++;
        }
    }
};

int main() {
  int n, m;
  cin >> n;
  cin >> m;
  UnionFind tree(n);
  rep(i, m) {
    int a, b;
    cin >> a;
    cin >> b;
    tree.unite(a-1, b-1);
  }
  vector<int> res;
  rep(i, n) {
    res.push_back(0);
  }
  int maxCount = 1;
  rep(i, n) {
    int index = tree.root(i);
    res[index]++;
    maxCount = max(maxCount, res[index]); 
  }
  cout << maxCount << endl;
}



Measured memory_bytes: 5800
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	ps := make([]float64, N+1)
	for i := 1; i < N+1; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%f", &ps[i])
	}

	dp := make([][]float64, N+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]float64, N+1)
	}

	dp[0][0] = 1
	for i := 1; i < len(dp); i++ {
		dp[i][0] = dp[i-1][0] * ps[i]
	}
	for j := 1; j < len(dp); j++ {
		dp[0][j] = dp[0][j-1] * (1.0 - ps[j])
	}

	for i := 1; i < len(dp); i++ {
		for j := 1; j < len(dp); j++ {
			if i+j > N {
				break
			}
			dp[i][j] = dp[i][j-1]*(1.0-ps[i+j]) + dp[i-1][j]*ps[i+j]
		}
	}

	/*
		for i := 0; i < len(dp); i++ {
			for j := 0; j < len(dp); j++ {
				fmt.Printf("%f\t", dp[i][j])
			}
			fmt.Println()
		}
	*/

	ans := 0.0
	for i, j := N, 0; i > j; i, j = i-1, j+1 {
		ans = ans + dp[i][j]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 44672
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		String s = sc.next();
      	String ans = "NO";
		for(int i = 0; i < s.length(); i++){
          for(int j = 0; j < s.length(); j++){
        	String zen = s.substring(0,i);
            String go = s.substring(j,s.length());
            if(zen.equals("keyence") || go.equals("keyence") || (zen+go).equals("keyence")){
             ans = "YES";
            }
        }
        }
             System.out.println(ans);
     }
}

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


int dp[101][10001];
int item[101][2];
int n, w;


void makeDP(){
	for(int i = 0;i <= w;i++) dp[0][i] = 0;
	for(int i = 0;i <= n;i++) dp[i][0] = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= w;j++){
			if(j-item[i][1]>-1) dp[i][j] = max(dp[i-1][j], dp[i][j-item[i][1]]+item[i][0]);
			else dp[i][j] = dp[i-1][j];
		}
	}
}


int main(){
	cin >> n >> w;

	for(int i = 1;i <= n;i++) cin >> item[i][0] >> item[i][1];

	makeDP();

	cout << dp[n][w] << endl;

	return 0;
}

Measured memory_bytes: 7008
using System;

namespace JOI
{
    class SocialGame
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var A = int.Parse(line.Split(' ')[0]);
            var B = int.Parse(line.Split(' ')[1]);
            var C = int.Parse(line.Split(' ')[2]);
            var coin = 0;
            var days = 0;
            
            while(coin < C)
            {
                days++;
                coin += A;
                if(days % 7 == 0)
                {
                    coin += B;
                }
            }
            Console.WriteLine(days);
        }
    }
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
  if(u->left != NIL) inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL) inorder(u->right);  
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25164
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
4 2
5 2
2 1
8 3

output:
13
"""

import sys
from collections import namedtuple


def solve():
    for i, item in enumerate(item_list, 1):
        for cp in range(1, real_cp + 1):
            if item.w <= cp:
                values[i][cp] = max(values[i - 1][cp], values[i - 1][cp - item.w] + item.v)
            else:
                values[i][cp] = values[i - 1][cp]
    return values[-1][-1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_items, real_cp = map(int, _input[0].split())
    items = map(lambda x: x.split(), _input[1:])

    Item = namedtuple('Item', 'v w')
    item_list = (Item(v=int(v), w=int(w)) for v, w in items)

    values = tuple([0] * (real_cp + 1) for _ in range(c_items + 1))
    ans = solve()
    print(ans)

Measured memory_bytes: 27932
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int maxi = 1e6+10;


int main () {
  int n;
  ll result = 0;
  cin >> n;
  std::vector<int> b(n-1),a(n);
  rep(i,n-1) cin >> b[i];
  a[0] = b[0];
  rep(i,n-2) {
    a[i+1] = min(b[i], b[i+1]);
  }
  a[n-1] = b[n-2];
  rep(i,n) {
    result += a[i];
  }
  cout << result << endl;
}


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll cnt = 0;
int N, H, maxA, tmpB, tmp;
vi a, b;

void solve(){
    maxA = a[N-1];
    
    rep(i,N){
        tmpB = b[N-1-i];
        if(H <= 0) break;

        if(tmpB > maxA){
            H -= tmpB;
            cnt += 1;
        } else
            break;
    }

    if(H > 0) cnt += (H+maxA-1)/maxA;

    cout << cnt << endl;
}

int main(){
    cin >> N >> H;
    a.resize(N);
    b.resize(N);
 
    rep(i, N){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    solve();
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n, k;  cin >> n >> k;
	vector<int64_t> as(n);
	unordered_map<int, vector<int>> map;
	map[0].push_back(-1);
	int64_t sum = 0;
	int64_t ans = 0;
	FOR_LT(i, 0, n) {
		int64_t a; cin >> a;
		a--;
		a %= k;

		as[i] = a;
		sum += a;
		sum %= k;
		map[sum].push_back(i);
	}

	for (auto p : map) {
		auto vec = p.second;
		int li = 0;
		int ri = 0;
		while (li < vec.size()) {
			while (ri + 1 < vec.size() && (vec[ri + 1] - vec[li]) <= (k - 1)) ri++;
			ans += ri - li;

			li++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 19400
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int ans=0;
        
        for(int i=0; i<s.length()/2; i++){
            if(s.charAt(i)!=s.charAt(s.length()-i-1)){
                ans++;
            }
        }
        
        System.out.println(ans);
   }
}


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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int dx = x2 - x1;
	int dy = y2 - y1;
	int x3 = x2 - dy;
	int y3 = y2 + dx;
	int x4 = x3 - dx;
	int y4 = y3 - dy;

	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    N = int(input())

    print(N * (N - 1) // 2)


if __name__ == '__main__':
    main()


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

using namespace std;

int h,w;
int sy,sx,gy,gx;
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
char board[1001][1001];
int dist[1001][1001];
const int INF = 1e9;

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

	cin >> h >> w;
	cin >> sy >> sx;
	cin >> gy >> gx;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin >> board[i][j];
			dist[i][j] = INF;
		}
	}

	priority_queue <pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pque;
	dist[sy][sx] = 0;
	pque.push(make_pair(dist[sy][sx],make_pair(sy,sx)));

	while(!pque.empty())
	{
		int y = pque.top().second.first;
		int x = pque.top().second.second;
		if(dist[y][x] < pque.top().first)
		{
			pque.pop();
			continue;
		}
		pque.pop();

		for(int k=0;k<4;k++)
		{
			int ny = y + dy[k];
			int nx = x + dx[k];
			if(ny<=0 || ny>h || nx<=0 || nx>w)
			{
				continue;
			}
			if(board[ny][nx]=='.')
			{
				if(dist[ny][nx] > dist[y][x])
				{
					dist[ny][nx] = dist[y][x];
					pque.push(make_pair(dist[ny][nx],make_pair(ny,nx)));
				}
			}
		}
		for(int ny=max(1,y-2);ny<=min(h,y+2);ny++)
		{
			for(int nx=max(1,x-2);nx<=min(w,x+2);nx++)
			{
				if(board[ny][nx]=='.')
				{
					if(dist[ny][nx] > dist[y][x] + 1)
					{
						dist[ny][nx] = dist[y][x] + 1;
						pque.push(make_pair(dist[ny][nx],make_pair(ny,nx)));
					}
				}
			}
		}
	}

	if(dist[gy][gx]==1e9)
	{
		cout << -1 << '\n';
	}
	else
	{
		cout << dist[gy][gx] << '\n';
	}
	return 0;
}


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

bool cmp(const int &a, const int &b) {
    if ((a % 10) == 0) {
        return true;
    }
    
    return ((a % 10) > (b % 10));
}

int main() {
    int ct[5];
    int ans = 0;
    
    for (int i = 0; i < 5; i++) {
        cin >> ct[i];
    }
    
    sort(ct, ct + 5, cmp);
    
    for (int i = 0; i < 5; i++) {
        if (i == 4) {
            ans += ct[i];
        }
        else {
            ans += ceil(ct[i] / 10.0) * 10;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	a := n % k
	ans := min(a, abs(a-k))
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1768
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"k,s=map(int,input().split());r=k+1;print(sum(k>=s-I//r-I%r>=0for I in range(r*r)))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 8132
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int r, D, x, X[11];
	cin >> r >> D >> x;
	X[0] = x;
	for (int i = 0; i < 10; i++) {
		X[i + 1] = r * X[i] - D;
	}
	for (int i = 0; i < 10; i++) {
		cout << X[i + 1] << endl;
	}
		return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 998244353;
//const ll MOD = 1000000007;

ll dp[100010]={0};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;
  std::vector<ll> h(n);
  rep(i,0,n)std::cin>>h[i];
  dp[0]=0;
  dp[1]=(ll)abs(h[1]-h[0]);
  rep(i,2,n){
    dp[i]=std::min(dp[i-1]+(ll)abs(h[i]-h[i-1]),dp[i-2]+(ll)abs(h[i]-h[i-2]));
  }
  std::cout<<dp[n-1];
  return 0;
}

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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	// your code goes here
	string a,b,c;
	cin >> a >> b >> c;
	if(a.back() == b.front() && b.back() == c.front()) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256