akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll h,n,a[1010],b[1010];
ll dp[10010];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,k,ans,g,mc,mh;
    	cin>>h>>n;
    	rep(i,0,n)
    	{
    		cin>>a[i]>>b[i];
		}
      repi(i,0,h)
		dp[i]=99999999999999999;
        dp[0]=0;
        repi(i,0,h)
    	{
    		rep(j,0,n)
    		{
    			dp[i]=min(dp[i],dp[max(0ll,i-a[j])]+b[j]);
			}
 
		}
		cout<<dp[h];
    } 
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] ans = new int[N + 1];
		for(int i=N;i>=1;i--){
			int cnt = 0;
			for(int j=i+i;j<=N;j+=i){
				cnt += ans[j];
			}
			ans[i] = A[i-1] ^ (cnt % 2);
		}
		var ret = new List<int>();
		for(int i=1;i<=N;i++) if(ans[i] == 1) ret.Add(i);
		Console.WriteLine(ret.Count);
		if(ret.Count > 0) Console.WriteLine(String.Join(" ",ret));
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 34520
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (ll ll i = a; i < n; i++)
#define ford(i, a, n) for (ll ll i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ", a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned ll ll
#define py puts("Yes")
#define pn puts("No")
#define pY puts("YES")
#define pN puts("NO")
#define re(i, a, b) for (int i = a; i <= b; ++i)
#define de(i, a, b) for (int i = a; i >= b; --i)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;
template <class t>
inline void cmin(t &a, t b) { ((a > b) && (a = b)); }
template <class t>
inline void cmax(t &a, t b) { ((a < b) && (a = b)); }
const ll V = 1e6 + 5;
const ll E = 4e6 + 5;
const ll mode = 1e9 + 7;
ll weight[E], to[E], nex[E];
ll cnt = 0;
ll n, m, dis[V];
ll head[V];
bool vis[V];
ll gcd(ll a, ll b)
{
  return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

ll multi(ll a, ll b, ll p)
{ //快速乘法
  ll ret = 0;
  while (b)
  {
    if (b & 1)
      ret = (ret + a) % p;
    a = (a + a) % p;
    b >>= 1;
  }
  return ret;
}

ll Pow(ll a, ll b, ll mode)
{
  ll sum = 1;
  a = a % mode;
  while (b > 0)
  {
    if (b % 2 == 1) //判断是否是奇数，是奇数的话将多出来的数事先乘如sum
      sum = sum * a % mode;
    b >>= 1;
    a = a * a % mode; // 不断的两两合并再取模，减小a和b的规模
  }
  return sum;
}
void add(ll u, ll v, ll w)
{
  cnt++;
  to[cnt] = v;
  weight[cnt] = w;
  nex[cnt] = head[u];
  head[u] = cnt;
}
void init()
{
  cnt = 0;
  memset(head, -1, sizeof(head));
}
void SPFA(ll s)
{
  memset(dis, 0x3f3f3f3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  dis[s] = 0;
  vis[s] = 1;
  queue<ll> q;
  q.push(s);

  while (!q.empty())
  {
    ll now = q.front();

    q.pop();
    vis[now] = 0;
    for (int i = head[now]; i != -1; i = nex[i])
    {

      if (dis[to[i]] > dis[now] + weight[i])
      {
        dis[to[i]] = dis[now] + weight[i];
        if (!vis[to[i]])
        {
          q.push(to[i]);
          vis[to[i]] = 1;
        }
      }
    }
  }
}
int a[MAXN];
int main()
{
  int a,b;
  sii(a,b);
  cout<<a*b<<endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

string str, strreverse;
int a, b, l;
map<string, int> m;

int main() {
	while ( scanf( "%d %d", &a, &l ) && l ) {
		str.resize( l );
		strreverse.resize( l );
		int now = 1;
		while ( true ) {
			int d = a;
			for ( int i = 0; i < l; i++ ) {
				str[ i ] = (a % 10) + '0';
				a /= 10;
			}
			reverse( str.begin(), str.end() );
			if ( m[ str ] ) {
				printf( "%d %d %d\n", m[ str ] - 1, d, now - m[ str ] );
				m.clear();
				break;
			}
			m[ str ] = now;
			now++;
			sort( str.begin(), str.end() );
			strreverse = str;
			sort( str.rbegin(), str.rend() );
			a = b = 0;
			for ( int i = 0; i < l; i++ ) {
				a *= 10;
				b *= 10;
				a += (str[ i ] - '0');
				b += (strreverse[ i ] - '0');
			}
			a -= b;
		}
	}
	return 0;
}

Measured memory_bytes: 1256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using Graph=vector<vector<int>>;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}


signed main(){
	string s;cin>>s;
	int flag=0;
	rep(i,s.size()){
		if(flag==0&&s[i]=='C') flag=1;
		if(flag==1&&s[i]=='F') flag=2;
	}
	Yn(flag==2);
}

Measured memory_bytes: 256
#ifndef Local
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;

// gp_hash_table<int, int> table;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int n, d;
  cin >> n >> d;

  d = 2 * d + 1;

  cout << (n + d - 1) / d << endl;

}


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

using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

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

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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

vector<vector<ll>>to;
bool flag[202020];
ll point[202020];

void dfs(ll x) {
	flag[x] = true;
	for (auto u : to[x]) {
		if (flag[u] == false) {
			point[u] += point[x];
			dfs(u);
		}
	}
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, q;
	cin >> n >> q;
	to.resize(n);
	rep(i, n-1) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i, q) {
		ll p, x;
		cin >> p >> x;
		p--;
		point[p] += x;
	}
	dfs(0);
	rep(i, n) {
		cout << point[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 21376
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

const int L=5e5+2;
LL d[L];
LL p[L];
LL s[L];
int main() {
	int N,D;
	cin >> N >> D;
	p[0]=D;
	for(int i=1;i<=N;i++){
		cin >> d[i];
		p[i]=min(p[i-1],abs(p[i-1]-d[i]));
	}
	s[N+1]=0;
	for(int i=N;i>0;i--){
		if(abs(s[i+1]+1-d[i])<=s[i+1]){
			s[i]=s[i+1]+d[i];
		}
		else{
			s[i]=s[i+1];
		}
	}
	int Q;
	cin >> Q;
	for(int i=0;i<Q;i++){
		int q;
		cin >> q;
		//cerr << p[q-1] << ", " << s[q+1] << endl;
		if(p[q-1]>s[q+1]){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 13696
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define eb emplace_back
#define pb push_back

typedef long long ll;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    map<string,int> mp;
    REP(i,n){
        string s;cin >> s;
        mp[s]++;
    }
    vector<pair<int,string> >ans;
    for(auto i : mp){
        ans.eb(i.second,i.first);
    }
    sort(ans.rbegin(),ans.rend());
    for(int i = ans.size();i >= 0;i--){
        if(ans[i].first == ans[0].first){
            cout << ans[i].second << '\n';
        }
    }
    
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

template<class T> struct Seg { 
	const T ID = 0; // comb(ID,b) must equal b
	T combine(T a, T b) { return a+b; } 
	int n; vector<T> seg;
	void init(int _n) { n = _n; seg.assign(2*n,ID);}

	void update(int p, T value) {	// set value at position p
		seg[p += n] = value;
		for (p /= 2; p; p /= 2) seg[p] = combine(seg[2*p], seg[2*p+1]);
	}
    
	T query(int l, int r) {	 // sum on interval [l, r]
		T ra = ID, rb = ID; 
		for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
			if (l&1) ra = combine(ra,seg[l++]);
			if (r&1) rb = combine(seg[--r],rb);
		}
		return combine(ra,rb);
	}
};


int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	string T; cin >> T;
	Seg<ll> seg1; seg1.init(S.size());
	Seg<ll> seg2; seg2.init(S.size());

	F0R(i, S.size()) seg1.update(i, 2 - S[i] + 'A');
	F0R(i, S.size()) seg2.update(i, 2 - T[i] + 'A');

	int Q; cin >> Q;
	F0R(i, Q) {
		int s1, s2, t1, t2; cin >> s1 >> s2 >> t1 >> t2;
		--s1; --s2; --t1; --t2;
		if (abs(seg1.query(s1, s2) - seg2.query(t1, t2))  % 3 == 0) {
			print("YES");
		} else {
			print("NO");
		}
	}
}

Measured memory_bytes: 4048
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

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

const int INF = 1 << 24;

typedef unsigned long long ull;

int main(){
    int W, H, N;
    std::cin >> W >> H >> N;

    int X[1010], Y[1010];
    REP(i, N){
        std::cin >> X[i] >> Y[i];
    }

    ull res = 0;
    FOR(i, 1, N){
        int dx = X[i] - X[i-1], dy = Y[i] - Y[i-1];
        
        if((dx > 0 && dy > 0) || (dx < 0 && dy < 0)){
            int k = std::min(std::abs(dx), std::abs(dy));
            res += k + (std::abs(dx) - k) + (std::abs(dy) - k);
        }else{
            res += std::abs(dx) + std::abs(dy);
        }
    }

    std::cout << res << std::endl;
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

bool func(pll a, pll b) {
    return a.first+a.second < b.first+b.second;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<pll> A(N);
    rep(i,N) cin >> A[i].first >> A[i].second;

    vector<ll> dp(N+1,1e18);
    sort(all(A),func);
    dp[0] = 0;
    rep(i,N) {
        int k = upper_bound(all(dp),A[i].first) - dp.begin();
        for (int j = k-1; j >= 0; --j) {
            chmin(dp[j+1],dp[j]+A[i].second);
        }
    }
    int ans = lower_bound(all(dp),1e18) - dp.begin();
    cout << ans-1 << ln;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>

using namespace std; using ll=long long; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  int n,m; cin>>n>>m;
  int h[n];
  vector<int> v[n];

  for(int i=0;i<n;i++) {
    cin>>h[i];
  } 
  for(int i=0;i<m;i++) {
    int a,b; cin>>a>>b; a--; b--;
    v[a].push_back(b); v[b].push_back(a);
  }

  int an=0;
  for(int i=0;i<n;i++) {
    bool ok=true;
    for(int x:v[i]) {
      if (h[x] >= h[i]) ok=false;
    }
    an += ok;
  }
  cout<<an<<endl;
}

Measured memory_bytes: 9100
// inputに入力データ全体が入る
function Main(input) {
	var input = input.split("\n");
	var tmp = input[0].split(" ");
	var A = Number(tmp[0]);
	var B = Number(tmp[1]);
	var C = Number(tmp[2]);
	var ans = (A+B >= C) ? "Yes" : "No";
	console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    if(n==1){
        cout << 0 << endl;
        return 0;
    }
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
        a[i]-=(i+1);
    }
    sort(a.begin(),a.end());
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(a[i]<0) ans-=a[i];
        else ans+=a[i];
    }
    ll mcnt=0;
    for(ll i=0;i<n;i++){
        if(a[i]>0){
            break;
        }
        mcnt++;
    }
    ll pcnt=n-mcnt;
    ll da=0;
    if(n%2==1){
        ll mid=n/2;
        if(mid>mcnt){
            while(a[mid]!=0){
                a[mcnt]-=da;
                ll b=a[mcnt];
                a[mcnt]=0;
                ans-=b*(pcnt-mcnt);
                da+=b;
                pcnt--;
                mcnt++;
            }
        }
        else {
            while(a[mid]!=0){
                a[n-pcnt-1]-=da;
                ll b=a[n-pcnt-1];
                a[n-pcnt-1]=0;
                ans-=b*(pcnt-mcnt);
                da+=b;
                pcnt++;
                mcnt--;
            }
        }
    }
    else {
        ll mid=n/2;
        if(mid>mcnt){
            while(mcnt!=pcnt){
                a[mcnt]-=da;
                ll b=a[mcnt];
                ans-=b*(pcnt-mcnt);
                da+=b;
                pcnt--;
                mcnt++;
            }
        }
        else {
            while(mcnt!=pcnt){
                a[n-pcnt-1]-=da;
                ll b=a[n-pcnt-1];
                ans-=b*(pcnt-mcnt);
                da+=b;
                pcnt++;
                mcnt--;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n, k;
    cin >> n >> k;
    long long temp = n / k;
    n = n - temp * k;
    if (n > abs(n - k))
    {
        cout << abs(n - k) << "\n";
    }
    else
    {
        cout << n << "\n";
    }
}

Measured memory_bytes: 256
s=sorted(list(input()))
t=sorted(list(input()),reverse=True)
for i in range(min(len(s),len(t))):
    if ord(s[i])<ord(t[i]):
        print("Yes")
        exit()
    elif ord(s[i])>ord(t[i]):
        print("No")
        exit()
if len(s)>=len(t):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9156
L = []
num = ["3", "5", "7"]
peak = 1
for i in range(10):
  for j in range(peak):
    T = ""
    S = [0, 0, 0]
    tmp = j
    for k in range(i):
      T = T[:] + num[tmp%3]
      S[tmp%3] += 1
      tmp //= 3
    if S[0] * S[1] * S[2] > 0:
      L.append(int(T))
  peak *= 3
L.sort()
N = int(input())
n = len(L)
l, c, r = 0, n // 2, n
pnt = 0
m = max(L)
if m <= N:
  print(n)
else:
  while L[pnt] <= N:
    pnt += 1
  print(pnt)

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str1 = br.readLine();
		int n = Integer.parseInt(str1);
		
		System.out.println((int)Math.pow((int)Math.sqrt(n), 2));
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  string s;
  cin >> n >> s;
  map<char, int> cnt;

  REP(i, n) {
    cnt[s[i]]++;
  }

  ll ans = 1;
  EACH(v, cnt) {
    ans *= (v.second + 1);
    ans %= MOD;
  }
  ans--;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 512
k = gets.to_i

a = (1..9).to_a
(k - 1).times do
  t = a.shift
  a << (10 * t + (t % 10) - 1) if t % 10 != 0
  a << (10 * t + (t % 10))
  a << (10 * t + (t % 10) + 1) if t % 10 != 9
end

puts a.shift


Measured memory_bytes: 3836
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		long count = 0;
	    int current = 0;
	    int state = 1;
	    long total = 0;
	    for (int i = 0; i < n; i++) {
	        int time = sc.nextInt();
	        int floor = sc.nextInt();
	        if (state - 1 + floor - 1 <= time - current) {
	            total += count * (state - 1);
	            count = 1;
	            current = time;
	            state = floor;
	        } else if (Math.abs(floor - state) <= time - current) {
	            total += count * (time - current);
	            count++;
	            current = time;
	            state = floor;
	            if (count > d) {
	                System.out.println(-1);
	                return;
	            }
	        } else {
	            System.out.println(-1);
	            return;
	        }
	    }
	    total += count * (state - 1);
		System.out.println(total);
	}
}



Measured memory_bytes: 68192
INF = 10**20
n = int(input())
nlist = []
all_mat = []
for i in range(n):
    a,b = map(int, input().split())
    all_mat.append((a,b))
    if (i == 0):
        nlist = [a,b]
    else:
        nlist.append(b)
        
def cost1(nlist):
    if len(nlist) == 0:
        return 0
    m = min(nlist)
    cost = 0
    mid = nlist.index(m)
    a = nlist[:mid]
    b = nlist[mid+1:]
    while (len(a)>1 and len(a) !=0):
        for i in range(len(a)-1):
            cost += a.pop()*a[-1]
            #print(a)
    while (len(b)>1 and len(b) !=0):
        b.reverse()
        for i in range(len(b)-1):
            cost += b.pop()*b[-1]
            #print(b)
    if (len(a) == 1 and len(b) == 1):
        cost += a.pop()*b.pop()
        #print(a,b)
    cost *= m
    return cost
#[34, 44, 13, 30]
def cost2(nlist, mm):
    if len(nlist) == 0:
        return 0
    m = min(nlist)
    cost = 0
    mid = nlist.index(m)
    a = nlist[:mid+1]
    #print(a)
    b = nlist[mid:]
    #print(b)
    while (len(a)>1 and len(a) !=0):
        a.reverse()
        for i in range(len(a)-1):
            cost += a.pop()*a[-1]
            #print(a)
    while (len(b)>1 and len(b) !=0):
        for i in range(len(b)-1):
            cost += b.pop()*b[-1]
            #print(b)
    if (len(a) == 1 and len(b) == 1):
        cost += m*mm
        #print(a,b)
    cost *= mm
    return cost

copy = nlist[:]
m = min(nlist)
#print(nlist)
c = nlist.count(m)
cost = 0
if (c == 1):
    cost = cost1(nlist)
elif (c >= 2):
    cc = 1
    cut_index = [0]
    mcount = nlist.count(m)
    for i in range(mcount):
        cut_index.append(nlist.index(m))
        nlist.remove(m)
    cut = []
    for i in range(mcount):
        cut.append(nlist[cut_index[i]:cut_index[i+1]])
    cut.append(nlist[cut_index[-1]:])
    #print(cut)
    co1 = cut[0] +[m]+ cut[-1]
    cost += cost1(co1)
    for co2 in cut[1:-1]:
        #print(co2)
        cost += cost2(co2,m)
    co3 = cut[0]+cut[-1]
    if (len(co3)>1):
        cost += (len(cut)-2)*m*min(co3)
print(cost)



Measured memory_bytes: 5624
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	for i,val in enumerate(S):
		tmp = max(val)
		for j,vol in enumerate(val):
			if tmp == vol:
				ans.append(j+1)
				break

	for i in range(D):
		print(ans[i])

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 84040
def main():
    A, B = input().split()

    A = int(A)
    B_int, B_frac = map(int, B.split('.'))  # 整数部分, 小数部分
    L = len(str(B_frac))  # 小数部分の桁数

    ans = (A * (B_int * 100 + B_frac)) // 100

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
typedef  long long ll;

int main() {
	int a, b;
	std::cin >> a >> b;
	std::cout << (a - 1)*(b - 1) << std::endl;
}


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

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n, k;
	cin >> n >> k;
	vector<vector<int>> w(k, vector<int>(k, 0)), b(k, vector<int>(k, 0));
	rip(i, n, 0) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if (bool((x / k % 2) ^ (y / k % 2)) ^ (c == 'W')) {
			w[x%k][y%k]++;
		}
		else {
			b[x%k][y%k]++;
		}
	}
	int ans = 0, al = 0;
	vector<int> X(k, 0), sX(k, 0);
	rip(i, k, 0) {
		rip(j, k, 0) {
			sX[i] += w[i][j] + b[i][j];
			X[i] += w[i][j];
		}
	}
	rip(i, k, 0) {
		int now = 0;
		rip(j, k, 0) {
			now += X[j];
		}
		rip(j, k, 0) {
			ans = max(ans, max(now, n - now));
			now += sX[j] - X[j] * 2;
		}
		rip(j, k, 0) {
			X[j] += b[j][i] - w[j][i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    ll n, m, ans=0;
    cin >> n >> m;
    cout << (ll)(abs(n-2)*abs(m-2));
}


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

int main() {
  string s,t,u;
  int a,b;
  
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(u==s) {
    a--;
  }
  else {
    b--;
  }
  
  cout << a << " " << b;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int A,B,C;
  scanf("%d",&A);
  scanf("%d",&B);
  C=(B-1)/(A-1);
  if((B-1)%(A-1)!=0){
    C++;
  }
  printf("%d",C);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

int main() {
    string S;
    cin >> S;
    int target = 753;
    int len = S.length();
    int minDiff = INF;

    for (int i = 0; i < (len - 2); i++){
        int sum = 0;
        sum += 100 * ctoi(S[i]);
        sum += 10 * ctoi(S[i+1]);
        sum += ctoi(S[i+2]);
        // DEBUG(S[i]);
        // DEBUG(S[i+1]);
        // DEBUG(S[i+2]);
        // DEBUG(sum);
        minDiff = min(minDiff, abs(target - sum));
    }

    cout << minDiff << endl;
}


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

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        long X = NextLong();
        long Y = NextLong();
        long Z = NextLong();
        long K = NextLong();
        long[] A = LineLong();
        long[] B = LineLong();
        long[] C = LineLong();
        Array.Sort(A);
        Array.Reverse(A);
        Array.Sort(B);
        Array.Reverse(B);
        Array.Sort(C);
        Array.Reverse(C);
        List<long> ans = new List<long>();
        for (int i = 0; i < X; i++)
            for (int j = 0; j < Y; j++)
            {
                if ((i + 1) * (j + 1) > K) break;
                for (int k = 0; k < Z; k++)
                {
                    if ((i + 1) * (j + 1) * (k + 1) > K) break;
                    ans.Add(A[i] + B[j] + C[k]);
                }
            }
        ans.Sort();
        ans.Reverse();
        for (int i = 0; i < K; i++) Console.WriteLine(ans[i]);

    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

const int N = 1010000, MOD = 1e9 + 7;

long long f[N], fac[N], inv[N];
int n;

long long Kissme(long long x, long long y) {
  long long c = 1;
  while(y) {
    if(y & 1) c = c * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return c;
}

void Init(void) {
  fac[0] = 1;
  for(int i = 1; i <= n; i++)
    fac[i] = fac[i - 1] * i % MOD;
  inv[n] = Kissme(fac[n], MOD - 2);
  for(int i = n - 1; i >= 0; i--)
    inv[i] = inv[i + 1] * (i + 1) % MOD;
}

long long C(int x, int y) {
  if(x < y) return 0;
  return fac[x] * inv[y] % MOD * inv[x - y] % MOD;
}

int main(void) {
  scanf("%d", &n);
  Init();
  long long ans = 0;
  for(int i = 0; i < n; i++)
    f[i] = C(n - 3 - i + 1, i);
  //for(int i = 1; i < n; i++)
  //f[i] = (f[i - 1] + f[i]) % MOD;
  for(int i = 0; i < n; i++)
    f[i] = f[i] * fac[i] % MOD * fac[n - i - 1] % MOD;
  for(int i = 1; i < n; i++) {
    ans = (ans + ((f[n - i - 1] - f[n - i]) * i % MOD + MOD) % MOD) % MOD;  
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 23808
#include <algorithm>
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#define ll long long int
#define eps 1e-7
#define rep(i, a, b) for(int i = (a); i <= (b); ++ i)
#define dwn(i, a, b) for(int i = (a); i >= (b); -- i)
using namespace std;
const int maxn = 22;

int n;
int zhengx[maxn][maxn], zhengy[maxn][maxn], num[maxn];
int is[maxn];
int main()
{
    cin >> n;
    rep(i, 1, n)
    {
        cin >> num[i];
        rep(j, 1, num[i])
            cin >> zhengx[i][j] >> zhengy[i][j];
    }
    int Ans = 0;
    rep(s, 1, (1 << n) - 1)
    {
        int sum = 0;
        rep(i, 1, n)
            if(s & (1 << (i - 1)))
                is[i] = 1, sum ++;
            else is[i] = 0;
        //cout << sum << endl;
        //rep(i, 1, n) cout << is[i] << ' ';cout << endl;
        int pd = 1;
        rep(i, 1, n)
            if(is[i])
                rep(j, 1, num[i])
                    if(is[zhengx[i][j]] != zhengy[i][j])
                    {
                        pd = 0;
                        break;
                    }
        if(pd) Ans = max(Ans, sum);
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>B(N-1);
    for(int i=0;i<N-1;i++){
        cin >>B[i];
    }
    vector<int>A(N);
    A[0]=B[0];
    for(int i=1;i<N-1;i++){
        A[i]=min(B[i-1],B[i]);
    }
    A[N-1]=B[N-2];
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=A[i];
    }
    cout << ans <<endl;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    char c;
    for(int in=0;in<n;in++) {
        cin >> c;
        if(c=='Y') { 
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;
    return 0;
}


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin >> x;
    ll y = x / 500;
    ll z = (x % 500) / 5;
    cout << y * 1000 + z * 5 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>

#define p(a, b) pair<a, b>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string x,y;
    cin >> x >> y;
    map<char,int> mp;
    mp['0'] = 0;
    mp['1'] = 1;
    mp['2'] = 2;
    mp['3'] = 3;
    mp['4'] = 4;
    mp['5'] = 5;
    mp['6'] = 6;
    mp['7'] = 7;
    mp['8'] = 8;
    mp['9'] = 9;
    mp['A'] = 10;
    mp['B'] = 11;
    mp['C'] = 12;
    mp['D'] = 13;
    mp['E'] = 14;
    mp['F'] = 15;
    if(x.size() > y.size()){
        cout << ">";
    }else if(x.size() < y.size()){
        cout << "<";
    }else {
        for(int i = 0; i < x.size(); i++){
            int a = mp[x[i]];
            int b = mp[y[i]];
            if(a > b){
                cout << ">";
                return 0;
            }
            if(b > a){
                cout << "<";
                return 0;
            }
        }
        cout << "=";
    }
    return 0;
}


Measured memory_bytes: 256
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def count_group(self, n):
        return len({self.find(x) for x in range(1, n + 1)})

n, m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i == j:continue
        a, b = ab[j]
        uf.union(a, b)

    if uf.count_group(n) != 1:cnt += 1
print(cnt)

Measured memory_bytes: 42608
s = input()

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] in {'R','U','D'}:
            continue
        else:
            print('No')
            exit()
    if i% 2 != 0:
        if s[i] in {'L','U','D'}:
            continue
        else:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using ll = long long;
using P = pair<int,int>;



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	ll n; cin >> n;
	
	vector<ll> a(n); rep(i,n) cin >> a[i];
	
	
	sort(rall(a));
	priority_queue<int> q;
	q.push(a[0]);

	ll ans = 0;
	
	for(int i = 1;i<n;i++){
		int v = q.top(); q.pop();
		ans += v;
		q.push(a[i]);
		q.push(a[i]);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 5844
#include <bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define int long long int
using namespace std;

const int N = 1e6+5;
const int mod = 1e9+7;

vector<vector<int>> g(N);
void solve() {
	int n,m;
	cin >> n >> m;
	vector<int> h(n+1);
	for(int i=1;i<=n;i++)
		cin >> h[i];
	int u,v;
	while(m--) {
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	int cnt = 0;
	for(int i=1;i<n+1;i++) {
		int cur = h[i];
		int flg = 0;
		for(int j=0;j<g[i].size();j++) {
			if(cur <= h[g[i][j]])
				flg = 1;
		}
		if(flg == 0)
			cnt++;
	}
	cout << cnt;
	return;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int testcases = 1,i = 1;
	//cin >> testcases;
    while(testcases--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 30892
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();

		sc.close();

		String[] regex = { ".*keyence", "k.*eyence", "ke.*yence", "key.*ence", "keye.*nce", "keyen.*ce", "keyenc.*e",
				"keyence.*", };

		String ans = "NO";
		for (String r : regex) {
			if (S.matches(r)) {
				ans = "YES";
			}
		}

		out.println(ans);

	}

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


Measured memory_bytes: 21972
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<list>
#include<stack>
#include<queue>
#include<iomanip>
#include<time.h> 
#define ff first
#define ss second 
#define li list<int>
#define vi vector<int>
#define ll long long
#define vvi vector<vector<int> >
#define vii vector<pair<int,int> >
#define forl(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define custom  pair<int,pair<int,int> >
#define mod 1000000007
using namespace std;
double dp[301][301][301];
double sol(int x,int y,int z,int n){
    if(x<0 || y<0 || z<0){
        return 0;
    }
    if(x==0 && y==0 && z==0){
        return 0;
    }
    if(dp[x][y][z]>-0.9)
    return dp[x][y][z];
    return dp[x][y][z]=(n+x*sol(x-1,y,z,n)+y*sol(x+1,y-1,z,n)+z*sol(x,y+1,z-1,n))/(x+y+z);
    
}
int main(){
    int n;
    cin>>n;
    double v[n];
    int x,y,z;
    x=y=z=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(v[i]==1)
        x++;
        if(v[i]==2)
        y++;
        if(v[i]==3)
        z++;
    }
    //cout<<"x "<<x<<" y "<<y<<" z "<<z<<endl;
    memset(dp,-1,sizeof dp);
    cout<<setprecision(10)<<sol(x,y,z,n);
    return 0;
}      

Measured memory_bytes: 213376
def check(x, y)
  return 'Yes' if x == y
  4.times do
    a, b, c, d, e, f  = x
    x = [e, a, c, d, f, b]
    return 'Yes' if x == y
    c = x
    4.times do
      i, j, k, l, m, n = c
      c = [i, k, m, j, l, n]
      return 'Yes' if c == y
    end
  end

  4.times do
    a, b, c, d, e, f  = x
    x = [d, b, a, f, e, c]
    return 'Yes' if x == y
    c = x
    4.times do
      i, j, k, l, m, n = c
      c = [i, k, m, j, l, n]
      return 'Yes' if c == y
    end
  end
  'No'
end

puts check(*$<.map(&:chomp).map(&:split))

Measured memory_bytes: 8712
S=list(input())
ans=103
for i in range(26):
  A=[-1]
  for j in range(len(S)):
    if S[j]==chr(i+97):
      A.append(j)
  A.append(j+1)
  a=0
  for j in range(len(A)-1):
    a=max(a,A[j+1]-A[j]-1)
  if a<ans:
    ans=a
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int i, j, tmp,n;
	int data[101];


		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d", &data[i]);
		}

	for (i = n-1; i > 0; i--)//上を繰り返し後、画面に出力。
	{
		printf("%d ",data[i]);
	}
	printf("%d\n",data[0]);

	return 0;//おわり。
}


Measured memory_bytes: 2036
n,m=map(int,input().split())
mist=[0 for i in range(m)]
for j in range(n):
    temp=list(map(int,input().split()))
    for s in range(1,len(temp)):
        mist[temp[s]-1]+=1

ans=sum(1 for x in mist if x==n)

print(ans)

Measured memory_bytes: 9128
#include <cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,d;
    cin>>n>>d;
    ll x[n][d];
    rep(0,i,n){
        rep(0,j,d)cin>>x[i][j];
    }
    ll ans=0;
    rep(0,i,n){
        rep(i+1,j,n){
            ld dis=0;
            rep(0,k,d){
                dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            dis=sqrt(dis);
            if((ll)dis==dis)++ans;
            
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256