akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0048
{
    public class Program

    {
        public static void Main(string[] args)
        {
            SortedDictionary<int, string> ranks = new SortedDictionary<int, string>
            {
                  {48,"light fly" }
                , {51,"fly" }
                , {54,"bantam"}
                , {57,"feather" }
                , {60,"light"}
                , {64,"light welter"}
                , {69,"welter"}
                , {75,"light middle" }
                , {81,"middle"}
                , {91,"light heavy"}
                , {150,"heavy"}
            };

            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;
                Console.WriteLine(ranks.Where(x => decimal.Parse(line) <= x.Key).First().Value);
            }
        }
    }
}




Measured memory_bytes: 17128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    vector<int> arr(n);for(int i=0; i<n; i++)cin>>arr[i];

    vector<int> dp(n,INT_MAX);
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i=1; i<n; i++){
      for(int j=1; i-j>=0 && j<=k; j++)
      dp[i] = min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int head[maxn], cnt = 1, inq[maxn], n, m, d[maxn], flag;
struct Node {int v, nxt, w;} G[maxn << 1];
void ins(int u, int v, int w) {G[cnt] = (Node) {v, head[u], w}; head[u] = cnt++;}
void spfa(int x, int col) {
	if(flag) return;
	inq[x] = col;
	for (int i = head[x]; i; i = G[i].nxt) {
		int v = G[i].v;
		if(d[v] > d[x] + G[i].w) {
			d[v] = d[x] + G[i].w;
			if(!inq[v]) spfa(v, col);
			if(flag) return;
			else if(inq[v] == col) {flag = 1; return;}
		}
	}
	inq[x] = 0;
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int x, y, z; scanf("%d%d%d", &x, &y, &z); ins(y, x, -z); ins(x, y, z);
	}
	memset(d, 0x3f, sizeof d); 
	for (int i = 1; i <= n; ++i) {
	    d[i] = 0;
		spfa(i, i);
		if(flag) {puts("No"); break;}
	}
	if(!flag) puts("Yes");
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2010;

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  
  vector<vector<bool> > dp(n+1, vector<bool>(MAX, false));
  dp[0][0] = true;
  for (int i = 1; i < n+1; i++) {
    for (int j = 0; j < MAX; j++) {
      dp[i][j] = dp[i-1][j];
      if (j - A[i-1] >= 0) {
        dp[i][j] = dp[i][j] || dp[i-1][j-A[i-1]];
      }
    }
  }

  int q;
  cin >> q;
  int num;
  for (int i = 0; i < q; i++) {
    cin >> num;
    if (dp[n][num]) {
      cout << "yes" << endl;
    }
    else {
      cout << "no" << endl;
    }
  }
}


Measured memory_bytes: 3156
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int h, prev=0, highest=0;
    for (int i=0; i<n; i++) {
        cin >> h;
        if (h < highest-1) {
            cout << "No" << endl;
            return 0;
        } else if (h > prev) {
            highest = h;
        }
        prev = h;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}
vector<ll>p(5100);
vector<ll>score(5100);
bool b[5100];
vector<ll>all;
void dfs(ll v,ll sum){
   if(b[v]==1) return;
   b[v] = 1;
   sum += score[p[v]];
   all.push_back(sum);
   dfs(p[v],sum);
}
void solve(){
    ll n,k;
    cin >> n >> k;
    ll ans = -1e18;
    for(ll i = 0;i<n;i++){
        cin >> p[i];p[i]--;
    }
    for(ll i = 0;i<n;i++) cin >> score[i];
    for(ll i = 0;i<n;i++){
        memset(b,0,sizeof(b));
        all.clear();
        dfs(i,0);
        ll q = k/all.size();
        ll rem = k%all.size();
        ll maxi = -1e18;
    if(q&&all.back()>0){
        for(ll j = 0;j<all.size();j++) maxi = max(maxi,all[j]);
        ans = max(all.back()*(q-1)+maxi,ans);
        maxi = 0;
        for(ll j = 0;j<rem;j++) maxi = max(maxi,all[j]);
        ans = max(ans,all.back()*q+maxi);
    }
    else{
        for(int i = 0;i<k;i++){
        if(i>=all.size()) break;
        ans = max(ans,all[i]);
    }
    }}
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3956
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int a[100], C, i, N, W;
	double k;
	scanf("%d", &N);
	for (i=0;i<N;i++) scanf("%d", &a[i]);

	C = 0;
	k = 0.0;
	for (i=0;i<N;i++) k += (double)a[i];
	k /= N;
	W = nearbyint(k);
	for (i=0;i<N;i++) C += (a[i]-W)*(a[i]-W);

	printf("%d\n", C);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    solve(new Scanner(System.in))
  }

  def solve(sc: Scanner): Unit = {
    val N = sc.nextInt
    val X = sc.nextInt
    val m = Array.fill(N)(sc.nextInt)
    println(N + (X - m.sum) / m.min)

  }
}


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

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

  int n,m;
  cin>>n>>m;
  int total = 0;
  vector<int> items(n);
  for(int i=0; i<n; ++i){
    cin>>items[i];
    total += items[i];
  }
  int cnt = 0;
  for(auto i : items){
    if( i * 4 * m >= total ){ ++cnt; }
  }
  if( cnt >= m ){ cout<<"Yes\n"; }
  else{ cout<<"No\n"; }

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<tuple<int, int, int>> txy(N+1);
    txy[0] = make_tuple(0, 0, 0);
    for(int i=1; i<=N; i++){
        int t, x, y;
        cin >> t >> x >> y;
        txy[i] = make_tuple(t, x, y);
    }
    for(int i=1; i<=N; i++){
        int t0, x0, y0;
        int t1, x1, y1;
        tie(t0, x0, y0) = txy[i-1];
        tie(t1, x1, y1) = txy[i];
        int dt = t1-t0;
        int dx = x1-x0;
        int dy = y1-y0;
        int d = abs(dx) + abs(dy);
        if(dt < d){
            cout << "No" << endl;
            return 0;
        }
        int tmp = dt - d;
        if(tmp % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int D, N;
    cin >> D >> N;
    int res;
    int base;
    switch (D) {
    case 0:
        base = 1;
        res = N;
        break;
    case 1:
        base = 100;
        res = N * base;
        break;
    case 2:
        base = 10000;
        res = N * base;
        break;
    }
    if (N == 100) res += base;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, K, ans=0;
  cin >> N >> K;
  int d[K], A[K][N];
  bool flags[N];
  for(int i=0; i<K; i++){
    cin >> d[i];
    for(int j=0; j<d[i]; j++) cin >> A[i][j];
  }
  for(int i=0; i<N; i++) flags[i] = true;
  for(int i=0; i<K; i++){
    for(int j=0; j<d[i]; j++){
      flags[A[i][j]-1] = false;
    }
  }
  for(int i=0; i<N; i++){
    if(flags[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	string s;
	cin >> s;
	if (sz(s) == 6 && s[2] == s[3] && s[4] == s[5])
		cout << "Yes\n";
	else
		cout << "No\n";
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 N;
  vector<vector<int64>> A(2, vector<int64>(3));
  cin >> N;
  REP(i, 2) REP(j, 3) cin >> A[i][j];
  vector<int64> dp(N+1, 0);
  dp[N] = N;
  REP(i, 3) {
    REP(j, dp.size()) {
      if (j + A[0][i] < dp.size()) {
        chmax(dp[j+A[0][i]], dp[j] + A[1][i]);
      }
    }
  } 
  int64 nN = 0;
  REP(i, dp.size()) nN = max(nN, dp[i] + N-i);
  dp = vector<int64>(nN+1, 0);
  dp[nN] = nN;
  REP(i, 3) {
    REP(j, dp.size()) {
      if (j + A[1][i] < dp.size()) {
        chmax(dp[j+A[1][i]], dp[j] + A[0][i]);
      }
    }
  } 
  int64 res = 0;
  REP(i, dp.size()) chmax(res, dp[i] + nN-i);
  cout << res << endl;
}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef complex<double> base;
ll mod=1e9+7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
const double PI=3.141592653589793238462643;

void fft(vector<base> &a, bool inv)
{
	int n=a.size(), j=0;
	vector<base> roots(n/2);
	for(int i=1; i<n; i++)
	{
		int bit=(n>>1);
		while(j>=bit)
		{
			j-=bit;
			bit>>=1;
		}
		j+=bit;
		if(i<j) swap(a[i],a[j]);
	}
	double ang=2*acos(-1)/n*(inv?-1:1);
	for(int i=0; i<n/2; i++) roots[i]=base(cos(ang*i), sin(ang*i));
	for(int i=2; i<=n; i<<=1)
	{
		int step=n/i;
		for(int j=0; j<n; j+=i)
		{
			for(int k=0; k<i/2; k++)
			{
				base u=a[j+k], v=a[j+k+i/2]*roots[step*k];
				a[j+k]=u+v;
				a[j+k+i/2]=u-v;
			}
		}
	}
	if(inv) for(int i=0; i<n; i++) a[i] /= n;
}

vector<ll> multiply(vector<ll> &v, vector<ll> &w)
{
	int n=2; while(n<v.size()+w.size()) n<<=1;
	vector<base> v1(n), v2(n), r1(n), r2(n);
	for(int i=0; i<v.size(); i++) v1[i]=base(v[i]>>15, v[i]&32767);
	for(int i=0; i<w.size(); i++) v2[i]=base(w[i]>>15, w[i]&32767);
	fft(v1, false); fft(v2, false);
	for(int i=0; i<n; i++)
	{
		int j=(i?(n-i):i);
		base ans1=(v1[i]+conj(v1[j]))*base(0.5, 0);
		base ans2=(v1[i]-conj(v1[j]))*base(0, -0.5);
		base ans3=(v2[i]+conj(v2[j]))*base(0.5, 0);
		base ans4=(v2[i]-conj(v2[j]))*base(0, -0.5);
		r1[i]=(ans1*ans3)+(ans1*ans4)*base(0, 1);
		r2[i]=(ans2*ans3)+(ans2*ans4)*base(0, 1);
	}
	fft(r1, true); fft(r2, true);
	vector<ll> ret(n);
	for(int i=0; i<n; i++)
	{
		ll av=(ll)round(r1[i].real());
		ll bv=(ll)round(r1[i].imag())+(ll)round(r2[i].real());
		ll cv=(ll)round(r2[i].imag());
		av%=mod, bv%=mod, cv%=mod;
		ret[i]=(av<<30)+(bv<<15)+cv;
		ret[i]=(ret[i]%mod+mod)%mod;
	}
	return ret;
}

ll fac[900010],invf[900010],pw3[600010];

int main()
{
	ios_base::sync_with_stdio(false);
	int n,m,k,i;
	cin>>n>>m>>k;
	fac[0]=1;
	for(i=0;i++<n+m+k;)
		fac[i]=fac[i-1]*i%mod;
	invf[n+m+k]=exp(fac[n+m+k],mod-2);
	for(i=n+m+k;i>0;i--)
		invf[i-1]=invf[i]*i%mod;
	for(i=1;i<=m+k;i*=2);
	vector<ll>x(i,0),y(i,0);
	for(i=0;i<=m;i++)
		x[i]=invf[i];
	for(i=0;i<=k;i++)
		y[i]=invf[i];
	x=multiply(x,y);
	pw3[0]=1;
	for(i=0;i++<m+k;)
		pw3[i]=pw3[i-1]*3%mod;
	ll ans=0;
	for(i=0;i<=m+k;i++)
		ans=(ans+x[i]*pw3[m+k-i]%mod*fac[n-1+i]%mod*invf[n-1])%mod;
	cout<<ans<<endl;
	return 0;
}

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

int main(void){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A.at(i);

    ll ans = 0;
    ll sum_value = 0;
    ll mod_value = 1000000007;

    rep(i,N-1){
        sum_value += A.at(i);
        sum_value %= mod_value;
        ll multi_value = sum_value*A.at(i+1);
        multi_value %= mod_value;
        ans += multi_value;
        ans %= mod_value;
    }

    cout << ans << endl;

    return 0;
}

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

ll N;
vvll G;
map<pair<ll, ll>, ll> mp;
ll ma = 0;

void dfs(ll n, ll pre, ll col) {
    for (auto nv: G[n]) {
        if (nv == pre) continue; //　そこからきたのならなにもしない
        col++;
        col %= ma;
        ll a = n, b = nv;
        if (a > b) swap(a, b);
        if (mp[{a, b}] > 0) continue;
        mp[{a, b}] = col + 1;
        dfs(nv, n, col);
    }
}

int main()
{
    cin >> N;
    G.resize(N);
    vll a(N-1), b(N-1);
    rep(i, N-1) {
        cin >> a[i] >> b[i]; a[i]--, b[i]--;
        if (a[i] > b[i]) swap(a[i], b[i]);
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }    
    ll idx = 0;
    rep(i, N) {
        if (ma < (ll)G[i].size()) {
            idx = i;
            ma = (ll)G[i].size();
        }
    }

    dfs(idx, -1, 0);
    cout << ma << endl;
    rep(i, N - 1) cout << mp[{a[i], b[i]}] << endl;
    return 0;
}

Measured memory_bytes: 16256
#include <iostream> 
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
bool isPrime(long long int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (long long int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
int main ()
{
 long long int n,k;cin>>n;
 if (n<=2) cout<<"2"<<endl;
 else {
     for (long long int i=n;  ;i++) {
         if (i%2==0) continue;
         if (isPrime(i)==true) {
             k=i;break;
         }
     }
     cout<<k<<endl;
 }
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, x;
    cin >> n >> x;

    vector<int64_t> s(n);
    for (auto&& ss : s) {
        cin >> ss;
    }

    sort(s.begin(), s.end());

    constexpr auto M = 1000000007L;
    vector<vector<int64_t>> dp(n, vector<int64_t>(x + 1));

    for (auto j : irange(0L, x + 1)) {
        dp[0][j] = j % s[0];
    }
    for (auto i : irange(1L, n)) {
        for (auto j : irange(0L, x + 1)) {
            dp[i][j] = (dp[i - 1][j % s[i]] + dp[i - 1][j] * i % M) % M;
        }
    }

    cout << dp[n - 1][x] << endl;
}

Measured memory_bytes: 157824
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
if M <= N:
    print(0)
else:
    Y = []
    for i in range(1, len(X)):
        Y.append(X[i] - X[i-1])
    Y = sorted(Y)
    if N == 1:
        print(sum(Y))
    else:
        print(sum(Y[:-(N-1)]))


Measured memory_bytes: 13960
s=input()
t=input()
ss=list(set(s))
st=list(set(t))
s_cnt=[0]*len(ss)
t_cnt=[0]*len(st)
ans='No'
for i in range(len(ss)):
    s_cnt[i]=s.count(ss[i])
for i in range(len(st)):
    t_cnt[i]=t.count(st[i])
s_cnt.sort()
t_cnt.sort()
if  s_cnt==t_cnt:
    ans='Yes'
print(ans)

Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}



ll i,j,k,ii,jj;
ll n,m,num;
ll a,b,c,e,f,g,h;
ll x[800005],y[800005],z[900005];
ll in[800005];
ll vnum = 0,sum,ans;
bool dame;
bool check[500005];


int main(){
    cin>>n>>a;
	ans = INF;
	for(i=0;i<n;i++){
		cin>>b>>c;
		if(c <= a){
			ans = min(ans,b);
		}
	}
	if(ans==INF){
		p("TLE");
	}else{
		p(ans);
	}
	return 0;

}


Measured memory_bytes: 25344
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    int a, b, x;
    scan(a, b, x);

    writeln(0 <= x - a && x - a <= b ? "YES" : "NO");
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

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

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

const int MAXN = 1e5 + 5;

int solve() {
  int n, k; cin >> n >> k;

  while(n % k != 0 && n >= k) {
    int diff = n - (n / k) * k;
    int jump = n / k + 1;
    int koef = max(1, diff / jump);

    n -= koef * jump;
  }

  if(n < k)
    return 0;
  return n / k;
}

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

  int X = 0;

  int n; cin >> n;
  REP(i, n) {
    X ^= solve();
  }

  if(!X) {
    cout << "Aoki\n";
  }
  else {
    cout << "Takahashi\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <climits>
using namespace std;


int main()
{
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    
    int result = INT_MAX;
    for (int i = 0; i <= 100000; i++) {
        int sum = 2 * C * i + max(0, X - i) * A + max(0, Y - i) * B;
        result = min(result, sum);
    }
    
    cout << result << endl;
}

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

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

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

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

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,a;
  cin >> h >> a;
  cout << (h / a) + (h % a != 0) << endl;
  return 0;
}


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

k=len(bin(max(l)))-2

for i in range(n):
    l[i]=bin(l[i])[2:]

ll=[[0,0] for i in range(k)]
for i in range(n):
    for j in range(k):
        try:
            if l[i][-1-j]=="1":
                ll[j][1]+=1
            if l[i][-1-j]=="0":
                ll[j][0]+=1
        except IndexError:
            ll[j][0]+=1

m=0
for i in range(k):
    m+=ll[i][0]*ll[i][1]*(2**i)
print(m%(10**9+7))


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

int main()
{
	int n,k,sum=0;
	cin>>n>>k;
	
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n;i>=n-k+1;i--) sum+=a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
while(true) {
int n;
scanf("%d", &n);
if(n == 0)
break;
for(int i = 0; i < 9; ++i) {
int t;
scanf("%d", &t);
n -= t;
}
printf("%d\n", n);
}
return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int mod = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int r;
    cin >> r;

    cout << r * r << endl;



    return 0;
}



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

typedef long long int ll;

int main()
{
	ll i,j,k,l,m,n,t,a,b,c,d;

	ll x1,x2,y1,y2;
	
	cin >> n >> m;

	if(m>=n)
		cout << "unsafe\n";
	else
		cout << "safe\n";
	
}

Measured memory_bytes: 3592
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
            map.put(a[i], map.getOrDefault(a[i], 0) +1);
        }
        
        long c = 0;
        for (Integer i : map.keySet()) {
            long j = map.get(i);
            if(j >= 2){
                c += (j * (j-1)) /2;
            }
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(c - (map.get(a[i]) -1)).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}

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

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


Measured memory_bytes: 256
package main

import (
	"fmt"
)

// main is ...
func main() {
	var a, b int
	fmt.Scan(&a, &b)

	isValid := isValid(a) && isValid(b)
	if isValid {
		fmt.Print(a * b)
		return

	}

	fmt.Print(-1)
}

func isValid(a int) bool {
	return 0 <= a && a < 10
}



Measured memory_bytes: 512
#include <stdio.h>
 int main(void){
  int a;
  double b;
  char c[4]={0};
  int i;
  double sum=0,sum1=0;
   scanf("%d",&a);

  for(i=0;i<a;i++){
   scanf("%lf",&b);
   scanf("%s",c);
   if(c[0]=='J')
    if(c[1]=='P')
     if(c[2]=='Y')
      sum=sum+b;
   if(c[0]=='B')
    if(c[1]=='T')
     if(c[2]=='C')
      sum1=sum1+380000*b;
}
  printf("%lf",sum+sum1);

   return 0;
 }


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N, M;
        {int[] a = r.ii(); N = a[0]; M = a[1];}
        int d = Math.abs(N-M);
        long[] fact = new long[Math.max(N, M)+1];
        fact[0] = 1;
        for(int i = 1; i < fact.length; i++)
            fact[i] = fact[i-1]*i%1000000007;
        long temp = fact[N]*fact[M]%1000000007;
        println(d == 0 ? 2*temp%1000000007 : d == 1 ? temp : 0);
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }

        int[] ii(int N) throws IOException{
            int[] ii = new int[N];
            for(int i = 0; i < N; i++) ii[i] = i();
            return ii;
        }

    }
}

Measured memory_bytes: 23124
#include <stdio.h>
int main(void){
    
    int n,t,c;
    
    scanf("%d",&n);
    t=n; c=0;
    
    while(t>0){
        c+=t%10; t/=10;    
    }
    
    if(n%c==0) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 1660
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
int main (){
    cin >> N;
    long long int p = 1;
    for(int i=1; i<N+1; i++){
        p = (p * i) % 1000000007;
    }
    cout << p << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
const int maxn=100001;

signed main(){
	int n;cin>>n;
  	vector<int> v(n);
  	for(auto&& w:v)cin>>w;
	vector<p> even(maxn),odd(maxn);
	for(int i=0;i<maxn;i++)even[i]=odd[i]=make_pair(i,0);	
	for(int i=0;i<n;i++){
	if(i%2==0){
      (even[v[i]].second)++;
    }else{
      (odd[v[i]].second)++;
	}
    }  
	sort(even.begin(),even.end(),[&](p x,p y){return x.second>y.second;});
	sort(odd.begin(),odd.end(),[&](p x,p y){return x.second>y.second;});
	int ans;
	if(even[0].first==odd[0].first){
      ans=min(n-odd[0].second-even[1].second,n-odd[1].second-even[0].second);
    }else{
      ans=n-odd[0].second-even[0].second;
    }
    cout<<ans<<endl;
	
}


Measured memory_bytes: 2176
mod = 10**9+7
fact = [1]
fact_inv = [1]
for i in range(10**5):
  new_fact = fact[-1]*(i+1)%mod
  fact.append(new_fact)
  fact_inv.append(pow(new_fact,mod-2,mod))

def mod_comb_k(n,k,mod):
  return fact[n]*fact_inv[k]%mod*fact_inv[n-k]%mod

N,K = map(int,input().split())
arr = list(map(int,input().split()))
arr = sorted(arr)
_max = 0
_min = 0
for i in range(K-1,N):
  _max += arr[i]*mod_comb_k(i,K-1,mod)
  _min += arr[i-K+1]*mod_comb_k(N-i+K-2,K-1,mod)
print((_max-_min)%mod)

Measured memory_bytes: 22596
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <random>
using namespace std;

/**
 * 解毒剤入り美味しくないクッキー: A枚
 * 解毒剤入り美味しいクッキー: B枚
 * 毒入り美味しいクッキー: C枚
 * 
 * [ 通常 ] -- 毒入り -> [ 腹痛 ] -X- 毒入り -> [ 死亡 ]
 *         <- 解毒剤 --
 * 
 * Q: 食べられる美味しいクッキーの枚数の最大値
 */
int main ()
{
	int A, B, C;
	cin >> A >> B >> C;

	/**
	 * 解毒剤が十分に多い場合，
	 * 毒入りクッキーを食べずに余った美味しいクッキーを
	 * ほおばればよいので，解毒剤はすべて食べられる．
	 * 
	 * 毒入りは，必ず解毒しなければならないので，
	 * 食べられるのは解毒剤の数(A + B)プラス1枚まで．
	 */

	int edible_delicious_poisonous_cookie = min(C, A + B + 1);
	int edible_delicious_antidote_cookie = B;

	int edible_delicious_cookie = edible_delicious_poisonous_cookie + edible_delicious_antidote_cookie;

	cout << edible_delicious_cookie << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] cut = input.split(" ");
        int surface = Integer.parseInt(cut[0]);
        int length = Integer.parseInt(cut[1]);
        System.out.println(surface * length + " " + 2 * ( surface + length ));
    }
}

Measured memory_bytes: 24076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();

		int count = 0;
		for(int i =0; i< N; i++) {
			if(A.charAt(i) == B.charAt(i) && A.charAt(i) == C.charAt(i)) {
				//全部一緒はつぎへ
				continue;
			}

			if(A.charAt(i) != B.charAt(i) && A.charAt(i) == C.charAt(i)) {
				//Bだけ違う
				count++;
				continue;
			}
			if(A.charAt(i) == B.charAt(i) && A.charAt(i) != C.charAt(i)) {
				//Ｃだけ
				count++;
				continue;
			}
			if(A.charAt(i) != B.charAt(i) && A.charAt(i) != C.charAt(i) && B.charAt(i) != C.charAt(i) ) {
				//AもBもCも違う
				count = count + 2;
				continue;
			}
			if(A.charAt(i) != B.charAt(i) && A.charAt(i) != C.charAt(i) && B.charAt(i) == C.charAt(i)) {
				count++;
				continue;
			}
		}

        System.out.println(count);


	}

}

Measured memory_bytes: 21844
function main(input){
    input = input.split(' ');
    inputA = parseInt(input[0]);
    inputB = parseInt(input[1]);
    out = 0;
    
    out=Math.ceil(inputA/inputB);
  	
    console.log(out);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        M: usize,
        X: i64,
        Y: i64,
        mut Xs: [i64; N],
        mut Ys: [i64; M],
    }

    Xs.sort();
    Ys.sort();

    let mut is_ok = false;
    for z in X + 1..=Y {
        if Xs[N - 1] < z && z <= Ys[0] {
            is_ok = true;
            break;
        }
    }

    if is_ok {
        println!("No War");
    } else {
        println!("War");
    }
}


Measured memory_bytes: 2172
Num = input()
if Num[-1] == "3":
    print("bon")
elif Num[-1] == "0":
    print("pon")
elif Num[-1] == "1":
    print("pon")
elif Num[-1] == "6":
    print("pon")
elif Num[-1] == "8":
    print("pon")
else:
    print("hon")


Measured memory_bytes: 9112
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
 int n,m,t0=1;
 cin>>n;
 queue<int> que;
 int n0=n;
 while(t0<n)t0*=2;
 if(t0==n){
   cout<<"No"<<endl;
   return 0;
 }
 t0/=2;
 bool used[(n>>2)]={};
 m=n;
 cout<<"Yes"<<endl;
 if(n0-t0!=2){
que.push(n);
 while(n%4!=0&&n!=1){
   cout<<n<<' '<<n-1<<endl;
   n--;
   m^=n;
    que.push(n);
 }
 int t=n;
 if(m%4){
   cout<<t<<' '<<m%4<<endl;
   t=(m%4);
   m^=(m%4);
   used[0]=true;
 }
 for(int i=0;m>=(1ll<<i);i++)if(m&(1ll<<i)){
cout<<t<<' '<<(1ll<<i)<<endl;
t=(1ll<<i);
used[t>>2]=true;
 }
 while(!que.empty()){
   cout<<t<<' '<<n0+que.front()<<endl;
  t=n0+que.front();
  que.pop();
 }
 }else{
   cout<<n0<<' '<<n0-1<<endl;
   cout<<2<<' '<<n0+n0<<endl;
     cout<<n0-1<<' '<<n0-2<<endl;
       cout<<1<<' '<<n0-1<<endl;
        cout<<n0+n0-1<<' '<<n0+n0-2<<endl;
       cout<<1<<' '<<n0+n0-2<<endl;
       n-=(n%4);
       used[0]=true;
 }

  if(n/4==0)return 0;
  if(!used[0])cout<<n<<' '<<1<<endl;
   for(int j=1;j<3;j++)cout<<j<<' '<<(1+j)<<endl;
   cout<<3<<' '<<n0+1<<endl;
   for(int j=1;j<3;j++)cout<<n0+j<<' '<<(n0+1+j)<<endl;

 for(int i=1;i*4<n;i++){
   if(!used[i])cout<<n<<' '<<(i<<2)<<endl;
   for(int j=0;j<3;j++)cout<<(i<<2)+j<<' '<<((i<<2)+1+j)<<endl;
   cout<<(i<<2)+3<<' '<<(i<<2)+n0<<endl;
   for(int j=0;j<3;j++)cout<<(i<<2)+n0+j<<' '<<((i<<2)+n0+1+j)<<endl;
 }
 




}


        


Measured memory_bytes: 2816
import numpy as np
import sys

n = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))

if sum(A) < sum(B):
    print(-1)
    sys.exit()
c = A - B
c.sort()
i = 0
j = n - 1
ans = 2
if c[0] >= 0:
    print(0)
    sys.exit()
while True:
    if c[i] < 0:
        if c[j] + c[i] >= 0:
            c[j] += c[i]
            c[i] = 0
        else:
            c[i] += c[j]
            c[j] = 0
            j -= 1
            ans += 1
    else:
        if c[i + 1] >= 0:
            break
        else:
            i += 1
            ans += 1
print(ans)


Measured memory_bytes: 31644
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s, t, u;
  int  n, m;
  cin >> s >> t;
  cin >> n >> m;
  cin >> u;
  if(u == t){
    m--;
  }else{
    n--;
  }
  
  
  cout << n << " "<< m <<endl;
}


Measured memory_bytes: 256
# coding: utf-8

N, M = map(int,input().split())
A = []
B = []
for i in range(N):
    A.append(list(input()))

for i in range(M):
    B.append(list(input()))
    
w = len(B[0])
flg = False    
for i in range(N-M+1):
    if flg:
        break
    
    for j in range(len(A[0])-len(B[0])+1):
        if flg:
            break
        cnt = 0
        for k in range(M):
            #print(i+k)
            #print(A[i+k][j:j+w], B[i+k])
            #print(k, j,j+w)
            if A[i+k][j:j+w] == B[k]:
                cnt += 1
        if cnt == M:
            flg = True
            break

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9164
void main(){
	int r, g, b;
	scanf("%d %d %d", &r, &g, &b);
	( (100*r+10*g+b)%4?"NO":"YES").writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2440
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;

struct node {
    char name[50];
    int begin_time,end_time;
    bool flag;
}f[550];

int dp[4000 * 7];
bool cmp(node a, node b) {
    return a.end_time < b.end_time;
}

int Max(int a, int b) {
    return a > b ? a : b;
}


vector<int>::iterator v_iter;
map<int , int >::iterator iter;
int main(){
    int n;
    char str[50];
    int week, t;
    while(~scanf("%d", &n) && n) {
		int num = 1;
		vector<int>coll[550];
        int ans = 0;
        map<int, int>flag;
        map<string, int>M;
        for(int i = 0; i < n; ++ i) {
            memset(dp, 0, sizeof(dp));
            scanf("%s %d %d", f[i].name, &week, &t);
            t += week * 2400 ;
            f[i].begin_time = t;
            t = f[i].begin_time % 100;
            t += 30;
            if(t > 60){
                t = t % 60 + 100;
            }
            f[i].end_time = t + f[i].begin_time / 100 * 100;
            f[i].flag = 0;
        }
		
        sort(f,f+n,cmp);
		
        int m;
		for(int i = 0; i < n; ++ i) {
			M[f[i].name] = i;
		}
		/**
		for(int i = 0; i < n; ++ i) {
			printf("%s %d %d\n", f[i].name, f[i].begin_time, f[i].end_time);
		}
		**/
        scanf("%d", &m);
        for(int i = 0; i < m; ++ i) {
            scanf("%s", str);
            int index = M[str];
            f[index].flag = 1;
        }
		bool note = 0;
		for(int i = 0; i < n; ++ i) {
			if(f[i].flag == 0)continue;
			for(int j = i + 1; j < n; ++ j) {
				if(f[j].flag == 0)continue;
				if(f[i].end_time > f[j].begin_time && f[i].end_time < f[j].end_time){
					note = 1;
					break;
				}
				if(f[j].end_time > f[i].begin_time && f[j].end_time < f[i].end_time){
					note = 1;
					break;
				}
			}
			if(note == 1)break;
		}
		if(note) {
			printf("-1\n");
			continue;
		}
        for(int i = 0; i < n; ++ i) {
			int index = flag[f[i].end_time];
			if( index == 0) {
				flag[f[i].end_time] = num;
				coll[num ++].push_back(i);
			} else {
				coll[index].push_back(i);
			}
        }
        
        for(int i = 1; i < 7 * 4000; ++ i) {
            iter = flag.find(i);
            if(iter != flag.end()) {
				int index = iter -> second;
				int size = coll[index].size();
				int stt,edt;
				stt = f[coll[index][0]].begin_time;
				edt = f[coll[index][0]].end_time;
				for(int j = 0; j < size; ++ j) {
					if(f[coll[index][j]].flag == 1) {	
						for(int k = stt + 1; k < edt; ++ k) {
							dp[k] = -0x7f7f7f7f;
						}
					}
				}
				
                dp[i] = Max(Max(dp[i], dp[stt] + 1), dp[i-1]);
				//printf("%d %d,", i, dp[i]);
            } else dp[i] = dp[i - 1];
            ans = Max(ans, dp[i]);
        }
        printf("%d\n", ans);
    }return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  int n;
  cin >> n;
  int a[n];
  int ma = -1, dx;
  string ans = "Yes";
  rep(i, n){
    cin >> a[i];
    if(a[i] < ma - 1) ans = "No";
    if(a[i] > ma){
      ma = a[i];
      dx = i;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4004
S = input()
A = int(S[:2])
B = int(S[2:])
f1 = 1 <= A <= 12
f2 = 1 <= B <= 12
if f1 and f2:
    print('AMBIGUOUS')
elif f1:
    print('MMYY')
elif f2:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#input
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

#output
import numpy as np
V = max(v)
INF = 10**10
dp = np.full((N+1, N*V+1), INF)
dp[0, 0] = 0

for i in range(N):
    dp[i+1, v[i]:] = np.minimum(dp[i, v[i]:], dp[i, :-v[i]]+w[i])
    dp[i+1, :v[i]] = dp[i, :v[i]]

answer = 0
for i in range(N*V+1):
    if dp[N, i] <= W:
        answer = i

print(answer)

Measured memory_bytes: 92936
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int a[10];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)
	{
		int x;
		scanf("%d",&x);
		mp[x]=1;
	}
	int t=n;
	while(true)
	{
		int tt=t;
		bool f=true;
		while(tt)
		{
			if(mp[tt%10])f=false;
			tt/=10;
		}
		if(f)break;
		t++;
	}
	printf("%d",t);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n,k; std::cin >> n >> k;
    std::unordered_map<int, int> m;
    for(int i=0; i<n; i++){
        int b; std::cin >> b;
        if(m.count(b)) m[b]++;
        else m.emplace(b,1);
    }

    if( m.size()<=k ){
        std::cout << 0 << "\n";
        return 0;
    }

    std::vector<int> v;
    for(auto mi : m){
        v.push_back(mi.second);
    }

    std::sort(v.begin(),v.end(),std::greater<int>());

    int cnt=0, ans=0;
    for(auto vi : v){
        cnt++;
        if(cnt>k){
            ans += vi;
        }
    }

    std::cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 13296
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        boolean able = true;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if(i < a[i]) able = false;
            if(0 < i && a[i-1] < a[i] && 1 < a[i] - a[i-1]) able = false;
        }
        if(!able){
            System.out.println(-1);
        }else{
            long ans = 0L;
            int[] b = new int[n];
            Arrays.fill(b, -1);
            for (int i = n-1; i > 0; i--) {
                if(b[i] != a[i]){
                    ans += a[i];
                }
                b[i-1] = a[i] - 1;
            }
            System.out.println(ans);

        }
        sc.close();

    }

}


Measured memory_bytes: 85980
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll calc(ll n){
    return n*(n+1)/2;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans = 0LL;
    for(ll i=1; i<=n; i++){
        ans += calc(i);
    }

    for(ll i=0; i<n-1; i++){
        int u, v;
        cin>>u>>v;
        if(u>v){
            ll t = u;
            u = v;
            v = t;
        }
        assert(u<=v);
        ans -= u*(n-v+1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>

using namespace std;

int L[100001],R[100001];

int main(){
  int i,N,M;
  cin >> N >> M;
  for (i=0;i<M;++i) {
    cin >> L[i] >> R[i];
  }
  sort(L,L+M);
  sort(R,R+M);
  if (R[0]-L[M-1]+1 > 0) {
    cout << (R[0]-L[M-1]+1) << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef tuple<int, int, int> T;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int l;

vector<T> calc(const int c, int L) {
    int i = 1;
    int p = 1;
    vector<T> vec;
    while (p*c <= L) {
        for (int j = 0; j < c; j++) {
            vec.push_back(make_tuple(i, i+1, p*j));
        }
        i++;
        p *= c;
    }

    int N = 20;
    int s = 0;
    i = 1;
    p = 1;
    while (L > 0) {
        int r = L % c;
        for (int k = 0; k < r; k++) {
            vec.push_back(make_tuple(i, N, s));
            s += p;
        }
        i++;
        p *= c;
        L /= c;
    }
    return vec;
}

void solve() {
    for (int c = 3; c < 10; c++) {
        vector<T> ret = calc(c, l);
        if ((int)ret.size() <= 60) {
            cout << 20 << " " << (int)ret.size() << endl;
            for (T t : ret) {
                cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << endl;
            }
            return;
        }
    }
}

void input() {
    cin >> l;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 3664
# from line_profiler import LineProfiler
from collections import deque
from sys import stdin

def main():
    while(True):
        W, H = map(int, stdin.readline().split())
        if not W: break
        tx,ty = map(int, stdin.readline().split())
        kx,ky = map(int, stdin.readline().split())
        ma = [[False]*(W+2) for _ in range(H+2)]
        for i in range(1,H+1):
            for j,a in enumerate(stdin.readline().split()):
                ma[i][j+1] = bool(1-int(a))
        que = deque([[tx,ty,kx,ky,0]])
        pas = set()
        ans = "NA"
        while(que):
            tx,ty,kx,ky,c = que.popleft()
            if c > 100: break
            if tx == kx and ty == ky:
                ans = c
                break
            for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:
                tdx, tdy = [ dx, dy] if ma[ty+dy][tx+dx] else [0,0]
                kdx, kdy = [-dx,-dy] if ma[ky-dy][kx-dx] else [0,0]
                if (tx+tdx,ty+tdy,kx+kdx,ky+kdy) in pas: continue
                que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1])
                pas.add((tx+tdx,ty+tdy,kx+kdx,ky+kdy))
        print(ans)

if __name__ == "__main__":
    # prf = LineProfiler()
    # prf.add_function(main)
    # prf.runcall(main)
    # prf.print_stats()
    main()


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (((A == B) && (B != C)) || ((A == C) && (C != B)) || ((B == C) && (A != B)))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256