akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

class Insertion{
public:
  void trace(int *A, int N){
      for(int i = 0; i < N; ++i){
          if(i > 0) std::cout << " ";
          std::cout << A[i];
      }
      std::cout << std::endl;
      return;
  } 
  void insertion_sort(int *A, int N){
      for(int i = 1; i < N; ++i){
          int v = A[i];
          int j = i - 1;
          while(j >= 0 && v < A[j]){
            A[j + 1] = A[j];
            --j;
          }
          A[j + 1] = v;
          trace(A, N);
      }
  }  
};

int main(){
    Insertion ins;
    int A[100];
    int N;
    
    std::cin >> N;
    for(int i = 0; i < N; ++i){
        std::cin >> A[i];
    }
    ins.trace(A, N);
    ins.insertion_sort(A, N);
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 100005
#define MAXC 100000000000014
#define MAXV 1000000009

int n, x[MAXN], y[MAXN], t[MAXN], rec;

int main()
{
    cin >> n;
    REP(i, 1, n + 1){
        cin >> t[i] >> x[i] >> y[i];
        if(x[i] == x[i - 1] && y[i] == y[i - 1]){
            if((t[i] - t[i - 1]) % 4 == 0){
                rec++;
            }
        }
        else if((t[i] - t[i - 1]) % (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) == 0){
            rec++;
        }
    }
    if(rec < n){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;




    return 0;
}
















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

using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;

#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
 
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////



int main(){fastio
    ll n;cin>>n;
    ll p[n+1];rep(i,2,n)cin>>p[i];p[1]=0;
    ll a[n+1];rep(i,1,n)cin>>a[i];
    vector<ll>chi[n+1];
    rep(i,2,n){
        chi[p[i]].pb(i);
    }
    queue<ll>q;q.push(1);
    vector<ll>idx;
    while(!q.empty()){
        ll t=q.front();q.pop();idx.pb(t);
        for(auto x:chi[t]){
            q.push(x);
        }
    }
    reverse(idx.begin(),idx.end());
    ll ans[n+1];memset(ans,-1,sizeof(ans));
    
    for(auto x:idx){
        if(chi[x].size()==0){
            ans[x]=0;
            continue;
        }
        ll cs=chi[x].size();
        ll X=1+a[x];
        bool dp[cs+1][X];memset(dp,false,sizeof(dp));
        dp[0][0]=true;
        ll sum=0;
        rep(j,0,cs-1){
            ll y=chi[x][j];
            rep(k,0,X-1){
                if(k-a[y]>=0)dp[j+1][k]|=dp[j][k-a[y]];
                if(k-ans[y]>=0)dp[j+1][k]|=dp[j][k-ans[y]];
            }
            sum+=a[y]+ans[y];
        }
        for(ll k=X-1;k>=0;k--){
            if(dp[cs][k]){
                ans[x]=sum-k;
                break;
            }
        }
        if(ans[x]==-1){
            cout<<"IMPOSSIBLE"<<endl;return 0;
        }
    }
    //rep(i,1,n)cout<<ans[i]<<" ";cout<<endl;
    cout<<"POSSIBLE"<<endl;
    
    
    return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto& i : p) cin >> i;
    int min = p.at(0);
    int ans = 0;
    for(int i = 0; i < p.size(); i++){
        if(p.at(i) <= min){
            ans++;
            min = p.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

	int dp[s.size()][t.size()];
	pair<int,int> parent[s.size()][t.size()];

	for(int i=0; i<s.size(); i++) {
		for(int j=0; j<t.size(); j++) {
			if(s[i] == t[j]) {
				if(i > 0 && j > 0){
					dp[i][j] = 1 + dp[i-1][j-1];
					parent[i][j] = pair<int,int>(i-1,j-1);
				}
				else {
					dp[i][j] = 1;
					parent[i][j] = pair<int,int>(i,j);
				}
			}
			else {
				int op1 = j > 0 ? dp[i][j-1] : 0;
				int op2 = i > 0 ? dp[i-1][j] : 0;

				if(op1 > op2) {
					dp[i][j] = op1;
					parent[i][j] = pair<int,int>(i,j-1);
				}
				else {
					dp[i][j] = op2;
					parent[i][j] = pair<int,int>(i-1,j);	
				}
			}
		}
	}

	// printing length of LCS
	//printf("%d\n", dp[s.size()-1][t.size()-1]);

	// printing LCS itself
	int i = s.size()-1, j = t.size()-1;
	string lcs = "";

	while(true) {
		pair<int, int> par = parent[i][j];
		//printf("me=(%d,%d), par=(%d,%d)\n", i,j,par.first,par.second);

		// add to the lcs if we hit an equality cell
		if(s[i] == t[j])
			lcs = s[i] + lcs;

		if((par.first == i && par.second == j) || par.first < 0 || par.second < 0)
			break;
		
		i = par.first;
		j = par.second;
	}

	cout << lcs << endl;

	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int K,S;
    cin >> K >> S;
    int ans = 0;
    for (int i = 0; i <= K; i++){
        int x = i;
        for (int k = 0; k <= K; k++){
            int y = k;
            int z = S-x-y;
            if (z >= 0 && z <= K) ans++;
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
  int input;
  scanf("%d",&input);
  int a = input / 100;
  int c = input % 10;
  int b = (input - (100*a + c))/10;
  int box[4];
  box[0] = a;
  box[1] = b;
  box[2] = c;
  int i;
  for (i = 0; i < 3; ++i) {
    if (box[i] == 1) {
      box[i] = 9;
    } else if (box[i] == 9) {
      box[i] = 1;
    }
  }
  int output = 100*box[0] + 10*box[1] + box[2];
  printf("%d\n",output);
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    double r;
    cin >> r;
    fcout << 2 * r * M_PI << endl;

    return 0;
}


Measured memory_bytes: 3832
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  ll X[N], Y[M];
  for(int i=0;i<N;++i) cin>>X[i];
  for(int i=0;i<M;++i) cin>>Y[i];
  ll sum1 = 0;
  for(int i=1;i<M;++i) {
    sum1 += (Y[i]-Y[i-1])*(M-i)%mod*i%mod;
    sum1 %= mod;
  }
  ll ans = 0;
  for(int i=1;i<N;++i) {
    ans += (X[i]-X[i-1])*(N-i)%mod*i%mod*sum1%mod;
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5196
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const int SIZE = 9;
int T[SIZE][SIZE];
bool F[SIZE][SIZE];

void input() {
    for ( int i = 0; i < SIZE; ++ i ) {
        for ( int j = 0; j < SIZE; ++ j ) {
            cin >> T[i][j];
        }
    }
}

bool check( int r, int c ) {
    int sr = r - r % 3;
    int sc = c - c % 3;
    for ( int i = 0; i < SIZE; ++ i ) {
        if ( i != c && T[r][c] == T[r][i] ) return true;
        if ( i != r && T[r][c] == T[i][c] ) return true;
    }
    for ( int i = 0; i < 3; ++ i ) {
        for ( int j = 0; j < 3; ++ j ) {
            if ( sr + i == r && sc + j == c ) continue;
            if ( T[r][c] == T[sr+i][sc+j] ) return true;
        }
    }
    return false;
}

void solve() {
    fill( (bool*)F, (bool*)F+SIZE*SIZE, false );
    for ( int i = 0; i < SIZE; ++ i ) {
        for ( int j = 0; j < SIZE; ++ j ) {
            F[i][j] = check( i, j );
        }
    }
    for ( int i = 0; i < SIZE; ++ i ) {
        for ( int j = 0; j < SIZE; ++ j ) {
            cout << ( F[i][j] ? '*' : ' ' ) << T[i][j];
        }
        cout << endl;
    }
}

int main() {
    int n;
    while ( cin >> n ) {
        for ( int i = 0; i < n; ++ i ) {
            input();
            solve();
            if ( i + 1 < n ) cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        int ans = 0;
        int max = 0;
        for(int i = 0; i < n; i++){
            int p = Integer.parseInt(sc.next());
            ans += p;
            if(p > max){
                max = p;
            }
        }
        ans -= max/2;
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
station = (?a.ord..?z.ord).to_a + (?A.ord..?Z.ord).to_a

until gets.to_i == 0
  list_key = gets.split.map(&:to_i)
  visit_list = gets.chomp.split(//)

  visit_list.each{|i|
    goal = station.find_index(i.ord) - list_key.first
    print station.slice(goal).chr
    list_key.rotate!(1)
  }

  puts
end

Measured memory_bytes: 6120
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val x = readLine.split(" ").map(_.toInt)
  val sorted = x.sorted
  val l = sorted(n / 2 - 1)
  val r = sorted(n / 2)

  x.foreach(i => {
    if (i < r) println(r)
    else println(l)
  })
}


Measured memory_bytes: 68776
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
#include <random>
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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

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

long long lcm(long long a, long long b) {
    return a / gcd(a,b) * b;
}

int main() {

    ll N;
    cin >> N;
    ll ans = 1;
    REP(i,N) {
        ll t; cin >> t;
        ans = lcm(ans,t);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
int main(void)
{
    int N,K,Q,A;
    int buckets[100005];
    memset(buckets,0,sizeof(buckets));
    cin >> N >> K >> Q;
    for(int i=0;i<Q;i++)
    {
        cin >> A;
        buckets[A]++;
    }
    for(int i=1;i<=N;i++)
    {
        if((K+buckets[i])>Q)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int n;cin>>n;
    cout<<n/3<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    long long int x;
    cin>>x;
   for (long long  a = -200; a <= 200; a++)
    {
        for (long long b = -200; b <= 200; b++)
        {
            if (a * a * a * a * a - b * b * b * b * b == x)
            {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}
  

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> simu(N, 1);
    vector<bool> pos(N, false); pos[0] = true;
    vector<pair<int, int>> com;
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        com.emplace_back(--a, --b);
    }
    
    for (int i = 0; i < M; i++) {
        int from, to; tie(from, to) = com[i];
        if (pos[from] == true) {
            pos[to] = true;
        }
        simu[from]--; simu[to]++;
        if (simu[from] == 0) pos[from] = false;
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) if (pos[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  int N; cin >> N;
  int K; cin >> K;

  vector<ll> h(N);

  REP(i, 0, N) cin >> h[i];

  sort(h.begin(), h.end(), greater<ll>());

  ll sum = 0;

  REP(i, 0, N) {
    if (i < K) continue;

    sum += h[i];
  }

  cout << sum << endl;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    ll K;
    cin >> K;

    set<string> st;
    for (ll i = 0; i < s.size(); i++) {
        for (ll j = 1; j <= K; j++) {
            st.insert(s.substr(i, j)); 
        }
    }

    set<string>::iterator itr = next(st.begin(), K-1);
    cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
  int K,S; cin>>K>>S;
  int ans=0;

  for(int X=0;X<=K;X++){
    for(int Y=0;Y<=K;Y++){
      if(S-X-Y<=K && S-X-Y>=0){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

typedef pair<int,int> P;

bool compare_y(P a,P b){
  return a.second<b.second;
}

int sqr(int a){
  return a*a;
}

int closest_pair(P *a,int n){
  if(n<=1)return 1<<30;
  int m=n/2;
  int x=a[m].first;
  int d=min(closest_pair(a,m),closest_pair(a+m,n-m));
  inplace_merge(a,a+m,a+n,compare_y);
  vector<P> b;
  for(int i=0;i<n;i++){
    if(sqr(a[i].first-x)>=d)continue;
    for(int j=0;j<b.size();j++){
      int dx=a[i].first-b[b.size()-1-j].first;
      int dy=a[i].second-b[b.size()-1-j].second;
      if(dy*dy>=d)break;
      d=min(d,dx*dx+dy*dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

int main(){
  static P A[500000];
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i].first>>A[i].second;
  }
  sort(begin(A),begin(A)+n);
  cout<<closest_pair(A,n)<<endl;
}

Measured memory_bytes: 10704
#include <stdio.h>

int main(void)
{
	int n, a, min, max;
	long sum;
	min = 1000000;
	max = -1000000;
	sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a < min) {
			min = a;
		}
		if (a > max) {
			max = a;
		}
		sum+=a;
	}
	printf("%d %d %ld\n", min, max, sum);
}



Measured memory_bytes: 2100
from collections import defaultdict

H,W = map(int, input().split())
S = [input() for _ in range(H)]

# Aが一文字だけの場合
if H == 1 and W == 1:
    print("Yes")
    exit()

d = defaultdict(int)
for i in range(H):
    for j in range(W):
        d[S[i][j]] += 1

# 普通の回分の場合
if H == 1 or W == 1:
    # 文字列が偶数個の場合は、それぞれの文字が偶数回出現していればOK
    if H % 2 == 0 or W % 2 == 0:
        f = True
        for i in d.values():
            if i % 2 != 0:
                f = False
        print("Yes" if f else "No")
    # 文字列が奇数個の場合、一つだけ奇数個の文字がある
    else:
        cnt_odd = 0
        for i in d.values():
            if i % 2 != 0:
                cnt_odd += 1
        print("Yes" if cnt_odd == 1 else "No")
# 行列の回分の場合
# 奇数×奇数のとき、行列の縦と横の真ん中の線の交点に来る文字は奇数個でOK。交点以外の真ん中のライン上の文字は２の倍数個いる。それ以外の位置は４の倍数個いる。
# 奇数×偶数でもおんなじ感じ
# 偶数×偶数は全部４の倍数個ずつ必要
else:
    #
    cnt_m1 = 0
    cnt_m2 = 0
    cnt_m3 = 0
    for i in d.values():
        if i % 4 == 1:
            cnt_m1 += 1
        elif i % 4 == 2:
            cnt_m2 += 1
        elif i % 4 == 3:
            cnt_m3 += 1
            
    f = True
    if H % 2 == 1 and W % 2 == 1:
        if cnt_m1 + cnt_m3 != 1:
            f = False
        if cnt_m2 + cnt_m3 > (H-1)//2 + (W-1)//2:
            f = False

    elif H % 2 == 1 or W % 2 == 1:
        if cnt_m1 != 0:
            f = False
        if H % 2 == 1:
            if cnt_m2 > (W//2):
                f = False
        else:
            if cnt_m2 > (H//2):
                f = False
        if cnt_m3 != 0:
            f = False
    else:
        if cnt_m1 != 0:
            f = False
        if cnt_m2 != 0:
            f = False
        if cnt_m3 != 0:
            f = False

    print("Yes" if f else "No")


Measured memory_bytes: 3316
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Measured memory_bytes: 38576
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
  int N;
  in(N);
  ll ans =0;
  for(int i=1;i<=N;i++){
    if(i%3!=0&&i%5!=0) ans += i;
  }
  out(ans);
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,s,t) for(int (i) = (s); (i)< (t); (i)++)
#define FORR(i,s,t) for(int (i) = (s); (i) > (t); (i)--)
#define debug(x) cout<<#x<<": "<<x<<endl;

typedef long long LL;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VL> VVL;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
struct BIT {
	int N;
	int nn;
	vector<ll>data;
	BIT(int n) {
		N = n + 1;
		data = vector<LL>(N, 0);
		nn = 1;
		while (nn*2<=N)
		{
			nn *= 2;
		}
	}
	void add(int i, LL w) {
		for (int x = i; x <= N;x += x&-x) {
			data[x] += w;
		}
	}
	LL sum(int i) {
		LL ret = 0;
		for (int x = i;x > 0;x -= x&-x) {
			ret += data[x];
		}
		return ret;
	}
	LL sum(int l, int r) {
		if (l > r)return 0;
		return sum(r) - sum(l - 1);
	}
	void range_add(BIT& bity, int l, int r, LL val) {
		add(l, -val*(l - 1));
		bity.add(l, val);
		add(r + 1, val*r);
		bity.add(r + 1, -val);
	}
	LL range_sum(BIT& bity, int i) {
		return sum(i) + bity.sum(i)*i;
	}
	LL range_sum(BIT& bity, int l, int r) {
		return range_sum(bity, r) - range_sum(bity, l - 1);
	}

};

//struct seg {
//	int L, R;
//	seg() {}
//	seg(int l, int r) {
//		L = l;
//		R = r;
//	}
//	//bool operator <(const seg&x)const{
//	//	if (R == x.R)return L < x.L;
//	//	else return R < x.R;
//	//}
//	bool operator <(const seg&x)const {
//		if (L == x.L)return R < x.R;
//		else return L < x.L;
//	}
//};
typedef pair<int, int> seg;

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

	int N;cin >> N;
	vector<pll> S(N);
	vector<seg> Seg(N);
	BIT bit(100005), bit2(100005);
	FOR(i, 0, N) {
		cin >> S[i].first >> S[i].second;
		Seg[i] = seg(S[i].second - 1,S[i].first);
		bit.range_add(bit2, S[i].first, S[i].second - 1, 1);
	}
	LL ans2 = 0;
	FOR(i, 1, 100001) {
		ans2 = max(ans2, bit.range_sum(bit2, i, i));
	}

	sort(Seg.begin(), Seg.end());
	LL ans = 0;
	priority_queue<int>pq;
	for (int i = N - 1;i >= 0;i--) {
		int nowR = Seg[i].first;
		int nowL = Seg[i].second;

	//	cout << nowL << " " << nowR << endl;

		while (!pq.empty()) {
			int T = pq.top();
			if (nowR < T) {
				pq.pop();
			}
			else {
				break;
			}
		}

		ll Rcnt = pq.size();

		ll Lcnt = i - (upper_bound(Seg.begin(), Seg.begin() + i, seg(nowL-1,INF)) - Seg.begin());

		ans = max(ans, Rcnt + Lcnt + 1);
		//cout << " ==== " << endl;
		//debug(Rcnt);
		//debug(Lcnt);
//		debug(ans);

		pq.push(nowL);
	}
//	debug(ans);
//	debug(ans2);
	cout << ans << " " << ans2 << endl;
	return 0;
}



Measured memory_bytes: 10060
#include <stdio.h>

int main(void)
{
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(x-r<0 || W<x+r)
    printf("No\n");

  else if(y-r<0 || H<y+r)
    printf("No\n");

  else
    printf("Yes\n");

  return 0;
}

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

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

    ll x;
    cin >> x;

    int ans = 0;
    ll sum = 0;
    REP(i, x + 1) {
        sum += i;
        if (sum >= x) {
            ans = i;
            break ;
        }
    }

    cout << ans << '\n';
    return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  bool touch[s.length()+1];
  string a1 = "dream";
  string a2 = "dreamer";
  string a3 = "erase";
  string a4 = "eraser";
  for(int i = 0; i < s.length()+1; i++) {
    touch[i] = false;
  }
  touch[0] = true;
  for(int i = 0; i < s.length()+1; i++) {
    if(!touch[i]) continue;
    if(i + 5 < s.length()+1){
      bool ok = true;
      for(int j = 0; j < 5; j++) {
        if(s[j + i] != a1[j]) ok = false;
      }
      if(ok) {
        touch[i+5] = true;
      }
      ok = true;
      for(int j = 0; j < 5; j++) {
        if(s[j + i] != a3[j]) ok = false;
      }
      if(ok) {
        touch[i+5] = true;
      }
    }
    if(i + 7 < s.length()+1){
      bool ok = true;
      for(int j = 0; j < 7; j++) {
        if(s[j + i] != a2[j]) ok = false;
      }
      if(ok) {
        touch[i+7] = true;
      }
    }
    if(i + 6 < s.length()+1){
      bool ok = true;
      for(int j = 0; j < 6; j++) {
        if(s[j + i] != a4[j]) ok = false;
      }
      if(ok) {
        touch[i+6] = true;
      }
    }
  }
  if(touch[s.length()]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	a := next.String()
	b := next.String()
	if a == "H" {
		if b == "H" {
			fmt.Println("H")
		} else {
			fmt.Println("D")
		}
	} else {
		if b == "H" {
			fmt.Println("D")
		} else {
			fmt.Println("H")
		}
	}

}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a []int) int {
	r := 0
	for i := 0; i < len(a); i++ {
		r += a[i]
	}
	return r
}

func pow(a []int) int {
	r := 1
	for i := 0; i < len(a); i++ {
		r *= a[i]
	}
	return r
}

func fill(a []int, n int) []int {
	for i := 0; i < len(a); i++ {
		a[i] = n
	}
	return a
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

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

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) String() string {
	return s.next()
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Ints(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = s.Int()
	}
	return r
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<stdio.h>
typedef long long ll;
main(){
  ll a[10];
  ll b;
  ll i,j;
  while(scanf("%lld",&b)!=EOF){
    for(i=9;i>=0;i--){
      a[i]=b%10;
      b=b/10;
    }
    for(i=9;i>0;i--){
      for(j=0;j<i;j++){
	a[j]=(a[j]+a[j+1])%10;
      }
    }
    printf("%lld\n",a[0]);
  }
  return 0;
}

Measured memory_bytes: 0
X,Y,Z,K=map(int, raw_input().split())
A=map(int, raw_input().split())
B=map(int, raw_input().split())
C=map(int, raw_input().split())

L=[]
for a in A:
	for b in B:
		L.append(a+b)

L.sort(reverse=True)
L=L[:K]

L2=[]
for ab in L:
	for c in C:
		L2.append(ab+c)

L2.sort(reverse=True)

for i in range(K):
	print L2[i]

Measured memory_bytes: 155080
// A - Connection and Disconnection
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll opeCounter(string &S, int K){
	string T=S; while(--K) T += S;
	ll c = 0; for(int i=1; i<T.size(); ++i) if(T[i-1] == T[i]) c++, i++;
	return c;
}

int main(){
  string S; int K; cin>>S>>K;
	ll s1 = opeCounter(S, 1);
	ll s2 = opeCounter(S, 2);
	int i=1; while(i<S.size() && S[0]==S[i++]);
  cout<< (i==S.size()? S.size() * K / 2: (s2 - s1) * (K - 1) + s1) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg = 100000000007;
#define ff(i,n) for(i=0;i<n;i++)
ll row[300001]; 
int main()
{
    ll kamal;
    kamal = 1;
    while(kamal--)
    {
    	ll i,j,h,w,m;
		cin>>h>>w>>m;
		vector<set<ll> >adj(w);
		ff(i,m)
		{
			ll a,b;
			cin>>a>>b;
			row[a-1]++;
			adj[b-1].insert(a-1);	
		}
		vector<pair<ll,ll> >vec;
		ff(i,h)			
			vec.pb(mp(row[i],i));
		sort(vec.begin(),vec.end());
		ll ans = 0;
		ff(i,w)
		{
			ll e = adj[i].size(),add = 0;
			for(j=vec.size()-1;j>=0;j--)
			{
				if(adj[i].find(vec[j].second)!=adj[i].end())
				{
					add = max(add,vec[j].first-1);
				}
				else
				{
					add = max(add,vec[j].first);
					break;
				}
			}
			ans = max(ans,e+add);
		}		    
		cout<<ans<<endl;
    }
    return 0;
} 

Measured memory_bytes: 42104
A = [list(map(int, input().split())) for _ in range(3)]
punch = [[0] * 3 for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
Yes = 0
for i in range(3):
    for j in range(3):
        for k in range(N):
            if b[k] == A[i][j]:
                punch[i][j] = 1
                break
if punch[0][0] == 1:
    if punch[0][1] == 1:
        if punch[0][2] == 1:
            Yes = 1
if punch[0][0] == 1:
    if punch[1][1] == 1:
        if punch[2][2] == 1:
            Yes = 1
if punch[0][0] == 1:
    if punch[1][0] == 1:
        if punch[2][0] == 1:
            Yes = 1
if punch[1][0] == 1:
    if punch[1][1] == 1:
        if punch[1][2] == 1:
            Yes = 1
if punch[2][0] == 1:
    if punch[2][1] == 1:
        if punch[2][2] == 1:
            Yes = 1
if punch[2][0] == 1:
    if punch[1][1] == 1:
        if punch[0][2] == 1:
            Yes = 1
if punch[0][1] == 1:
    if punch[1][1] == 1:
        if punch[2][1] == 1:
            Yes = 1
if punch[0][2] == 1:
    if punch[1][1] == 1:
        if punch[2][0] == 1:
            Yes = 1
if punch[0][2] == 1:
    if punch[1][2] == 1:
        if punch[2][2] == 1:
            Yes = 1
            
if Yes == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3192
#include <cstdint>
#include <vector>
#include <cassert>

namespace Wheel {
  static constexpr uint64_t miniprimes[] = {2, 3, 5, 7, 11, 13};
  static std::vector<int> diff;
  struct Initializer {
    Initializer() {
      uint64_t prev = 17;
      for(uint64_t i = 17 + 1; i <= 17 + 2 * 3 * 5 * 7 * 11 * 13; ++i) {
        auto checker = [](uint64_t i){
          for(uint64_t p : miniprimes) {
            if( i % p == 0 ) return true;
          }
          return false;
        };
        if( checker(i) ) continue;
        diff.push_back(i - prev);
        prev = i;
      }
    }
  } initializer;
  static bool isprime(uint64_t x) {
    for(uint64_t p : miniprimes) {
      if( p == x ) return true;
      if( x % p == 0 ) return false;
    }
    assert( x >= 17 );
    for(uint64_t p = 17;;) {
      for(std::size_t k = 0; k < diff.size(); ++k) {
        if( x == p ) return true;
        if( x % p == 0 ) return false;
        p += diff[k];
        if( p >= (1ULL << 32) ) return true;
        if( p * p > x ) return true;
      }
    }
    return true;
  }
};
#include <cstdio>

int main() {

  int n;
  scanf("%d", &n);
  int res = 0;
  for(int i = 0; i < n; ++i) {
    uint64_t x;
    scanf("%lu", &x);
    if( Wheel::isprime(x) ) res += 1;
  }
  printf("%d\n", res);

  
  return 0;
}

Measured memory_bytes: 2712
using System;
using System.Linq;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            string res = FindAlpfa(n);
            Console.WriteLine(res);
        }

        private static string FindAlpfa(long n)
        {
            long thischar = 0;
            if (n % 26 == 0){
                thischar = 26;
            }
            else{
                thischar = n % 26;
            }

            if (n == thischar){
                return ((char)(thischar + 96)).ToString();
            }

            return FindAlpfa((n - thischar) / 26) + ((char)(thischar + 96)).ToString();
        }
    }

}

Measured memory_bytes: 27268
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0; i<(lli)(n); i++)
#define repf(i, n) for(lli i=1; i<(lli)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n;
    cin >> n;
    vector<lli> a(n);
    rep(i, n) cin >> a[i];
    lli ans = 0;
    // 0~60ビットの位置ごとに"0"か"1"かをカウント
    rep(bit, 60){
        // チェックする位置にマスクをセット
        lli mask = (1LL<<bit);
        lli cnt0 = 0; // 0の数
        lli cnt1 = 0; // 1の数
        rep(i, n){
            if(a[i]&mask) cnt1++;
            else cnt0++;
        }
        ans += ((mask%MOD * cnt1%MOD) % MOD * cnt0%MOD) % MOD;
    }
    cout << ans%MOD << endl;
}

Measured memory_bytes: 2560
terms = [int(i) for i in input().split(" ")]
scores = [int(i) for i in input().split(" ")]

N = terms[0]
K = terms[1]

tempScore = []
scoreSet = []

for i in range(N-K):
    if scores[i] < scores[i+K]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 31536
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

############
############
############

N, M = l_inpl()
D = [0] * (N+1)
for _ in range(M):
    li, ri = l_inpl()
    li, ri = li-1, ri-1
    D[li] += 1
    D[ri+1] -= 1

for i in range(1, len(D)):
    D[i] += D[i-1]

ans_l = D[:len(D)-1]
print(ans_l.count(M))

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

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    rep(i, 0, a+1){
        rep(j, 0, b+1){
            rep(k, 0, c+1){
                if(500*i + 100*j + 50*k == x) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var n []byte
	fmt.Scan(&n)

	switch n[len(n)-1] {
	case '3':
		fmt.Println("bon")
	case '0', '1', '6', '8':
		fmt.Println("pon")
	default:
		fmt.Println("hon")
	}
}


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

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

  int cnt = 0;
  for (int i = 0; i < s.size(); ++i)
  {
    if (s[i] == 'p')
      cnt++;
  }
  cout << (s.size() - 2 * cnt) / 2 << endl;

  return 0;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
X = [0 for i in range(N)]
S = 0
A2n = 0
for i in range(N):
    S += A[i]
    if i % 2 == 1:
        A2n += A[i]
X[0] = S - 2 * A2n
print(X[0], end=" ")
for i in range(1, N):
    X[i] = 2 * (A[i - 1] - int(X[i - 1] / 2))
    if i == N:
        print(X[i], end="")
    else:
        print(X[i], end=" ")

Measured memory_bytes: 14028
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn main() {
    let n: usize = read();
    let h: usize = read();
    let mut aseq = vec![0; n];
    let mut bseq = vec![0; n];
    for i in 0..n {
        aseq[i] = read();
        bseq[i] = read();
    }
    let mut ans = 0;
    let mut sum = 0;
    aseq.sort();
    bseq.sort();
    aseq.reverse();
    bseq.reverse();
    for i in 0..n {
        if sum < h && aseq[0] < bseq[i] {
            ans += 1;
            sum += bseq[i];
        }
    }
    if sum < h {
        ans += (h - sum + aseq[0] - 1) / aseq[0];
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
a, b, c, x, y = map(int, input().split())
price = a * x + b * y

for i in range(0, max(2*x + 1, 2*y + 1), 2):
    price_new = int(max(a * (x - i/2), 0) + max(b * (y - i/2), 0) + c * i)
    if price > price_new:
        price = price_new
print(price)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main (){
    int N;
    cin >> N;
    vector<string> s;
    for (int i = 0;i<N;i++){
        string str;
        cin >> str;
        s.push_back(str);
       
    }
    int maxim = 0;
    sort(s.begin(), s.end());
    int count = 1;
    for (size_t i = 0; i < s.size()-1; i++)
    {
     if(s[i]==s[i+1])count++; 
     else count = 1; 
     maxim = max(count,maxim);
    }
    count = 1;
    for (size_t i = 0; i < s.size()-1; i++){
        if(s[i]==s[i+1])count++; 
        else count = 1; 
        if(count == maxim){
            cout  << s[i] << endl;
        }
    }
    if(maxim == 1){
        cout << s[s.end()-s.begin()-1] << endl;
    }


    

  
    return 0;
}

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

using ll=long long;

const int MAX = 2200000;
const long long MOD = 1000000007;
long long INF = 90000000001000;

long long fac[MAX], finv[MAX], inv[MAX];

unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

vector<ll> enumDivisor(ll n){
    vector<ll> res;
    for(ll i=1; i*i<=n; ++i){//nの二乗根まで調べれば良い。
        if(n%i != 0) continue;//割り切れない場合
        res.push_back(i);//割り切れたらresにいれる
        if(i*i != n) res.push_back(n/i);//二乗根じゃない場合もう片方の約数もいれる。
    }
    return res;
}


int main() {
ll n,mx,mn=15; cin >> n;


 for(ll i=1; i*i<=n; ++i){//nの二乗根まで調べれば良い。
        if(n%i != 0) continue;//割り切れない場合
        mx = max(i,n/i);
        mx = GetDigit(mx);
        mn = min(mn,mx);
    }
cout << mn;
return 0;
}




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

int main() {
  string T;
  cin >> T;
  string ans = "No";
  if (T.at(1) == T.at(2)) {
    if (T.at(0) == T.at(1) || T.at(2) == T.at(3)) {
      ans = "Yes";
    } 
  }
        
  cout << ans << endl;
  
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B, K int
	fmt.Scanf("%d %d %d", &A, &B, &K)

	if A > K {
		fmt.Println(A-K, B)
	} else if A+B > K {
		fmt.Println(0, A+B-K)
	} else {
		fmt.Println(0, 0)
	}
}


Measured memory_bytes: 512
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
W = iil()
sW = sum(W)
div = 0
for i in W:
    div += i
    if div > (sW+1)//2:
        print(min(2*div-sW, sW-2*(div-i)))
        exit()

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

using namespace std;

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


Measured memory_bytes: 3644
#include <stdio.h>
//#include <string.h>

int main(void){
  
  int a,b,c,d,e,k = 0; 
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &k);
  
  if(k<e-a) printf(":(");
  else printf("Yay!");


  return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int c[n],a[n],b[n];
    vector<vector<int> > v(n);
    for(int i=0;i<n-1;i++){
    	cin>>a[i]>>b[i];
    	a[i]--,b[i]--;
    	v[a[i]].pb(b[i]);
    	v[b[i]].pb(a[i]);
    }
    bool maki[n];
    memset(maki,0,sizeof(maki));
    int ans[n];
    queue<int> q;
    int index=0;
    for(int i=0;i<n;i++)cin>>c[i];
    sort(c,c+n);
    reverse(c,c+n);
    q.push(0);
    while(!q.empty()){
    	int now=q.front();
    	q.pop();
    	ans[now]=c[index];
    	index++;
    	maki[now]=true;
    	for(auto& i:v[now]){
    		if(!maki[i])q.push(i);
    	}
    }
    int sum=0;
    for(int i=0;i<n-1;i++){
    	sum+=min(ans[a[i]],ans[b[i]]);
    }
    cout << sum<<endl;
    for(int i=0;i<n;i++){
    	cout << ans[i] <<" ";
    }
    cout << endl;

    return 0;
}


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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a + b + c >= 22){
    cout << "bust\n";
  }
  else{
    cout << "win\n";
  }
  return 0;
}

Measured memory_bytes: 256
N,L = map(int,input().split())
ans = 101
all_sum = 0
for i in range(N):
    if ans > abs(L+i):
        ans = abs(L+i)
for i in range(N):
    if abs(L+i) == ans:
        continue
    else :
        all_sum += (L+i)
print(all_sum)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		try {
			while (input.ready()) {
				String[] dataStr = input.readLine().split(" ");
				int[] dataInt = new int[dataStr.length];
				for (int i = 0; i < dataStr.length; i++) {
					dataInt[i] = Integer.valueOf(dataStr[i]);
				}
				System.out.println(getGCD(dataInt[0], dataInt[1]) + " " + getLCM(dataInt[0], dataInt[1]));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/***
	 * ?????§??¬?´???°
	 */
	public static int getGCD(int a, int b) {
		if (a == b)
			return a;
		int d = 1;
		if (a < b) {
			if (b % a == 0)
				return a;
			d = a / 2 + 1;
		} else {
			if (a % b == 0)
				return b;
			d = b / 2 + 1;
		}
		for (int i = d; i > 0; i--) {
			if ((a % i == 0) & (b % i == 0)) {
				return i;
			}
		}
		return 0;
	}

	/***
	 * ????°???¬?????°
	 *
	 * @param a
	 * @param b
	 * @return
	 */
	public static int getLCM(int a, int b) {
		int productA = a;
		int productB = b;
		while (productA <= 2000000000) {
			if (productA == productB) {
				return productA;
			}
			if (productA < productB) {
				productA += a;
			} else {
				productB += b;
			}
		}
		return 0;
	}
}

Measured memory_bytes: 25096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,M;
    cin >> N >> M;
    rep(i,M){
        int A;
        cin >> A;
        N -= A;
    }
    if (N < 0) cout << -1 << endl;
    else cout << N << endl;
}



Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
	int i,j,H,W,dp[50][50],a[50][50],S1,S2;
	char ch[50][50];
	
	scanf("%d%d",&H,&W);
	for(i=0;i<=H-1;i++)
	{
		scanf("%s",ch[i]);
	}
	for(i=0;i<=H-1;i++)
	{
		for(j=0;j<=W-1;j++)
		{
			a[i][j]=ch[i][j]-'0';
		}
	}
	dp[0][0]=0;
	for(i=1;i<=W-1;i++)
	{
		dp[0][i]=dp[0][i-1]+a[0][i];
	}
	for(i=1;i<=H-1;i++)
	{
		dp[i][0]=dp[i-1][0]+a[i][0];
	}
	for(i=1;i<=H-1;i++)
	{
		for(j=1;j<=W-1;j++)
		{
			S1=dp[i][j-1]+a[i][j];
			S2=dp[i-1][j]+a[i][j];
			if(S1>S2)
			{
				dp[i][j]=S2;
			}
			else
			{
				dp[i][j]=S1;
			}
		}
	}
	printf("%d\n",dp[H-1][W-1]);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b, ab, x, y;
    cin >> a >> b >> ab >> x >> y;
    ll ans = 0;
    while (x > 0 and y > 0)
    {
        x--;
        y--;
        ans += min(2*ab, a + b);
    }
    while (x > 0)
    {
        x--;
        ans += min(a, 2*ab);
    }
    while (y > 0)
    {
        y--;
        ans += min(b, 2*ab);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256