akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );

			if(str.matches("^((dreamer)|(eraser)|(dream)|(erase))+$") ){
				System.out.println("YES");
			}else{
				System.out.println("NO");
				System.exit(0);
			}
		}

}


Measured memory_bytes: 38356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#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);}
long double EPS=1E-8;
////////////////////////////////////////

int main(){
    double a,b;cin>>a>>b;
    cout<<setprecision(10)<<a/b<<endl;
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

INF = 10**9

dp = [INF for i in range(n)]
dp[0] = 0

for i in range(n):
	dp[i] = min(dp[i], dp[i-1] + abs(h[i]- h[i-1]))
	if i >= 2:
		dp[i] = min(dp[i], dp[i-2] + abs(h[i]- h[i-2]))

print(dp[n-1])


Measured memory_bytes: 52728
#include<iostream>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i = 0;i < n ; i++)
	
int people[100];


bool judge(int n,int a)
{
	REP(i,n)
	{
		if(people[i] != 0 && i != a)return false;
	}
	
	return true;
}



int main()
{
	int n,p;
	
	while(cin >> n >> p,n)
	{
		int flag = false;
		REP(i,100)people[i] = 0;
		for(int i = 0;!flag;i++)
		{
			//cout << p << endl;
			if(p == 0)
			{
				p = people[ i % n ];
				people[i % n] = 0;
			}
			else
			{
				people[i % n]++;
				p--;
				if(p == 0)
				{

					if(judge(n,i%n))
					{
						flag = true;
						cout << i%n << endl;
					}
				}
			}
		}
		
	}
	
	return 0;
}
							

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int s,w;cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe\n";
    }
    else
    {
        cout<<"safe\n";
    }
    return 0;


}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
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; }

int DP[3001][3001];
int DPR[3001][3001];
int main() {
    string s, t;
    cin >> s;
    cin >> t;
    int S = s.length(), T = t.length();
    REP(i, S+1) {
        REP(j, T+1) {
            if (i == 0 || j == 0) {
                DP[i][j] = 0;
            }
        }
    }
    
    REP(i, S) {
        REP(j, T) {
            if (s[i] == t[j]) {
                DP[i+1][j+1] = DP[i][j] + 1;
                DPR[i+1][j+1] = 0;
            }
            else{
                if (DP[i+1][j] >= DP[i][j+1]){
                    DP[i+1][j+1] = DP[i+1][j];
                    DPR[i+1][j+1] = 1;
                } else {
                    DP[i+1][j+1] = DP[i][j+1];
                    DPR[i+1][j+1] = 2;
                }
                
            }
        }        
    }

    int i = S, j = T;
    string res = "";
    while(DP[i][j] > 0){
        if (DPR[i][j] == 0) {
            res = s[i-1] + res;
            i--;
            j--;
        } else if (DPR[i][j] == 1){
            j--;
        } else {
            i--;
        }
    }
    cout << res;
}

Measured memory_bytes: 70656
N = int(input())
A = [int(input()) for i in range(N)]
min_v = 1
ans = 0
for a in A:
    if a == min_v:
        min_v += 1
    elif a > min_v:
        d = (a-1)//min_v
        ans += d
        if a - d*min_v == min_v == 1:
            min_v += 1
print(ans)

Measured memory_bytes: 7080
//Yeh Toh Sahi Hoga
#include<bits/stdc++.h>
using namespace std;
//#define ll long long int
#define ld long double
#define int long long
#define pb push_back 
#define mod 1000000007
#define Z(c) (int)(c).size()
#define F first
#define S second
#define nl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define clber cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);(i)++)
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl;
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl;
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl;
#define pi 3.1415926536
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define tr(ct,it) for(typeof((ct).begin() it = (ct).begin(); it != (ct).end(); it++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;

int power(int a,int n,int lelo)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a)%lelo;
        if(n%2)
                return (a*power(a,n-1,lelo))%lelo;
        else
                return power(power(a,n/2,lelo),2,lelo)%lelo;
}


void swap(int &a,int &b)
{ int tm=a; a=b; b=tm; }

 const int N=3e5+5;

/* void dfs(int n)
 {
    chk[n]=1;
    for(int i=0;i<v[n].size();i++)
    {
      if(chk[v[n][i]]==0)
       { dfs(v[n][i]);
           
        }
    }
 }   */

void solve()
{ 
  int a,b,c; cin>>a>>b>>c;
  cout<<min(a+b,min(b+c,c+a));
}

  


signed main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
 
  int t=1;
  
//  cin>>t;
rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   solve();
   

   cout<<"\n";
  }

 return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int a,b,c;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a <<" "<< b << " "<< c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int a,b,c;

int main(){
	cin >> a >> b>> c;
	
	cout << a*b/2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define X real()
#define Y imag()
typedef complex<double> P;

int main(){
	
	const int N = 1111;
	P lis[N];
	
	P st = P(1,0);
	for(int i=0;i<N;i++){
		lis[i]=st;
		
		P dir = -st;
		dir *= P(0,-1);
		dir /= abs(dir);
		
		st += dir*P(1,0);
	}
	
	int n;
	while(cin>>n){
		if(n==-1)break;
		printf("%lf\n%lf\n",lis[n-1].X,lis[n-1].Y);
	}
	
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

int main(){
    string s,t;
    cin >> s;
    int l,m;
    l = s.size() - 2;
    m = s.size() - 1;

    string l_str;
    l_str = to_string(l);
    t = s[0] + l_str + s[m];
    cout << t;
    return 0;
}

Measured memory_bytes: 256
K = int(input())

table = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in table:
	if len(table) > K:
		break
	x = i % 10
	for j in range(max(0, x - 1), min(x + 2, 10)):
		table.append(i * 10 + j)

print(table[K - 1])

Measured memory_bytes: 7284
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


n = gif
a = gi
hash = Hash.new
data = []
a.each do |aa|
hash[aa] ||= 0
hash[aa] += 1
data << aa if hash[aa] % 2 == 0
end
data.sort!
puts data.size > 1 ? data[-1]*data[-2] : 0


Measured memory_bytes: 15596
N, Y = list(map(int, input().split()))
for n in range(N+1):
  for m in range(N-n+1):
    l=N-n-m
    sum=10000*n+5000*m+1000*l
    if sum==Y:
      print(f'{n} {m} {l}')
      exit()
print('-1 -1 -1')

Measured memory_bytes: 9168
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll n;

	cin >> n;

	ll x = 0;
	ll y = n;

	while (y > 0) {
		x += y % 10;
		y = y / 10;
	}

	if (n % x == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
typedef long long ll;
const ll MOD = 1000000007;
const int N = 100000 + 7;
typedef unsigned long long ull;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif*/
	string s;int fav = 753;
	cin >> s;
	int x, ptr2 = 2, ptr1 = 0, diff = 1e9;
	while (ptr2 < s.size())
	{
		x = (stoi(s.substr(ptr1, 3)));
		diff = min(abs(fav - x), diff);
		ptr1++, ptr2++;
	}
	printf("%d\n", diff);
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<pair<ll,ll>> ball;
    ll Max=0,Min=1e9;
    for (int i=0;i<N;++i){
        ll x,y; cin >> x >> y;
        ball.emplace_back(minmax(x,y));
        Max=max(Max,max(x,y));
        Min=min(Min,max(x,y));
    }
    sort(ball.begin(),ball.end());
    ll ans=(ball[N-1].first-ball[0].first)*(Max-Min);
    Max=max(Max,ball[N-1].first);
    Min=min(Min,ball[0].first);
    set<pair<ll,int>> red;
    red.emplace(ball[0].second,-1);
    for (int i=1;i<N;++i) red.emplace(ball[i].second,i);
    while(1){
        ans=min(ans,(red.rbegin()->first-red.begin()->first)*(Max-Min));
        auto nxt=*red.rbegin();
        red.erase(nxt);
        if (nxt.second==-1) break;
        red.emplace(ball[nxt.second].first,-1);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 16876
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;
ll bigmod(ll x,ll y)
{
    ll z=1;
    while(y)
    {
        if(y&1) z = (z*x)%Mod;
        x = (x*x)%Mod;
        y /= 2;
    }
    return z;
}
void solve(int t)
{
    ll i,j,n,m,ans,mx;
    cin >> n;
    ans = (bigmod(10,n)-2*bigmod(9,n)+bigmod(8,n))%Mod;
    ans = (ans+Mod)%Mod;
    cout <<ans<<endl;
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
    return 0;
}



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> memo(1);
    cin >> memo[0];
    REP(i,n-1){
        int32 a;
        cin >> a;
        if(memo.back() >= a){
            memo.emplace_back(a);
        }else{
            *upper_bound(ALL(memo),a,greater<int32>()) = a;
        }
    }
    ANS(memo.size());
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        ans += a[i];
        mp[a[i]]++;
    }
    int q;
    cin >> q;
    vector<pair<int, int>> b(q);
    for (int i = 0; i < q; i++)
    {
        cin >> b[i].first >> b[i].second;
    }
    for (int i = 0; i < q; i++)
    {
        ans += (b[i].second - b[i].first) * mp[b[i].first];
        mp[b[i].second] += mp[b[i].first];
        mp[b[i].first] -= mp[b[i].first];
        cout << ans << endl;
    }
}

Measured memory_bytes: 8764
using System;
					
public class Program
{
	public static void Main()
	{
		string n = Console.ReadLine();
		
		int sn = 0;
		for(int i = 0; i < n.Length; i++){			
			sn += Convert.ToInt32(n[i].ToString());
		}
		if((Convert.ToInt32(n) % sn) == 0){
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
		
	}
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG



signed main() {
  int N; cin >> N;
  unordered_map<int,int> D;
  rep(i, N) {
    int d; cin >> d;
    D[d]++;
  }
  int M; cin >> M;
  vector<int> T(M);
  rep(i, M) cin >> T[i];
  
  rep(i, M) {
    if(D[T[i]] > 0) {
      D[T[i]]--;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  
  
  

  
}


Measured memory_bytes: 10056
N = int(input())
S = [int(input()) for _ in range(N)]
S.sort()
s_sum = sum(S)
if all(map(lambda x: x % 10 == 0, S)):
    print(0)
    exit(0)
if s_sum % 10 != 0:
    print(s_sum)
else:
    tmp = list(filter(lambda x: x % 10 != 0, S))[0]
    print(s_sum - tmp)


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

int main(){
  int n, m, l;
  int a[101][101];
  int b[101][101];

  cin >> n >> m >> l;


  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) cin >> a[i][j];

  for(int i=0;i<m;i++)
    for(int j=0;j<l;j++) cin >> b[i][j];

 
  long long c [100][100] = { };

  for(int i=0;i<n;i++)
    for(int j=0;j<l;j++)
      for(int k=0;k<m;k++) c[i][j] += a[i][k] * b[k][j];

  for(int i=0; i<n;i++){
    for(int j=0;j<l;j++){
      if(j) cout << " ";
      cout << c[i][j];
    }
    cout<< endl;
  }
  return 0;

}
  


Measured memory_bytes: 3224
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.append(0)
count = 0
for i in range(N):
  if A[i+1]-A[i] == 1:
    count += B[A[i]-1]+C[A[i]-1]
  else:
    count += B[A[i]-1]
print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
//char Input[40*1024*1024+5],*pos;
//#define Read() (strtol(pos,&pos,10))
map<char,int> M;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//fread(Input,40*1024*1024,1,stdin);
	//pos=Input;
	string s;
	cin>>s;
	for(size_t i=0;i<s.length();i++)
		M[ s[i] ]=1;
	for(char i='a';i<='z';i++)
		if(!M.count(i)){
			printf("%c",i);
			return 0;
		}
	puts("None");
	return 0;
}


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

using ll = long long;

int main() {
    int n;
    int q = 0;
    while(cin >> n, n) {
        if(q != 0) {
            cout << endl;
        }
        q++;
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int cnt = 1e9;
        int r1 = 0, r2 = 0, r3 = 0, r4 = 0;
        for(int i=0; i<=a; ++i) {
            for(int j=0; j<=b; ++j) {
                for(int k=0; k<=c; ++k) {
                    for(int l=0; l<=d; ++l) {
                        int total = 10 * i + 50 * j + 100 * k + 500 * l;
                        if(total < n) {
                            continue;
                        }
                        int m = total - n;
                        if(m / 500 > 0 && l != 0) {
                            continue;
                        }
                        int t = m / 500;
                        m %= 500;
                        if(m / 100 > 0 && k != 0) {
                            continue;
                        }
                        t += m / 100;
                        m %= 100;
                        if(m / 50 > 0 && j != 0) {
                            continue;
                        }
                        t += m / 50;
                        m %= 50;
                        if(m / 10 > 0 && i != 0) {
                            continue;
                        }
                        t += m / 10;
                        t = t + (a - i) + (b - j) + (c - k) + (d - l);
                        if(t <= cnt) {
                            r1 = i;
                            r2 = j;
                            r3 = k;
                            r4 = l;
                            cnt = t;
                        }
                    }
                }
            }
        }
        if(r1 > 0) {
            cout << 10 << ' ' << r1 << endl;
        }
        if(r2 > 0) {
            cout << 50 << ' ' << r2 << endl;
        }
        if(r3 > 0 ) {
            cout << 100 << ' ' << r3 << endl;
        }
        if(r4 > 0) {
            cout << 500 << ' ' << r4 << endl;
        }
    }
}

Measured memory_bytes: 3012
#include <iostream>

using namespace std;

int main(){

int a,b;
  cin >> a >> b;
  
  if(a>b){
    cout << a+(a-1) << endl;
  }
  else if(a<b){
    cout << b+(b-1) << endl;
  }
  else{
    cout << a+b << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i=0; i<n; i++){
			h[i] = sc.nextInt();
		}
		int[] dp = new int[n];
		Arrays.fill(dp, 1000000000);
		dp[0] = 0;
		for(int i=0; i<n; i++){
			for(int j=1; j<k+1; j++){
				if(i>=j){
					dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(h[i] - h[i-j]));
				}
			}
		}
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 60372
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> ans(n,0);
  int temp;
  for(int i=0;i<n-1;i++)
  {
    cin>>temp;
    ans[temp-1]++;
  }
  for(int i=0;i<n;i++)
    cout<<ans[i]<<"\n";
  return 0;
}

Measured memory_bytes: 4044
from collections import Counter, defaultdict

N = int(input())

def primeFactorization(N):
    primes = Counter()
    R = int(N**(0.5)) + 1
    for num in range(2, R):
        while N % num == 0:
            N //= num
            primes[num] += 1
    if N > 1 :
        primes[N] = 1
    return primes

primes = Counter()
for i in range(1, N + 1):
    primes += primeFactorization(i)

cnt = defaultdict(int)
for c in primes.values():
    c += 1
    for d in (3, 5, 15, 25, 75):
        if c >= d:
            cnt[d] += 1

ans = 0
ans += cnt[5] * (cnt[5] - 1) * (cnt[3] - 2) // 2
ans += cnt[25] * (cnt[3] - 1)
ans += cnt[15] * (cnt[5] - 1)
ans += cnt[75]
print(ans)


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			
			
			
			System.out.println(N%hashould(N)==0?"Yes":"No");
			
			
			
		}
		
	}
	
	
	
	public static  int hashould(int x) {
		String S = String.valueOf(x);
		
		int goukei =0;
		
		for(int i = 0;i<S.length();i++) {
			goukei+=Integer.valueOf(S.substring(i, i+1));
		}
		
		
		return goukei;
	}

}


Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#define LL long long
int N;
LL T[100];
LL ans;
int main(){
    std::cin>>N;
    for(int i=0;i<N;i++){
        std::cin>>T[i];
    }
    ans=T[0];
    for(int i=1;i<N;i++){
        LL gcd=std::__gcd(ans,T[i]);
        ans/=gcd;
        ans*=T[i];
    }
    std::cout<<ans<<std::endl;
    return 0;
}


Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll dp[3005][3005];
void solve()
{
    ll n,s;
    cin>>n>>s;
    vl v;
    v.pb(0);
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    rep(i,3005)
        rep(j,3005)
            dp[i][j]=0;
    ll ans=0;    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=s;j++)
        {
            if(j<v[i])
                continue;
            dp[i][j]+=(dp[i-1][j-v[i]]);
            if(j==v[i])
                dp[i][j]+=i;
            dp[i][j]%=mod;
        }
        ll temp=(n-i+1)*(dp[i][s]);
        temp%=mod;
        ans+=temp;
        ans%=mod;
        for(int j=1;j<=s;j++)
        {
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=mod;
        }
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;


  if(n % 2 == 0){

    int half = n / 2;
    int cnt = 0;

    int np = half - 1;

    vector<pair<int, int>> ans;

    int fnp = (np + 2 - 1) / 2;
    rep(i, fnp){
      ans.push_back(make_pair(i, fnp*2-i-1));
      cnt++;
      if(cnt == m){
        break;
      }
    }

    if(cnt < m){

      int snp = np - fnp;
      rep(i, snp){
        ans.push_back(make_pair(fnp*2 + i , np*2-i));
        cnt++;
        if(cnt == m){
          break;
        }
      }
    }

    rep(i, ans.size()){
      cout << ans[i].first + 1 << " " << ans[i].second +1 << endl;

    }
  }else{

    vector<pair<int, int>> ans;

    rep(i, m){
      ans.push_back(make_pair(i, n - 2 - i));
    }

    rep(i, ans.size()){
      cout << ans[i].first + 1 << " " << ans[i].second + 1<< endl;
    }

  }

  return 0;
}


Measured memory_bytes: 4276
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
int main() {
  int N, Q; cin >> N >> Q;
  string S; cin >> S;
  vector<int> s(N + 1);
  s[0] = 0; s[1] = 0;
  for (int i = 1; i < N; ++i) {
    if (S[i-1] == 'A' && S[i] == 'C')
      s[i + 1] = s[i] + 1;
    else
      s[i + 1] = s[i];
  }

  for (int i = 0; i < Q; ++i) {
    int l, r; cin >> l >> r;
    cout << s[r] - s[l] << endl;
  }
}


Measured memory_bytes: 3812
#include<iostream>
using namespace std;
/*

男子   500M  1000M
AAA級  35秒50  1分11秒00
AA級   37秒50  1分17秒00
A級  40秒00  1分23秒00
B級  43秒00  1分29秒00
C級  50秒00  1分45秒00
D級  55秒00  1分56秒00
E級 1分10秒00 2分28秒00

*/

int main(){
  double a,b;
  while(cin>>a>>b){
    if(a<35.5 && b<71){
      cout<<"AAA"<<endl;
    }else if(a<37.5 && b<77){
      cout<<"AA"<<endl;
    }else if(a<40 && b<83){
      cout<<"A"<<endl;
    }else if(a<43 && b<89){
      cout<<"B"<<endl;
    }else if(a<50 && b<105){
      cout<<"C"<<endl;
    }else if(a<55 && b<116){
      cout<<"D"<<endl;
    }else if(a<70 && b<148){
      cout<<"E"<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
}

Measured memory_bytes: 1220
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
char c[maxn];
int main()
{
    scanf("%s",c+1);
    int n = strlen(c+1);
    int fl = 0;
    for(int i = 1; i <= n; i++){
        if(c[i] != c[n+1-i])fl = 1;
    }
    for(int i = 1;i <(1+n)/2;i++){
        if(c[i] != c[(1+n)/2-i])fl = 1;
    }
    for(int i = (1+n)/2+1; i<= n; i++){
        if(c[i]!=c[(3*n+3)/2-i])fl =1;
    }
    puts(fl?"No":"Yes");
}

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

int main()
{
	int N,K;
	int h[100010]={};
	int ans=2e9;
	
	cin >> N >> K;
	for(int i=0;i<N;i++)
		cin >> h[i];
	
	sort(h,h+N);
	
	for(int i=0;i<N-K+1;i++)
		ans=min(ans,h[i+K-1]-h[i]);
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import numpy as np
A, B, C = map(int,input().split(' '))

Srt = np.sort([A,B,C])

if np.sum(Srt % 2) == 0: a = 0; ad = 0;
elif np.sum(Srt % 2) == 1: a = 1; ad = 1;
elif np.sum(Srt % 2) == 2: a = 1; ad = 0;
elif np.sum(Srt % 2) == 3: a = 0; ad = 1;

#num = a + np.sum(Srt[2] // 2 - (Srt // 2))
Add = (Srt + ad) % 2
newSrt = Srt + Add

#print(a)
#print(newSrt)

print(int(a + np.sum((newSrt[2]- newSrt)/2)))

Measured memory_bytes: 21528
#include<stdio.h>

int main(void){
        int n, c, i, sm=0;
        scanf("%d %d", &n, &c);
        for(i=0; i<c; i++){
                int tmp;
                scanf("%d", &tmp);
                sm += tmp;
        }
        printf("%d\n", sm/++n+(sm%n>0));
        return 0;
}


Measured memory_bytes: 2112
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        a: i64,
        v: i64,
        b: i64,
        w: i64,
        t: i64,
    }
    println!("{}", if (v - w) * t >= (a - b).abs() { "YES" } else { "NO" });
}

Measured memory_bytes: 2064
#include <iostream>
#include <string>
#include <map>
using namespace std;
 
int main(void) {
	
	map<int, int> mp;
	int a,b,c;
	cin >> a >> b >> c ;
	mp[a] = 1;
	mp[b] = 1;
	mp[c] = 1;
	
	cout << mp.size();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll a,b;
cin>>a>>b;

ll right=b-a;
ll height=0;
rreps(i,0,right)height+=i;
cout<<height-b<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine();
		int[] nums = new int[Integer.parseInt(s[0])];
		s = readLine();
		for(int i=0;i<s.length;i++) {
			nums[i]=Integer.parseInt(s[i]);
		}
		int count = 0;
		for(int i=1;i<s.length-1;i++) {
			if((nums[i-1]<nums[i]&&nums[i]<nums[i+1])||(nums[i+1]<nums[i]&&nums[i]<nums[i-1])) {
				count++;
			}
		}
		print(count);
	}

	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}

Measured memory_bytes: 21076
a, b, c, x, y = map(int, input().split())

ab = min(x, y)
c2 = c * 2
p = 0

if a + b >= c2:
  x -= ab
  y -= ab
  p += c2 * ab

if a >= c2:
  p += c2 * x
  x = 0
  y -= x

if b >= c2:
  p += c2 * y
  y = 0
  x -= y

if x > 0:
  p += a * x

if y > 0:
  p += b * y
  
print(p)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int n, m;

vector<vector<int>> graph;

vector<int> min_cycle;
const int INF = 100000;
int min_dist = INF;

void bfs(int s) {
    vector<int> prev(n, -1);
    queue<int> que;
    que.push(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int to: graph[v]) {
            if (to == s) {
                vector<int> path;
                for (; v != -1; v = prev[v]) path.push_back(v);
                if (chmin(min_dist, (int)path.size())) min_cycle = path;
                return;
            }
            
            if (prev[to] == -1) {
                prev[to] = v;
                que.push(to);
            }
        }
    }
}

int main() {
    cin >> n >> m;
    graph.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
    }
    
    rep(i, n) {
        bfs(i);
    }
    
    if (min_dist == INF) cout << -1 << endl;
    else {
        cout << min_cycle.size() << endl;
        for (int v: min_cycle) cout << v + 1 << endl;
    }
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = ((A-1)//10)*10 + 10
b = ((B-1)//10)*10 + 10
c = ((C-1)//10)*10 + 10
d = ((D-1)//10)*10 + 10
e = ((E-1)//10)*10 + 10

print(min(A+b+c+d+e,a+B+c+d+e,a+b+C+d+e,a+b+c+D+e,a+b+c+d+E))

Measured memory_bytes: 3064
//Problem A
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count5 = 0;
		int count7 = 0;
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a == 5) {
			count5++;
		}
		if (a == 7) {
			count7++;
		}
		if (b == 5) {
			count5++;
		}
		if (b == 7) {
			count7++;
		}
		if (c == 5) {
			count5++;
		}
		if (c == 7) {
			count7++;
		}
		if (count5 == 2 && count7 == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>x;
      rep(i,n)cin>>a[i];
      rep(i,n){
        ans+=min(a[i]*2,abs(x-a[i])*2);
      }
      Cout(ans);
    
       
return 0;
}


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

int		main(void)
{
	int N;

	cin >> N;
	int high = 0;
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		int H;

		cin >> H;
		if (H >= high)
		{
			high = H;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{

    vector<int> a(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int sum = a[0] * 10 + a[1];
    cout << sum + a[2] << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<int[]> listcd = new ArrayList<>();
		for(int i=0;i<n;i++) {
			int[] ab = new int[2];
			ab[0] = in.nextInt();
			ab[1] = in.nextInt();
			listcd.add(ab);
		}
		listcd.sort((ab1,ab2)->ab1[0]-ab2[0]);
		
		List<int[]> listab = new ArrayList<>();
		for(int i=0;i<n;i++) {
			int[] cd = new int[2];
			cd[0] = in.nextInt();
			cd[1] = in.nextInt();
			listab.add(cd);
		}
		listab.sort((cd1,cd2)->cd1[0]-cd2[0]);
		
		boolean[] usedcd = new boolean[n];
		int count = 0;
		for(int i=0;i<n;i++) {
			int a = listab.get(i)[0];
			int b = listab.get(i)[1];
			
			int j = 0;
			int maxd = -1;
			int idx = -1;
			while(j<n) {
				int c = listcd.get(j)[0];
				int d = listcd.get(j)[1];
				if(c>=a) break;
				if(d>=b) {
					j++;
					continue;
				}
				if(!usedcd[j] && d>maxd) {
					maxd = d;
					idx = j;
				}
				j++;
			}
			if(idx>=0) {
				count++;
				usedcd[idx] = true;
			}
		}
		System.out.println(count);
		in.close();
	}

}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    double T, A; cin >> T >> A;
    vector<double> H(N);
    rep(i, N) cin >> H[i];

    double tmp = 1e+9;
    int res=0;
    rep(i, N){
        if(tmp > abs(T-0.006*H[i] - A)){
            tmp = abs(T-0.006*H[i] - A);
            res = i+1;
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>

using namespace std;

int num(char c){
   return c-'0';
}
int main(){
    char s[30];
    cin >> s;

    int y,m,d;
    y = num(s[0])*1000 + num(s[1])*100 + num(s[2])*10+ num(s[3]);
    m = num(s[5])*10 + num(s[6]);
   d = num(s[8])*10 + num(s[9]);
   if(y > 2020){
cout << "TBD" << endl;
return 0;
   }else if(y == 2019){
if(m > 4){
cout << "TBD" << endl;
return 0;
}else if(m==4 && m >30){
cout << "TBD" << endl;
}
cout << "Heisei" << endl;
return 0;
}



    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

signed main()
{
	ios::sync_with_stdio(false);
	int n,d,cnt=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		int num=x*x+y*y;
		if(num<=d*d) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

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

using namespace std;

const int N = 8080;

bool dp[N][N];

bool cek(int sum, const vector<int>& c) {
  memset(dp, 0, sizeof dp);
  int tot = 0;
  for (int x : c)
    tot += x;
  dp[0][0] = 1;
  for (int i = 0; i < c.size(); ++i) {
    for (int j = 0; j <= tot; ++j) {
      if (!dp[i][j]) continue;
      dp[i+1][j+c[i]] = 1;
      dp[i+1][abs(j-c[i])] = 1; 
    }
  }
  return dp[c.size()][sum];
}

char s[N];

int main() {
  scanf("%s", s);
  int x, y;
  scanf("%d %d", &x, &y);
  int n = strlen(s);
  int i = 0;
  while (i < n && s[i] == 'F') x--, i++;
  bool datar = 1;
  int cnt = 0;
  vector<int> hor, ver;
  while (i < n) {
    if (s[i] == 'T') {
      if (cnt > 0) {
        if (datar)
          hor.push_back(cnt);
        else
          ver.push_back(cnt);
      }
      cnt = 0;
      datar ^= 1;
    }
    else
      cnt++;
    i++;
  }
  if (cnt > 0) {
    if (datar)
      hor.push_back(cnt);
    else
      ver.push_back(cnt);
  }
  bool ans = cek(abs(x), hor);
  ans &= cek(abs(y), ver);
  puts(ans ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 64000
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int64_t q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  int64_t mini = min({q*8, h*4, s*2, d});
  int64_t res = 0;
  while(n != 0 && n != 1) {
    n -= 2;
    if(mini == q*8) res += q*8;
    if(mini == h*4) res += h*4;
    if(mini == s*2) res += s*2;
    if(mini == d)   res += d;
  }
  if(n == 1) res += min({q*4, h*2, s});
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256