akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	int a,b,k;
	cin>>k;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			break;
		}else if(i==b){
			cout<<"NG"<<endl;
		}

	}
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int dp[100005][2],num[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&num[i]);
	}
	num[0]=10000000;
	for(int i=2;i<=n;i++)
	{
		dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(num[i]-num[i-1]);
		dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(num[i]-num[i-2]);
	}
	printf("%d",min(dp[n][0],dp[n][1]));
}

Measured memory_bytes: 1408
a,b = list(map(int,input().split()))
to = 0

while 1:
  to += 100
  c = int(to * 0.08)
  d = int(to * 0.1)
  if c >= a and d >= b:
    to -= 100
    while 1:
      to += 1
      c = int(to * 0.08)
      d = int(to * 0.1)
      if c == a and d == b:
        print(to)
        exit()
      elif to % 100 == 0:
        print(-1)
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> P;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える


int main() {
	int n, k; cin >> n >> k;
	vector<int> p(n);
	rep(i, n) cin >> p[i];

	sort(all(p));

	int s = 0;
	rep(i, k) s += p[i];

	cout << s << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>

using namespace std;

int main(){
  int a,b,k; cin >>a>>b>>k;
  queue<int> que;
  for(int i=b;i>=1;i--){
    if(a%i==0&&b%i==0) que.push(i);
  }
  for(int j=0;j<k-1;j++){
    que.pop();
  }
  cout << que.front() <<endl;
}
  
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf=INT_MAX;
int dp[5000];
vector<int> ls[5000];
int c[5000],r[5000];
int main(){
	int n,k;	cin>>n>>k;
	for(int i=0;i<n;i++)	cin>>c[i]>>r[i];
	for(int i=0;i<k;i++){
		int a,b;	cin>>a>>b;	a--;	b--;
		ls[a].push_back(b);	ls[b].push_back(a);
	}
	for(int i=0;i<n;i++)	dp[i]=inf;
	dp[0]=0;
	priority_queue<pair<int,int>> pq;
	pq.push(make_pair(0,0));
	while(!pq.empty()){
		auto tp=pq.top();	pq.pop();
		int cost=-tp.first,cur=tp.second;
		//cout<<cur<<" "<<cost<<endl;
		if(cost>dp[cur])	continue;
		if(cur==n-1){
			cout<<cost<<endl;
			return 0;
		}
		cost+=c[cur];
		set<int> visited;	visited.insert(cur);
		set<int> now,next;	now.insert(cur);
		for(int i=0;i<r[cur];i++){
			for(auto it=now.begin();it!=now.end();it++){
				for(int j=0;j<(int)ls[*it].size();j++){
					if(visited.find(ls[*it][j])==visited.end()){
						visited.insert(ls[*it][j]);
						next.insert(ls[*it][j]);
						if(dp[ls[*it][j]]>cost){
							dp[ls[*it][j]]=cost;
							pq.push(make_pair(-cost,ls[*it][j]));
						}
					}
				}
			}
			now=next;
		}
	}
	return 0;
}
		

Measured memory_bytes: 2364
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    if (N >= 30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;

  if(abs(c-a)<=d){cout<<"Yes"<<endl;}
  else if(abs(c-b)<=d && abs(b-a)<=d){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
 }

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

int main() {
  int a, b, c, d, e;
  cin >> a;
  b = a - a % 100; // 三の位の百倍
  c = a - b; // 下二桁
  d = c % 10; // 下一桁（＝一の位）
  e = c - d; // 二の位の十倍
  cout << b / 100 + e / 10 + d << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int H, W, a[11][10009], z[10009];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin >> H >> W, H | W) {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) cin >> a[i][j];
		}
		int ret = 0;
		for(int i = 0; i < (1 << H); i++) {
			fill(z, z + W, 0);
			for(int j = 0; j < H; j++) {
				for(int k = 0; k < W; k++) {
					if(i & (1 << j)) z[k] += 1 - a[j][k];
					else z[k] += a[j][k];
				}
			}
			int res = 0;
			for(int j = 0; j < W; j++) {
				res += max(z[j], H - z[j]);
			}
			ret = max(ret, res);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
int main(){
    int n; sc(n);
    bool check = false;
    string s = to_string(n);
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '7') check = true;
    }
    if (check) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define maxn 500005

struct Node{
	int x,y,id;
	Node(){}
	Node(int _x,int _y,int _id){x=_x;y=_y;id=_id;}
}a[maxn];

int sta[maxn],r,c,top;

int cnt=0,n;

bool Judge(int x,int y)
{
	if (x==0||x==r) return true;
	if (y==0||y==c) return true;
	return false;
}

int cal(Node a)
{
	if (a.x==0) return a.y;
	if (a.y==c) return c+a.x;
	if (a.x==r) return r+c+c-a.y;
	else return c+r+c+r-a.x;
}

bool cmp(Node a,Node b)
{
	return cal(a)<cal(b);
}

int main()
{
	
	#ifdef WXL
	freopen("in.txt","r",stdin);
	#endif
	
	scanf("%d%d%d",&r,&c,&n);
	for (int i=1;i<=n;++i)
	{
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if (Judge(x1,y1)&&Judge(x2,y2)){
			a[++cnt]=Node(x1,y1,i);
			a[++cnt]=Node(x2,y2,i);
		}
	}
	
	sort(a+1,a+cnt+1,cmp);
	for (int i=1;i<=cnt;++i){
		if (top&&sta[top]==a[i].id) top--;
		else sta[++top]=a[i].id;
	}
	if (top) printf("NO\n");
	else printf("YES\n");
	
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////

/*（๑•﹏•๑｀) */
int main() {
    int A,B,T;
    cin >> A >> B >> T;
    cout << (T / A) * B << endl;

}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int a[3];
	REP(i,3) cin >> a[i];
	sort(a,a+3);
	if(a[0]!=a[1]) cout << a[0] << endl;
	else cout << a[2] << endl;	
}

Measured memory_bytes: 256
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 3e3 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;
vector <int> a(N);
ll dp[N][N];
bool vis[N][N] = {0};

ll f(int l, int r) {
	if(vis[l][r])	return dp[l][r];

	if (l == r)	return a[l];

	ll t1 = a[l] - f(l + 1, r);
	ll t2 = a[r] - f(l, r - 1);
	dp[l][r] = max (t1, t2);
	vis[l][r] = true;
	return dp[l][r];
}

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	cout << f(0, n - 1);
}

int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

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

template<class Abel> struct UnionFind{
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n = 1,Abel SUM_UNITY = 0){
		init(n,SUM_UNITY);
	}

	void init(int n = 1,Abel SUM_UNITY = 0){
		par.resize(n); rank.resize(n);diff_weight.resize(n);
			for(int i=0;i<n;i++){
				par[i] = i;
				rank[i] = 0;
				diff_weight[i] = 0;
			}
		}
		int root(int x){
			if(par[x] == x)return x;
			else{
				int r = root(par[x]);
				diff_weight[x] += diff_weight[par[x]];
				return par[x] = r;
			}
		}

		Abel weight(int x){
			root(x);
			return diff_weight[x];
		}

		bool issame(int x,int y){
			return root(x)==root(y);
		}

		bool merge(int x, int y, Abel w){
			w += weight(x);w -= weight(y);
			x = root(x);y = root(y);
			if(x == y)return false;
			if(rank[x] < rank[y]){
				int temp = x;
				x = y;
				y = temp;
				w = -w;
			}
			if(rank[x] == rank[y])rank[x]++;
			par[y] = x;
			diff_weight[y] = w;
			return true;
		}
		Abel diff(int x,int y){
			return weight(y)-weight(x);
		}
};

int main(void){
	int N,M;
	cin>>N>>M;
	UnionFind<int> tree(N,0);
	for(int i=0;i<M;i++){
		int l,r,d;
		cin>>l>>r>>d;
		l--;r--;
		if(tree.issame(l,r)){
			int diff = tree.diff(l,r);
			if(diff != d){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
			tree.merge(l,r,d);
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

vector<string> x = {"erase", "eraser", "dream", "dreamer"};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.length();
    vector<char> dp(n + 1, 0);
    dp[n] = 1;
    ford(i, 0, n) {
        for (string t : x) {
            int k = t.length();
            if (i + k <= n && dp[i + k] && string(s.begin() + i, s.begin() + i + k) == t)
                dp[i] = 1;
        }
    }
    cout << (dp[0] ? "YES\n" : "NO\n");
}


Measured memory_bytes: 512
//https://atcoder.jp/contests/abc160/tasks/abc160_e
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll X,Y,A,B,C; cin>>X>>Y>>A>>B>>C;
  vector<ll> pa(A); for(auto&&p:pa) cin>>p;
  vector<ll> qb(B); for(auto&&q:qb) cin>>q;
  vector<ll> rc(C); for(auto&&r:rc) cin>>r;
  sort(pa.begin(),pa.end(),greater<ll>());
  sort(qb.begin(),qb.end(),greater<ll>());
  sort(rc.begin(),rc.end(),greater<ll>());

  vector<ll> ren;
  FOR(i,0,min<ll>(X,pa.size())){
    ren.push_back(pa.at(i));
  }
  FOR(i,0,min<ll>(Y,qb.size())){
    ren.push_back(qb.at(i));
  }
  ren.insert(ren.end(),rc.begin(),rc.end());
  sort(ren.begin(),ren.end(),greater<ll>());
  ll ans=0;
  FOR(i,0,X+Y){
    ans+=ren.at(i);
  }
  cout<<ans<<endl;

  return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, C; cin >> N >> C;
        vector<vector<ll>> D(C, vector<ll>(C)); cin >> D;
        vector<vector<int>> G(N, vector<int>(N)); cin >> G;

        vector<vector<pair<ll, int>>> costs(3);
        rep(m, 3) {
            rep(c, C) {
                ll cost = 0;
                rep(y, N) {
                    rep(x, N) {
                        if((x + y) % 3 == m) {
                            cost += D[G[y][x] - 1][c];
                        }
                    }
                }
                costs[m].emplace_back(cost, c);
            }
            sort(all(costs[m]));
        }
        function<ll(int, set<int>&)> dfs = [&] (int m, set<int> &used) {
            if(m == 3) return 0ll;
            ll res = INFL;
            rep(i, 3) if(not used.count(costs[m][i].second)) {
                used.insert(costs[m][i].second);
                set_min(res, dfs(m + 1, used) + costs[m][i].first);
                used.erase(costs[m][i].second);
            }
            return res;
        };
        set<int> used;
        cout << dfs(0, used) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K= sc.nextInt(),A=sc.nextInt(),B=sc.nextInt();
		boolean flag= false;
		for(int i=A;i<B+1;i++) {
			if(i%K==0) {
				flag=true;
			}
		}
		if(flag) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}
		

	}

}


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

 
int main() {
    long long int x;
    cin>>x;
    long long a,b;
    bool t=false;
    for(int i=0;i<1000;i++){
        for(int j=-1000;j<1000;j++){
            int y=i*i*i*i*i-j*j*j*j*j;
            if(x==y){
                a=i;
                b=j;
                t=true;
                break;
            }
            
        }
        if(t) break;
    }
    cout<<a<<" "<<b<<endl;
}

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

using namespace std;

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef complex<int64> point;
typedef vector<point> polygon;

#define NEXT(i) (((i) + 1) % n)

double cross(point a, point b) { return imag(conj(a) * b); }

int64 area2(const polygon &P)
{
	int64 A = 0;
	for (int i = 0, n = P.size(); i < n; ++i)
		A += cross(P[i], P[NEXT(i)]);
	return A;
}

void print(int64 v){
	cout << v / 2 << "." << ((v & 1) ? '5' : '0') << endl;
}

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

	int n; cin >> n;
	polygon p(n);
	for (int i = 0; i < n; ++i){
		int64 x, y; cin >> x >> y;
		p[i] = point(x, y);
	}

	print(area2(p));

	return 0;
}

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

const int mod = 1e9 + 7;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	map<tuple<int, int, int>, int> q;
	q[make_tuple(0, 0, 0)] = 1;
	for (int i = 0; i < N; i++) {
		map<tuple<int, int, int>, int> qq;
		for (auto p : q) {
			auto tp = p.first;
			if (get<0>(tp) == A[i]) {
				auto tmp = tp;
				++get<0>(tmp);
				(qq[tmp] += p.second) %= mod;
			}
			if (get<1>(tp) == A[i]) {
				auto tmp = tp;
				++get<1>(tmp);
				(qq[tmp] += p.second) %= mod;
			}
			if (get<2>(tp) == A[i]) {
				auto tmp = tp;
				++get<2>(tmp);
				(qq[tmp] += p.second) %= mod;
			}
		}
		q = move(qq);
	}
	int res = 0;
	for (auto p : q) {
		(res += p.second) %= mod;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, A, B;
	int count = 0, f = 1;
	char p[1000001];
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++)
		cin >> p[i];

	for (int i = 1; i <= N; i++){
		if (p[i] == 'a' && count < A + B) {
			printf("Yes\n");
			count++;
		} else if (p[i] == 'b' && count < (A + B) && (f <= B)) {
			printf("Yes\n");
			f++;
			count++;
		} else {
			printf("No\n");
		}
	}

}

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

int main() {
  int count=0;
  int N,T;
  cin>>N>>T;
  vector<pair<int,int>>X(N);
  rep(i,N){
    cin>>X[i].first>>X[i].second;
  }
  rep(i,N){
    if(T<X[i].second)
      X[i].first+=10000;
  }
  sort(X.begin(),X.end());
  if(X[0].first<10000)
  cout<<X[0].first;
  else
    cout<<"TLE";
}


Measured memory_bytes: 256
N=32768
p=[i for i in range(N)]
for i in range(2,int(N**0.5)+1):
    if p[i]:
        for j in range(i*i,N,i):p[j]=0
p=sorted(set(p))[2:]
while 1:
    n=int(input())
    if n==0:break
    c=0
    if n&1:c=int(n-2 in p)
    else:
        for x in p:
            if x>n//2:break
            if n-x in p:c+=1
    print(c)

Measured memory_bytes: 8900
#include <stdio.h>

int main () {
	int a[3][3], b[3][3];
	int count = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	int n, m;
	scanf("%d", &n);
	for ( int i = 0; i < n; i++) {
		scanf("%d", &m);
		
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == m) {
					b[i][j] = 1;
				}
			}
		}
	}
	
	if (b[0][0]+ b[1][1]+ b[2][2] == 3 || b[0][2]+ b[1][1]+ b[2][0] == 3) {
      puts("Yes");
      return 0;
    }
	
	for(int i = 0; i < 3; i++) {
      if(b[i][0]+ b[i][1]+ b[i][2] == 3 || b[0][i]+ b[1][i]+ b[2][i] == 3) {
        puts("Yes");
        return 0;
      }
    }
	printf("No");
	
	return 0;
}

Measured memory_bytes: 1696
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int[] A = new int[9];
		for( int i=0; i<9; i++ ){
			A[i] = sc.nextInt();
		}
		int N = sc.nextInt();
		int[] B = new int[N];
		for( int i=0; i<N; i++ ){
			B[i] = sc.nextInt();
			for( int k=0; k<9; k++ ){
				if( B[i]==A[k] ){
					A[k] = 0;
					break;
				}
			}
		} 
		int ans = 0;
		if( A[0]==A[1] && A[1]==A[2] ){
			ans = 1;
		}
		if( A[3]==A[4] && A[4]==A[5] ){
			ans = 1;
		}
		if( A[6]==A[7] && A[7]==A[8] ){
			ans = 1;
		}
		if( A[0]==A[3] && A[3]==A[6] ){
			ans = 1;
		}
		if( A[1]==A[4] && A[4]==A[7] ){
			ans = 1;
		}
		if( A[2]==A[5] && A[5]==A[8] ){
			ans = 1;
		}
		if( A[0]==A[4] && A[4]==A[8] ){
			ans = 1;
		}
		if( A[2]==A[4] && A[4]==A[6] ){
			ans = 1;
		}
		System.out.println(ans==1?"Yes":"No");
	}
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string a;
  cin >> a;
  int ans = 0;
  for (int i = 2; i < n; i++) {
    if (a[i - 2] == 'A' & a[i - 1] == 'B' && a[i] == 'C') ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

long long powMod(long long x, long long n, long long m) {
    long long res = 1;
    while (n > 0) {
        if ((n & 1) == 1) res = res * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return res;
}

int main() {

    string S;
    cin >> S;
    int N = S.length();
    vector<ll> blank_left(N + 1, 0), blank_right(N + 1, 0);
    vector<ll> left(N + 1, 0), right(N + 1, 0);
    rep(i,N) {
        left[i + 1] = left[i];
        blank_left[i + 1] = blank_left[i];
        if (S[i] == 'A') left[i + 1] += powMod(3, blank_left[i], MOD);
        else if (S[i] == '?') {
            blank_left[i + 1]++;
            left[i + 1] *= 3;
            left[i + 1] %= MOD;
            left[i + 1] += powMod(3, blank_left[i], MOD);
        }
        left[i + 1] %= MOD;
    }
    for (int i = N - 1; i >= 0; i--) {
        right[i] = right[i + 1];
        blank_right[i] = blank_right[i + 1];
        if (S[i] == 'C') right[i] += powMod(3, blank_right[i + 1], MOD);
        else if (S[i] == '?') {
            blank_right[i]++;
            right[i] *= 3;
            right[i] %= MOD;
            right[i] += powMod(3, blank_right[i + 1], MOD);
        }
        right[i] %= MOD;
    }

    ll ans = 0;
    rep(i,N) {
        if (S[i] != 'B' && S[i] != '?') continue;
        ans += left[i] * right[i + 1];
        ans %= MOD;
    }

    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll k;
    cin >> k ;
    ll x=100;
    ll i;
    for(i=1;i;i++)
    {
        x+=x*0.01;
        if(x>=k) break;
    }
    cout << i;

   return 0;
}//main


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << (h * w + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int x = 6;
    for (int i = 0; i < 2; i++)
    {
        int y;
        cin >> y;
        x -= y;
    }
    cout << x << endl;
}

int main()
{
    solve();
    return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	char a[5]; scanf("%s", a);
	char s[20] = "";

	s[0] = a[0];
	s[2] = a[1];
	s[4] = a[2];
	s[6] = a[3];
	s[7] = '=';
	s[8] = '7';
	REP(i,8){
	int ans = (a[0] - '0');
		bitset<3> b(i);
		REP(j,3){
			switch(b[j]){
				case true:
					ans += a[j+1] - '0';
					s[2*j+1] = '+';
					break;
				case false:
					ans -= a[j+1] - '0';
					s[2*j+1] = '-';
					break;
			}
			}
			if(ans == 7){ 
				printf("%s\n", s);
				return 0;
		}

	}



	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

class Point {
public:
	int x;
	int y;
};

class QInfo {
public:
	int x;
	int y;
	int depth;
	vector<string> board;

	QInfo(int x, int y, int depth, vector<string> &board) {
		this->x = x;
		this->y = y;
		this->depth = depth;
		this->board = board;
	}
};

Point st, gl;

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

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

signed main() {
	cin >> w >> h;
	while (w != 0) {
		vector<string> board;
		rep(y, h) {
			string tmp = "";
			rep(x, w) {
				char ch;
				cin >> ch;
				tmp += ch;

				if (ch == '2') {
					st.x = x;
					st.y = y;
				} else if (ch == '3') {
					gl.x = x;
					gl.y = y;
				}
			}
			board.push_back(tmp);
		}

		queue<QInfo> q;
		q.push(QInfo(st.x, st.y, 0, board));
		while (!q.empty()) {
			QInfo nowInfo = q.front(); q.pop();
			vector<string> board = nowInfo.board;
			rep(dir, 4) {
				int nx = nowInfo.x + dx[dir];
				int ny = nowInfo.y + dy[dir];
				if (!inBoard(nx, ny) || board[ny][nx] == '1') continue;
				while (inBoard(nx, ny)) {
					if (board[ny][nx] == '3') {
						cout << nowInfo.depth + 1 << endl;
						goto END_PHASE;
					}
					if (board[ny][nx] == '1') {
						if (nowInfo.depth == 9) break;
						board[ny][nx] = '0';
						q.push(QInfo(nx - dx[dir], ny - dy[dir], nowInfo.depth + 1, board));
						board[ny][nx] = '1';
						break;
					}
					nx += dx[dir];
					ny += dy[dir];
				}
			}
		}

		cout << -1 << endl;

END_PHASE:

		cin >> w >> h;
	}

    return 0;
}

Measured memory_bytes: 22096
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) {return log(b) / log(a);}

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h);
	vector<vector<int>> c(h);
	rep(i, h) {
		a[i].resize(w);
		c[i].resize(w);
		rep(j, w) {
			cin >> a[i][j];
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (i == 0 && j == 0 && a[i][j] == '.') {
				c[i][j] = 1;
			}
			else if (i == 0 && a[i][j] == '.') {
				c[i][j] = c[i][j - 1];
			}
			else if (j == 0 && a[i][j] == '.') {
				c[i][j] = c[i - 1][j];
			}
			else if (a[i][j] == '.') {
				c[i][j] = (c[i - 1][j] + c[i][j - 1]) % mod;
			}
		}
	}
	cout << c[h - 1][w - 1] << endl;
}


Measured memory_bytes: 5248
//It is good to start with zero//
//    kyu @Aryabhatta//




#include<bits/stdc++.h> 
using namespace std;                          
#pragma GCC optimize("O3")
typedef long long ll;
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define vec(i, a)  for( auto i=a.begin();i != a.end(); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define in  freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define sixfive in out 
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector<ll> vi;
const ll MOD = 1e9 + 7;
ll n_bits(ll n ) { ll x= __builtin_popcount(n) ;return x ;}
int pow(int a, int b, int m)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return ans;
}
int main()
{    
    #ifndef ONLINE_JUDGE
    sixfive
    #endif
    fast
    ll t=1;
    //cin>>t;
    while(t--)
    {    
        int x;
        cin>>x;
        if(x==0)
        {
            cout<<1;
        }
        else
            cout<<0;
    }
    return 0;
}

//            sometimes I do it for her...//

Measured memory_bytes: 3636
/*
* @author:  codancer
* @createTime:  2020-02-09, 20:02:43
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int main(){
	string s;
	cin>>s;
	int n=(int)s.length();
	for(int i=1;i<=n;i++){
		cout<<'x';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int   n,h[110];
   cin >> n;
   rep(i,n) cin >> h[i];

   int ans = 1;
   for(int i=1;i<n;i++){
      bool flg = 1;
      for(int j=0;j<i;j++){
            if(h[j] > h[i]) {
               flg = 0;
               break;
            }
      }
      if(flg) ans++;
   }

   cout << ans << endl;




   return 0;
}

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

vector<vector<char>> maze;
vector<vector<int>> cost;
queue<p> que_a, que_b;
int h,w,ch,cw,dh,dw;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void bfs_a(){
    while(que_a.size() > 0){
        p r = que_a.front();
        que_b.push(r);
        que_a.pop();
        for(int i = 0; i < 4; i++){
            int nx = r.first + dx[i], ny = r.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w 
                    && maze[nx][ny] != '#' && cost[nx][ny] == INF){
                cost[nx][ny] = cost[r.first][r.second];
                que_a.push(p(nx,ny));
            }
        }
    }
}

void warp_b(){
    while(que_b.size() > 0){
        p r = que_b.front(); que_b.pop();
        for(int x = -2; x <= 2; x++){
            for(int y = -2; y <= 2; y++){
                int nx = r.first + x, ny = r.second + y;
                if(0 <= nx && nx < h && 0 <= ny && ny < w 
                        && maze[nx][ny] != '#' && cost[nx][ny] == INF){
                    cost[nx][ny] = cost[r.first][r.second] + 1;
                    que_a.push(p(nx, ny));
                }
            }
        }
    }
}

int main(){
    cin >> h >> w >> ch >> cw >> dh >> dw;
    vector<char> tmp(w);
    vector<int> tmp2(w, INF);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> tmp[j];
        }
        maze.push_back(tmp);
        cost.push_back(tmp2);
    }
    que_a.push(p(ch - 1, cw - 1));
    cost[ch - 1][cw - 1] = 0;

    while(que_a.size() > 0){
        bfs_a();
        warp_b();
    }

    if(cost[dh - 1][dw - 1] == INF) puts("-1");
    else cout << cost[dh - 1][dw - 1] << endl;
    return 0;
}

Measured memory_bytes: 8576
#from operator import itemgetter
#from collections import Counter
import heapq
#N = int(input())
N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
#A = [int(input()) for i in range(N)]

heapq.heapify(A)

for i in range(M):
    max = heapq.heappop(A)
    heapq.heappush(A, max*(-1)//2*(-1))
print(-sum(A))

Measured memory_bytes: 14180
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> p(N);
  rep(i, N) cin >> p[i];

  bool flag = false;
  vector<int> tmp;
  tmp = p;
  sort(tmp.begin(), tmp.end());
  if (tmp == p) {cout << "YES" << endl; return 0;}
  for (int i = 0; i < N; ++i){
    for (int j = i + 1; j < N; ++j){
      swap(p[i], p[j]);
      tmp = p;
      sort(tmp.begin(), tmp.end());
      if (tmp == p) {flag = true; break;}
      swap(p[i], p[j]);
    }
  }
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

#define all(c) c.begin(), c.end()
using ll = long long;

using namespace std;
const int MAX = 200001;
int freq[MAX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    freq[x]++;
  }
  sort(freq, freq + MAX);
  int distinct = 0;
  for (int i = 1; i < MAX; i++) {
    if (freq[i] > 0) distinct++;
  }
  int ans = 0;
  for (int i = 1; i < MAX && distinct > k; i++) {
    if (freq[i] > 0) {
      ans += freq[i];
      distinct--;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define rep(i, n) for (ll i=0;i<(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
//using ll=long long;
typedef long long ll;
typedef pair<ll, ll> pi;

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

  vector<ll> a(n);
  vector<ll> x(n);

  rep(i, n){
    cin >> a[i];
  }
  ll s = a[0] + a[n-1];

  rep(i, n-2){
    if(i%2==0) s -= a[i+1];
    else s += a[i+1];
  }

  x[0] = s/ 2 ;

  rep(i, n-2){
    x[i+1] = a[i] - x[i];
  }

  x[n-1] = a[n-1] - x[0];
  
  rep(i, n-1) cout << 2*x[i] << " ";
  cout << 2*x[n-1] <<endl;
  
  
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve2440();
	}

	public static void solve2440() {
		Scanner sc = new Scanner(System.in);
		while(true){
            double n = sc.nextInt();
            if(n==0) {
            	break;
            }
    		int cnt = 0;
    		for(int i=1;i<n/2;i++) {
        		int a = 0;
	            for(int j=i ;n>a;j++) {
	            	a+=j;
	            	if(n==a) {
	            		cnt++;
	            		break;
	            	}
	            }
    		}
    		System.out.println(cnt);
        }
	}
}


Measured memory_bytes: 26724
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    int ans=0;
    if(x==1)
        ans+=300000;
    else if(x==2)
        ans+=200000;
    else if(x==3)
        ans+=100000;


    if(y==1)
        ans+=300000;
    else if(y==2)
        ans+=200000;
    else if(y==3)
        ans+=100000;

    if(x==1&&y==1)
        ans+=400000;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define NIN -100000000
#define EPS 0.0000000001
int main()
{
    int n,i;
    scanf("%d",&n);
    long long inf=1e18;
    long long inp,ans=1;
    long long A[n];
    bool z=false;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&A[i]);
        if(A[i]==0)
        {
            z=true;
        }
    }
    if(z)
    {
        printf("0");
        return 0;
    }
    for(i=0;i<n;i++)
    {
        inp=A[i];

        if((inf/ans)<inp)
        {
            printf("-1");
            return 0;
        }
        ans=ans*inp;
    }
    printf("%lld",ans);
    return 0;
}


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N, M;
vector<ll> A;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  cin >> N >> M;
  A.resize(N);
  ll sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  double border = double(sum) / 4 / M; // int は割られる前にcastしないと小数点でない
  ll ans = 0;
  rep(i, N) {
    if (A[i] >= border) {
      ans++;
    }
  }
  string hoge = (M <= ans)?"Yes":"No";
  cout << hoge << endl;
  return 0;
}


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

int main() {
    ll N,M;
    cin >> N >> M;
    vector<vector<ll>> c(M);
    for(int i=0;i<M;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int s;
            cin >> s;
            --s;
            c[i].push_back(s);
        }
    }
    vector<ll> p(M);
    for(int i=0;i<M;i++){
        cin >> p[i];
    }

    ll ans =0;
    for(int bit =0;bit<(1<<N);++bit){
        ll temp =0;
        // cerr <<"bit=" << bitset<8>(bit) << endl;
        for(int i=0;i<M;i++){
            // cerr <<"i="<< i << endl;
            ll num =0;
            for(int s:c[i]){
                if((bit>>s) & 1 == 1){
                    // cerr <<"s="<<s << endl;
                    num++;
                }
            }
            if(num%2==p[i]){
                temp++;
            }
        }
        if(temp == M){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	static long long N, A[200000], NOW = 1;
	bool check = false;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		if (A[i] == 1) check = true;
	}
	if (!check) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (A[i] == NOW) NOW++;
	}
	cout << N - NOW + 1 << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
 
class UnionFind
{
public:
	explicit UnionFind(int size)
		: mParent(size, -1)
		, mRank(size, 0)
        , mData(size, 0)
		, mSize(size)
		{}
	bool unionSet(int x, int y)
	{
		if ((x = root(x)) == (y = root(y)))
			return false;
		if( mRank[x] < mRank[y] )
		{
			mParent[y] += mParent[x];
			mParent[x] = y;
            unionData( mData[y], mData[x] );
		}
		else
		{
			mParent[x] += mParent[y];
			mParent[y] = x;
			if( mRank[x] == mRank[y] ) ++mRank[x];
            unionData( mData[x], mData[y] );
		}
		--mSize;
		return true;
	}
	bool isEqualSet(int x, int y)
	{
		return root(x) == root(y);
	}
	int root(int x)
	{
		return mParent[x] < 0 ? x : mParent[x] = root(mParent[x]);
	}
	int unionSize(int x)
	{
		return -mParent[root(x)];
	}
	int size() const
	{
		return mSize;		
	}
 
	void unionData( int& parent, int& child )
	{
		parent += child;
	}
	void setData( int x, int data )
	{
		mData[root(x)] = data;
	}
	int getData( int x )
	{
		return mData[root(x)];
	}
 
private:
	vector<int> mParent; // = mUnionSize
	vector<int> mRank;
	vector<int> mData;
	int mSize;
};
 
int main()
{
	int n,m;cin>>n>>m;
 
	UnionFind uf(n);
	REP(i,m)
	{
		int x,y,z;cin>>x>>y>>z;
		uf.unionSet(x-1,y-1);
	}
 
	cout << uf.size() << endl;
	return 0;
}

Measured memory_bytes: 1408
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int k,a,b;
  cin>>k>>a>>b;

  bool flag=false;
  for(int i=a;i<=b;i++){
    if(i%k==0) flag=true;
  }

  if(flag) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
typedef long long     ll;
using namespace std;
map<ll,ll>mp;
int main()
{
    ll x,n,pos,con=1000,non=1000;
    cin>>x>>n;
    if(n==0)
    {
        cout << x << endl;
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        mp[a]=1;
    }
    for(int i=x; i<=101; i++)
    {
        if(mp[i]==0)
        {
            con=i-x;
            pos=i;
            break;
        }
    }
    for(int i=x-1; i>=0; i--)
    {
        if(mp[i]==0)
        {
            non=x-i;
            if(non<=con)
                pos=i;
            break;
        }
    }
    cout << pos << endl;
}


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

int LCS(char *, char *);

int main()
{
  int q,i;
  char X[1005],Y[1005];

  scanf("%d",&q);
  if(q<1 || q>150) exit(1);
  for(i=0;i<q;i++){
    scanf("%s%s",&X[1],&Y[1]);
    X[0]=Y[0]=' '; //この処理がないと1オリジンで考えてるから最初の文字が判別されない
    printf("%d\n",LCS(X,Y));
  }
  return 0;
}

int LCS(char *X,char *Y)
{
  int i,m,n,j,max=0,c[1005][1005]; //c[i][j]をX(i),Y(j)のLCSの長さとする2次元配列
  
  m = strlen(X)-1;
  n = strlen(Y)-1;

  /*strcpy(X+1,X);
  strcpy(Y+1,Y);*/
 
  //printf("%s\n",X);
  //printf("m=%d,n=%d\n",m,n);
  
  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=1;j<=n;j++) c[0][j] = 0; //0行目,0列目を全部0にする
  
  for(i=1;i<=m;i++){
    //printf("\n");
    for(j=1;j<=n;j++){
      if(X[i] == Y[j]) c[i][j] = c[i-1][j-1]+1; //表参照
      else if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j]; //↑
      else c[i][j] = c[i][j-1]; //↑
      //printf("c=%d\n",c[i][j]);
      if(max < c[i][j]) max = c[i][j]; //↑
    }
  }
  return max;
}



Measured memory_bytes: 5724
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ld sqr(ll x)
    {
        ld l=0,r=x,mid;
        for(int i=0;i<=100;++i)
        {
            mid=(l+r)/2;
            if(mid*mid>=x)
                r=mid;
            else
                l=mid;
        }
        return l;
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll a,b,c;
            cin>>a>>b>>c;
            ld x=sqr(a);
            ld y=sqr(b);
            ld z=sqr(c);
            if(x+y<z)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
        return 0;
    }


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  ll now=1000;
  for(int i=0;i<N-1;i++){
    if(A[i+1]>A[i]){
      now=A[i+1]*(now/A[i])+now%A[i];
    }
  }

  cout<<now<<endl;
  return 0;
}


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

int H, W;
vector<vector<int>> changeNum(10, vector<int>(10));
vector<vector<int>> wall(201, vector<int>(201));
vector<int> toOne(10, 999999999);

void searchMin(int k, vector<bool> check, int sum, int pre) {
  if (toOne[pre] > sum) {
    toOne[pre] = sum;
  }
  if (k == 9) {
    return;
  }
  for (int i = 0; i < 10; i++) {
    if (check[i]) {
      continue;
    }
    check[i] = true;
    searchMin(k + 1, check, sum + changeNum[i][pre], i);
    check[i] = false;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> H >> W;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> changeNum[i][j];
    }
  }
  vector<bool> check(10);
  check[1] = true;
  toOne[1] = 0;
  long long sum = 0;
  searchMin(0, check, sum, 1);
  long long ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> wall[i][j];
      if(wall[i][j] != -1){
        ans += toOne[wall[i][j]];
      }
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3852