akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;


int main() {

  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i = 0; i < m; i++){
    int x;
    cin >> x; 
    b[i] = x;
  }
  vector<vector<int>> a(n, vector<int>(m));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
        int x;
        cin >> x;
        a[i][j] = x;
    }
  }

  int cnt = 0;
  for(int i = 0; i < n; i++){
    int sum = c;
    for(int j = 0; j < m; j++){
      sum += a[i][j] * b[j];
    }
    if(sum > 0){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
N=int(input())
Tree=[{} for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  Tree[a-1][b-1]=c
  Tree[b-1][a-1]=c
Q,K=map(int,input().split())
depth=[-1]*N
depth[K-1]=0
dfs_stack=[K-1]
while dfs_stack:
  s=dfs_stack.pop()
  for t,t_depth in Tree[s].items():
    if depth[t]==-1:
      depth[t]=depth[s]+t_depth
      dfs_stack.append(t)
      
for q in range(Q):
  x,y=map(int,input().split())
  print(depth[x-1]+depth[y-1])
  
      
    
      
      

Measured memory_bytes: 97440
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;

int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

string alpha="abcdefghijklmnopqrstuvwxyz";

int n;



int main(){
	cin>>n;
	cout<<"ABC"<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node {
	int key;
	Node *right, *left, *parent;
};
Node *root, *NIL;
Node *find(Node *u, int k) {
	while (u != NIL&&k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}
void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NIL)root = z;
	else {
		if (z->key < y->key)y->left = z;
		else y->right = z;
	}
	return;
}
void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
	return;
}
void preorder(Node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
	return;
}
int main() {
	int n, i, x;
	string com;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			cin >> x;
			Node *t = find(root, x);
			if (t != NIL)puts("yes");
			else puts("no");
		}
		else if (com == "insert") {
			cin >> x;
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}


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

int main() {

    string s; cin >> s;
    vector<int> a('z' - 'a' + 1, 0);
    for (char c : s) a[c - 'a']++;
    ll ans = 0;
    for (int x : a) ans += x % 2;
    ans -= ans/2;
    ans -= s.size() % 2 != 0;
    cout << ans << endl;

}


Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
//This code is written by Itst
using namespace std;

const int MAXN = 1e6 + 7 , MOD = 1e9 + 7;
int N , dp[MAXN];

int main(){
	cin >> N;
	dp[N] = N; dp[N - 1] = (1ll * N * N + dp[N]) % MOD;
	for(int i = N - 2 ; i > 0 ; --i)
		dp[i] = (dp[i + 1] - dp[i + 2] + (N - 1ll) * (N - 1) + dp[i + 3] + dp[i + 1] + i + 1 + MOD) % MOD;
	cout << (dp[1] - dp[2] + MOD) % MOD;
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define Rep(i,n) for(int i=0; i<(n); i+=2)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

bool compare_by_b(pair<int, ll> a, pair<int, ll> b)
{
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int n,c;
    cin >> n;
    c = n / 2;
    double ans;
    ans = c / (double)n;
    cout << 1-ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<iterator>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	vector<int>vec;
	int i,j,v;
	for(i=0; i<n; i++)
	{
		cin>>v;
		vec.push_back(v);
	}
	ll dp[n];
	memset(dp,0,sizeof(dp));
	dp[1]=abs(vec[1]-vec[0]);
	for(i=2; i<n; i++)
	{
		ll min1=10000000000;
		j=i-1;
		ll cnt=k;
		while(cnt>0 && j>=0)
		{
			cnt--;
			min1=min(min1,dp[j]+abs(vec[i]-vec[j]));
			j--;
		}
		dp[i]=min1;
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <math.h>
using namespace std;

int tax(int x,int p){
    return floor(p * (100+x) / 100);
}

int main(){
    while(true){
        int X,Y,S;
        cin >> X >> Y >> S;
        if(!(X|Y|S)) break;
        int maximum = 0;
        for (int i=1; i<S; ++i){
            for (int j=1; j<S; ++j){
                if (tax(X,i)+tax(X,j) == S){
                    maximum = max(maximum, tax(Y,i) + tax(Y,j));
                }
            }
        }
        cout << maximum << endl;
    }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n;
    cin>>n;
    
    ll res = 0;

    for (int i=1; i<=n; i++) {
	res += (1ll*i*(i+1)/2);
    }
    
    for (int i=0; i<n-1; i++) {
	int u,v;
	cin>>u>>v;
	if (u>v) swap(u,v);
	ll cur = 1ll*u*(n-v+1);
	res -= cur;
    }

    cout<<res<<endl;    
    
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;
const Int M=(Int)(1e9+7);

inline Int mmul(Int a,Int b){if(a>=M)a=a%M;if(b>=M)b=b%M;if(a*b>=M)return(a*b)%M;return(a*b);}
inline Int madd(Int a, Int b){if(a>=M)a=a%M;if(b>=M)b=b%M;if(a+b>=M)return(a+b)%M;return(a+b);}



int main()
{
    int A,B;
    cin>>A>>B;
    cout<<(A==B ? "Yes\n":"No\n");
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int i = 0;
		String ans = "";
		if (n == 0) {
			ans = "0";
		}
		while (Math.abs(n) > 0) {
			if (n % (-2) == 0) {
				if (Math.pow(-2, i) < 0) {
					ans = "1" + ans;
					n--;
				} else {
					ans = "0" + ans;
				}
			} else {
				ans = "1" + ans;
				n--;
			}
			n = n / (-2);
		}

		System.out.println(ans);

		sc.close();
	}
}


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

int main(void) {
  ll I, O, T, J, L, S, Z;
  cin >> I >> O >> T >> J >> L >> S >> Z;

  ll ans1 = 0, ans2 = 0;
  ans1 += O;
  ans1 += I / 2 * 2;
  ans1 += J / 2 * 2;
  ans1 += L / 2 * 2;
  if(J % 2 == 1 && L % 2 == 1 && I % 2 == 1) ans1 += 3;
  if(I >= 1 && J >= 1 && L >= 1) {
    ans2 += O;
    ans2 += (I - 1) / 2 * 2;
    ans2 += (J - 1) / 2 * 2;
    ans2 += (L - 1) / 2 * 2;
    ans2 += 3;
  }
  cout << max(ans1, ans2) << endl;
}


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

#define endl '\n'
using namespace std;
typedef long long int ll;

const int N = 55;

int W, H, n;
int ans, highest;
vector<tuple<int,int,int>> pt;
int arr[N][N];
bool locked[N][N];

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> W >> H >> n;
    ans = 0;
    highest = -7122;
    memset(locked, 0, sizeof(locked));
    for(int i = 0; i < n; i++)
    {
        int x, y, z; cin >> x >> y >> z;
        x--, y--;
        highest = max(highest, z);
        locked[x][y] = true;
        pt.emplace_back(x, y, z);
    }
}

bool valid_start()
{
    for(int i = 0; i < n; i++)
    {
        int x1, y1, z1;
        tie(x1, y1, z1) = pt[i];
        for(int j = 0; j < n; j++)
        {
            if(i == j) continue;
            int x2, y2, z2;
            tie(x2, y2, z2) = pt[j];
            int d12 = abs(x1-x2)+abs(y1-y2);
            if(d12 < abs(z1-z2)) return false;
            for(int k = 0; k < n; k++)
            {
                if(k == i || k == j) continue;
                int x3, y3, z3;
                tie(x3, y3, z3) = pt[k];
                int d13 = abs(x1-x3)+abs(y1-y3);
                if(d13 < abs(z1-z3)) return false;
                int d23 = abs(x2-x3)+abs(y2-y3);
                if(d23 < abs(z2-z3)) return false;
            }
        }
    }
    return true;
}

void fill()
{
    for(int x = 0; x < W; x++)
        for(int y = 0; y < H; y++)
            arr[x][y] = highest;
    ans = W*H*highest;
}

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

bool valid(int x, int y)
{
    return 0 <= x && x < W && 0 <= y && y < H;
}

void bfs_dig(int x, int y, int z)
{
    queue<tuple<int,int,int>> q;
    q.emplace(x, y, z);
    while(!q.empty())
    {
        tie(x, y, z) = q.front(); q.pop();
        if(z >= arr[x][y]) continue;
        ans -= arr[x][y]-z;
        arr[x][y] = z;
        for(int d = 0; d < 4; d++)
        {
            int nx = x+dx[d], ny = y+dy[d];
            if(valid(nx, ny) && z+1 < arr[nx][ny]) q.emplace(nx, ny, z+1);
        }
    }
}

bool drop(int x, int y)
{
    int nz = arr[x][y]-1;
    bool flg = true;
    for(int d = 0; d < 4; d++)
    {
        int nx = x+dx[d], ny = y+dy[d];
        if(valid(nx, ny))
            if(abs(arr[nx][ny]-nz) > 1) flg = false;
    }
    if(flg) arr[x][y]--, ans--;
    return flg;
}

void process()
{
    if(!valid_start()) cout << "No" << endl;
    else
    {
        fill();
        int x, y, z;
        for(auto t : pt)
        {
            tie(x, y, z) = t;
            bfs_dig(x, y, z);
        }
        bool flg = true;
        while(flg)
        {
            flg = false;
            for(int x = 0; x < W; x++)
                for(int y = 0; y < H; y++)
                {
                    if(locked[x][y]) continue;
                    flg |= drop(x, y);
                }
        }
        cout << ans << endl;
        /*
        for(int y = 0; y < H; y++)
            for(int x = 0; x < W; x++)
                cout << arr[x][y] << " \n"[x==W-1];
        */
    }
}




Measured memory_bytes: 3228
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#define USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 30;
const double EPS = 1E-9;

int to_num(char c){
	if(isdigit(c)){
		return c - '0';
	}else if(c == 'T'){
		return 10;
	}else if(c == 'J'){
		return 10;
	}else if(c == 'Q'){
		return 10;
	}else if(c == 'K'){
		return 10;
	}else{
		return 1;
	}
}


int card[8];

int main(){
	int n;
	char ch;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a, b;
		bool ele_used = false;

		cin >> ch;
		a = to_num(ch);
		cin >> ch;
		b = to_num(ch);

		for(int j = 0; j < 8; j++){
			cin >> ch;
			card[j] = to_num(ch);
		}

		int sum = 0;

		if(a != 1){
			sum += a;
		}else{
			sum += 11;
			ele_used = true;
		}

		if(b != 1 || ele_used){
			sum += b;
		}else{
			sum += 11;
			ele_used = true;
		}

		if(sum == 21){
			cout << "blackjack" << endl;
			continue;
		}else if(sum > 17 || (sum == 17 && !ele_used)){
			cout << sum << endl;
			continue;
		}

		for(int j = 0; j < 8; j++){

			if(card[j] != 1){
				sum += card[j];
			}else if(sum + 11 > 21){
				sum += 1;
			}else{
				sum += 11;
				ele_used = true;
			}

			if(sum > 21){
				if(ele_used){
					sum -= 10;
					ele_used = false;
				}else{
					cout << "bust" << endl;
					break;
				}
			}

			if(sum > 17 || (sum == 17 && !ele_used)){
				cout << sum << endl;
				break;
			}
		}
	}
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

map<ll, ll> mp;

ll rec(ll h) {
    if (h == 1) {
        return 1LL;
    }
    if (mp.count(h)) {
        return mp[h];
    }
    ll l = rec(h/2);
    mp[h/2] = l;
    ll r = rec(h/2);

    return l + r + 1;
}

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

    ll h; cin >> h;

    cout << rec(h);









    return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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()
{
    int A,B;
    cin >> A >> B;

    if( A%3==0 || B%3==0 || (A+B)%3==0 ) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
import sys
def solve(balls):
    if distribute(balls, 0, 0): print('YES')
    else: print('NO')
  
def distribute(balls, lastR, lastL):    
    if len(balls) != 0:
        next = balls[0]
        if next>lastR:
            if distribute(balls[1:], next, lastL): return True
        
        if next>lastL:
            if distribute(balls[1:], lastR, next): return True
    else:
        return True

sys.setrecursionlimit(2**11)
size = int(input());
for i in range(size):
    balls = []
    for a in input().split(' '):
        balls.append(int(a))   
    solve(balls)

Measured memory_bytes: 7648
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	long long a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(c<=a+b)
		printf("No\n");
	else
		if(4*a*b<(c-a-b)*(c-a-b))
			printf("Yes\n");
		else
			printf("No\n");
	return 0;
}

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

int main() {

  string s;
  cin >> s;
  
  int a = s.find("A");
  
  vector<string> zvec(s.size());
  int j = 0;
  for(int i = s.size(); i > 0; i--){
    zvec.at(j) = s[i-1];
    j++;
  }
  
  string sr;  
  for(int i = 0; i < s.size(); i++){
    sr += zvec.at(i);
  }
  int z = sr.find("Z");
  
  cout << s.size() - z - a;
  
  return 0;
}




Measured memory_bytes: 11780
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  void __solve(Scanner cin) {
	  
	  int K = cin.nextInt();
	  SList list = new SList();
	  
	  long sum = 0;
	  for( int i = 0; i < K; ++i ) {
		  switch( cin.nextInt() ) {
		  case 1:
			  list.add(cin.nextInt());
			  sum += cin.nextInt();
			  break;
		  case 2:
			  list.center(sum);
			  break;
		  }
	  }

  }
  
  class SList {
	  private PriorityQueue<Integer> lo;
	  private PriorityQueue<Integer> hi;
	  long loSum;
	  long hiSum;
	  SList() {
		  lo = new PriorityQueue<Integer>();
		  hi = new PriorityQueue<Integer>();
		  loSum = 0;
		  hiSum = 0;
	  }
	  void add(int K) {
		  if( lo.size() == 0 ) {
			  lo.add(-K);
			  loSum += -K;
			  return;
		  }
		  if( hi.size() == 0 ) {
			  int V = -lo.peek();
			  if( V <= K ) {
				  hi.add(K);
				  hiSum += K;
			  }
			  else {
				  lo.poll();
				  loSum -= -V;
				  hi.add(V);
				  hiSum += V;
				  lo.add(-K);
				  loSum += -K;
			  }
			  return;
		  }
		  int L = -lo.peek();
		  int H = hi.peek();
		  if( K >= H ) {
			  hi.add(K);
			  hiSum += K;
			  if( hi.size() == lo.size() + 1 ) {
				  int V = hi.poll();
				  hiSum -= V;
				  lo.add(-V);
				  loSum += -V;
			  }
		  }
		  else {
			  lo.add(-K);
			  loSum += -K;
			  if( lo.size() == hi.size() + 2 ) {
				  int V = -lo.poll();
				  loSum -= -V;
				  hi.add(V);
				  hiSum += V;
			  }
		  }
	  }
	  void center(long base) {
		  long V;
		  if( lo.size() == 0 ) {
			  System.out.println("0 0");
			  return;
		  }
		  if( hi.size() == 0 || lo.size() == hi.size() || lo.size() == hi.size() + 1 ) {
			  V = -lo.peek();
		  }
		  else {
			  V = hi.peek();
		  }
		  long total = hiSum + loSum + V * (lo.size() - hi.size()) + base;
		  // System.err.println(V + " " + (lo.size() + hi.size()) + " " + (loSum - hiSum) + " " + base);
		  System.out.println(V + " " + total);
	  }
	  
  }

}


Measured memory_bytes: 153268
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

//正直
#define YES 1
//不親切
#define NO 0

//未定
#define MITEI 2

long long N;
//xの人が正直と言っている人
vector<long long> shozi[20];
//xの人が不親切と言っている人
vector<long long> hushi[20];

long long memo[20];

int main(){
	cin >> N;
	rep(i, N) {
		long long a;
		cin >> a;
		rep(j, a) {
			long long x, y;
			cin >> x >> y;
			x--;
			if(y == YES) {
				shozi[i].push_back(x);
			} else {
				hushi[i].push_back(x);
			}
		}
	}


	long long ans = 0;
	rep(pat, (1<<N)) {
		rep(i, N) memo[i] = MITEI;

		bool ok = true;
		rep(from, N) {
			if((pat>>from)&1) {
				if(memo[from] == NO) {
					ok = false;
				}
				memo[from] = YES;
			} else {
				if(memo[from] == YES) {
					ok = false;
				}
				memo[from] = NO;
			}

			//fromが正直もの？
			if((pat>>from)&1) {
				for(auto p: shozi[from]) {
					if(memo[p] == NO) {
						ok = false;
					}
					memo[p] = YES;
				}

				for(auto p: hushi[from]) {
					if(memo[p] == YES) {
						ok = false;
					}
					memo[p] = NO;
				}
			}
		}
		if(ok) {
			ans = max(ans, (long long)__builtin_popcountll(pat));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b, a%b);
}
ll c, d, l;

int main()
{
    ll a, b; cin>>a>>b>>c>>d;
	l=c/gcd(c, d)*d;
	ll x=b-b/c-b/d+b/l;
	ll y=a-1-(a-1)/c-(a-1)/d+(a-1)/l;
	cout<<x-y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 5/24/2020

 14:19-14:35 WA


 */

const int MAX_N=1e6+1;
LL A[MAX_N],K;
int N;

LL cnt[61][2];
LL dp[61][2];
int ith(LL mask, int i) { return (mask>>i)&1; }
void solve() {
  REP(i,N) {
    LL a=A[i];
    REP(j,60) cnt[j][ith(a,j)]++;
  }

  const LL Inf=1e18;
  REP(i,61)REP(j,2) dp[i][j]=-Inf;
  dp[60][0]=0;
  for(int i=59; i>=0; --i) REP(less,2) if(dp[i+1][less]>=0) {
    int hb=less?1:ith(K,i);
    // dump(i,less,hb,dp[i+1][less]);
    REPE(d,hb) {
      SMAX(dp[i][less|(d<hb)], dp[i+1][less]+(1LL<<i)*cnt[i][1^d]);
    }
  }
  cout<<max(dp[0][0],dp[0][1])<<endl;
}

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

  cin>>N>>K;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[200000+10];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        a[i]-=i;
    }
    sort(a+1,a+1+n);
    int b;
    if(n%2!=0)
        b=n/2+1;
    else
        b=n/2;

    long long int ans=0;
    for(int i=1;i<=n;i++)
        ans+=abs(a[i]-a[b]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    l = len(s)
    print(s[0:(l-8)])

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
n = int(input())

A = [[0 for i in range(n)] for j in range(n)]

for i in range(n):

	B = input().split()

	if B[1]!=0:
		for j in range(int(B[1])):
			#B[2+j]
			A[i][int(B[2+j])-1] = 1

for i in range(n):
	for j in range(n):
		if j!=n-1:
			print(A[i][j], end=" ")
		else:
			print(A[i][j], end="\n")


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int count = 3;
  if (A == B) count--;
  if (B == C) count--;
  if (A == C) count--;
  if (A == B && B == C && A == C) count++;
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int i,j,ans,L,A,B,C,D;
  cin >> L >> A >> B >> C >> D;
  for(i=0;A>0;i++){
    A-=C;
  }
  for(j=0;B>0;j++){
    B-=D;
  }
  if(i>j){
    ans=L-i;
  }
  else{
    ans=L-j;
  }
  cout << ans << endl;
  return (0);
}

Measured memory_bytes: 1160
#include<set>
#include<iostream>
using namespace std;
int main(){
  string s;
  int a=0,b=0,c=0;
  cin >> s;
  set<char> d;
  for (int i=0; i<s.size(); i++){
    d.insert(s[i]);
  }
  if(d.size() == 3){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>a(3),b(3);
  for(int i=0;i<3;i++){
    cin>>a.at(i)>>b.at(i);
  }
  vector<int>num(4);
  for(int i=0;i<3;i++){
    num.at(a.at(i)-1)++;
    num.at(b.at(i)-1)++;
  }
  bool ans=false;
  for(int i=0;i<4;i++)if(num.at(i)>=3)ans=true;
  if(ans)cout<<"NO"<<endl;else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define M 1000000007LL
typedef pair<int,int> ii;
typedef vector<int> vi;

int main() {
	int n;cin >> n;
	map <int,int> poss;
	for (int i=1; i<=1000; i++) {
		poss[(i*(i+1))/2] = i;
	}
	if (poss.count(n)) {
		printf("Yes\n");
		int r = poss[n];
		printf("%d\n", r+1);
		vi unused, duplicate[r+1];
		for (int i=1; i<=n; i++) {
			unused.push_back(i);
		}
		for (int i=0; i<=r; i++) {
			printf("%d ",r);
			for (int k=0; k<i; k++) {
				int v = duplicate[k].back();
				duplicate[k].pop_back();
				printf("%d ", v);
			}
			for (int j=i; j<r; j++) {
				int v = unused.back();
				unused.pop_back();
				duplicate[i].push_back(v);
				printf("%d ", v);
			}
			printf("\n");
		}
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2428
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int x, y, z; cin >> x >> y >> z;
  int ans = 0, width = y + 2*z;
  while (width <= x) {
    ++ans;
    width += y + z;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, ans;
string s;

int main() {
	cin >> n >> s;
	int L = 0, R = sz(s) - 1;
	while (L < R) {
		while (L < sz(s) && s[L] == 'R') L++;
		while (R >= 0 && s[R] == 'W') R--;
		if(L < sz(s) && R >= 0 && L < R) ans++;
		L++; R--;
	}
	cout << ans;
}

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

int debug = 1;
int test = 1;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)

#define ll long long

long double pi = 3.14159265358979323846;

#define binf 10000000000050000
#define llinf 1000000000005000000
#define inf 1000050000
#define MOD 1000000007
#define abs llabs

#define prDouble(x) cout << fixed << setprecision(10) << x
//-----------------------------------------//
#define test() int tt=1; if(test){cin>>tt;}  while(tt--)

//###########################################//
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
//###########################################//
void filereader() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}
//###########################################//

 double dp[3001][3001];

// I
 double solve(double a[], int i, int x)
{
    if (x == 0)
    {
        return 1;
    }

    if (i == 0)
    {
        return 0;
    }

    if (dp[i][x] > -0.9)
        return dp[i][x];

    return dp[i][x] = a[i] * (solve(a, i - 1, x - 1)) + (1 - a[i]) * (solve(a, i - 1, x ));

}

int main() {

    debug = 0;
    test = 0;

    test() {

        int n;
        cin>>n;
        double a[n + 1];

       memset(dp,-1,sizeof dp);

        REP(i, n)
        {
            cin >> a[i];
        }

        prDouble(solve(a, n, (n + 1) / 2));

    }
}
/*
Maximum Circular Sum CodeChef Qn
Wildcard Matching

// F

*/


Measured memory_bytes: 74316
#include <stdio.h>
#include <ctype.h>

#define PRED(X) \
  ( (X) ? "x" : "o" )

int read (
  int *d
  )
{
  int i;

  for ( i = 0; i < 3 * 3; ++i )
  {
    int ch = '\0';

    while ( !isalpha ( ch ) )
    {
      if ( ch == EOF )  return ( 0 );
      ch = getchar ( );
    }

    switch ( ch )
    {
      case 'o': d[ i ] = 0;   break ;
      case 'x': d[ i ] = 1;   break ;
      default:  d[ i ] = -1;  break ;
    }
  }

  return ( 1 );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int d[ 3 ][ 3 ];
  int i;

  while ( read ( (int *)d ) )
  {
    for ( i = 0; i < 3; ++i )
    {
      if ( d[ i ][ 0 ] >= 0
        && d[ i ][ 0 ] == d[ i ][ 1 ]
        && d[ i ][ 0 ] == d[ i ][ 2 ] )
      {
        puts ( PRED( d[ i ][ 0 ] ) );
        goto CONT;
      }
      if ( d[ 0 ][ i ] >= 0
        && d[ 0 ][ i ] == d[ 1 ][ i ]
        && d[ 0 ][ i ] == d[ 2 ][ i ] )
      {
        puts ( PRED( d[ 0 ][ i ] ) );
        goto CONT;
      }
    }
    if ( d[ 0 ][ 0 ] >= 0
      && d[ 0 ][ 0 ] == d[ 1 ][ 1 ]
      && d[ 0 ][ 0 ] == d[ 2 ][ 2 ] )
    {
      puts ( PRED( d[ 0 ][ 0 ] ) );
      goto CONT;
    }
    if ( d[ 0 ][ 2 ] >= 0
      && d[ 0 ][ 2 ] == d[ 1 ][ 1 ]
      && d[ 0 ][ 2 ] == d[ 2 ][ 0 ] )
    {
      puts ( PRED( d[ 0 ][ 2 ] ) );
      goto CONT;
    }

    puts ( "d" );

CONT: ;
  }

  return ( 0 );
}

Measured memory_bytes: 0
z = input()
s = int(input())
b, c = 0,0
r=[]
for i in range(s):
    a = input().split()
    if a[0] == "print":
        b, c = int(a[1]), int(a[2])
        print(z[int(b):int(c)+1])
    elif a[0] == "reverse":
        b, c = int(a[1]), int(a[2])
        r= list(z[b:c+1])
        r=r[::-1]
        z=list(z)
        z[b:c+1]=r
        z=''.join(z)

    else:
        b, c, d = int(a[1]), int(a[2]), list(a[3])
        z=list(z)
        z[b:c+1]=d
        z=''.join(z)

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

signed main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  map<int, int> c[2];
  for (int i = 0; i < N; ++i) ++c[i & 1][A[i]];

  vector<pair<int, int>> v[2];
  for (int i = 0; i < 2; ++i)
    for (auto p : c[i])
      v[i].emplace_back(-p.second, p.first);

  for (int i = 0; i < 2; ++i)
    sort(v[i].begin(), v[i].end());

  int ans = 0;
  if (v[0][0].second == v[1][0].second) {
    ans = N + min(v[0][0].first + (1 < v[1].size() ? v[1][1].first : 0),
                  v[1][0].first + (1 < v[0].size() ? v[0][1].first : 0));
  } else {
    ans = N + v[0][0].first + v[1][0].first;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int r, c, matrix[100][100];
	scanf("%d %d", &r, &c);
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++)scanf("%d", &matrix[i][j]);
	}
	int sumsum = 0;
	for (int i = 0; i < r + 1; i++) {
		if (i == r) {
			int sum;
			for (int j = 0; j < c+1; j++) {
				if (j == c) {
					printf("%d\n", sumsum);
					break;
				}
				sum = 0;
				for (int k = 0; k < r; k++) {
					sum += matrix[k][j];
				}
				printf("%d ", sum);
				sumsum += sum;
			}
		}
		else {
			int sum = 0;
			for (int j = 0; j < c; j++) {
				printf("%d ", matrix[i][j]);
				sum += matrix[i][j];
				if (j == c-1)printf("%d\n", sum);
			}
		}
	}
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,ans=0;
int a[200005],visited[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  visited[a[i]]++;
	
	for (int i=1;i<=200000;i++)  ans=max(ans,visited[i]+visited[i-1]+visited[i+1]);
	cout<<ans<<endl;
	
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b; cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	if (a > b) cout << "Alice";
	if (a == b) cout << "Draw";
	if (a < b) cout << "Bob";
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

const int N = (int) 1e5 + 123;

int n;
int a[N];

void NO() {
    cout << "No\n";
    exit(0);
}

void YES() {
    cout << "Yes\n";
    exit(0);
}

void run() {
    cin >> n;
    read(a, a + n);
    sort(a, a + n);
    if (abs(a[n - 1] - a[0]) > 1) NO();
    
    if (a[0] == a[n - 1]) {
        int x = a[0];
        if (x == n - 1) YES();
        if (2 * x > n) NO();
        YES();
    } else {
        int x = a[n - 1];
        int cnt_u = 0, cnt_n = 0;
        rep(i, 0, n) {
            if (a[i] == x) cnt_n++;
            else cnt_u++;
        }
        
        int rest = x - cnt_u;
        if (rest <= 0) NO();
        if (2 * rest > cnt_n) NO();
        YES();
    }
}


Measured memory_bytes: 640
def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v

        print(' '.join(map(str, A)))

if __name__ == "__main__":
    n = int(input())
    a = [int(e) for e in input().split()]
    print(' '.join(map(str, a)))
    insertionSort(a, n)

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

int main() {
  int N;
  cin>>N;
  string str;
  cin>>str;
  if(str.size()>N){
  for(int i=0;i<N;i++){
    cout<<str.at(i);
  }
  cout<<"..."<<endl;
  }
  else{
    for(int i=0;i<str.size();i++){
      cout<<str.at(i);
    }
  }
  }

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

int n;


int a[102];

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	long long int ans = LLONG_MAX;
	for (int j = -100; j <= 100; j++){
		long long int tmp = 0;
		for (int k = 0; k < n; k++){
			long long int ab = a[k] - j;
			ab *= ab;
			tmp += ab;
		}
		ans = min(ans, tmp);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int maxn = 3010;
const int mo = 1000000007;
using namespace std;
int a[maxn], b[maxn], f[maxn][maxn], n, m; char s[maxn];
void solve1(int l, int r) {
	int tot = 0;
	rep(i, l, r) tot += a[i];
	rep(i, l, l + tot - 1) a[i] = 1;
	rep(i, l + tot, r) a[i] = 0;
}
void solve2(int l, int r) {
	int tot = 0;
	rep(i, l, r) tot += 1 - b[i];
	rep(i, l, l + tot - 1) b[i] = 0;
	rep(i, l + tot, r) b[i] = 1;
}
int main() {
	scanf("%d%d", &n, &m);
	scanf("%s", s + 1);
	rep(i, 1, n) a[i] = b[i] = (s[i] == '1');
	rep(i, 1, n) b[i] = a[i]; int x, y;
	rep(i, 1, m) scanf("%d%d", &x, &y), solve1(x, y), solve2(x, y);
	rep(i, 2, n) a[i] += a[i - 1], b[i] += b[i - 1];
	f[0][0] = 1;
	rep(i, 1, n) rep(j, b[i], a[i]) f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % mo;
	printf("%d\n", f[n][a[n]]);
	return 0;
}

Measured memory_bytes: 12416
#include <stdio.h>

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

	scanf("%d %d %d %d %d", &W, &H,&x,&y,&r);
	i =W - r;
	j =H - r;


	if (r <= x && x <= i){
		if (r <= y&&y <= j)
			printf("Yes\n");
		else
			printf("No\n");
	}
		else
			printf("No\n");

	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <iterator>

using ll = long long;
using namespace std;
#define modmod 1000000007

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)


int main(){
    int N;
    ll x;
    cin >> N >> x;
    ll a[N];
    ll sum=0;
    ll count = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(i==0){
            if(a[i] > x){
                count += a[i]-x;
                a[i] = x;
            }
            continue;
        }
        sum = a[i-1] + a[i];
        if(sum > x){
            count += (sum - x);
            a[i] -= (sum - x);
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    int bingo[3][3];
    int n,count = 0;
    bool check[3][3] = {false};
    

    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> bingo[i][j];
        }
    }

    cin >> n;

    int *array = new int[n];

    for(int i = 0;i < n;i++){
        cin >> array[i];
    }

    while(count != n){
        for(int i = 0;i < 3;i++){
            for(int j = 0;j < 3;j++){
                if(bingo[i][j] == array[count]){
                    check[i][j] = true;
                }
            }
        }
        count++;
    }

    if(check[0][0] && check[1][1] && check[2][2]){
        cout << "Yes" << endl;
        return 0;
    }else if(check[2][0] && check[1][1] && check[0][2]){
        cout << "Yes" << endl;
        return 0;
    }

    for(int i = 0;i < 3;i++){
        int yoko = 0;
        for(int j = 0;j < 3;j++){
            if(check[i][j])
                yoko++;
        }
        if(yoko == 3){
            cout << "Yes" << endl;
            return 0;
        }else{
            yoko = 0;
        }
    }

    for(int i = 0;i < 3;i++){
        int tate = 0;
        for(int j = 0;j < 3;j++){
            if(check[j][i])
                tate++;
        }
        if(tate == 3){
            cout << "Yes" << endl;
            return 0;
        }else{
            tate = 0;
        }
    }

    cout << "No" << endl;

    delete [] array;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  ll N;
  cin >> N;
  vi A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());  // 昇順

  if (A[0] == 1) {
    if (N > 1 && A[1] == 1)
      cout << 0 << endl;
    else
      cout << 1 << endl;
    return 0;
  }

  ll ans = 0;

  vector<bool> B(1e6 + 10);
  for (ll i = 0; i < N; i++) {
    B[A[i]] = true;
    if ((i > 0 && A[i - 1] == A[i]) || (i < N - 1 && A[i + 1] == A[i]))
      continue;

    ll j = 2;
    bool isOK = true;
    while (j * j <= A[i]) {
      if (A[i] % j == 0 && (B[j] || B[A[i] / j])) {
        isOK = false;
        break;
      }
      j++;
    }
    if (isOK)
      ans++;
  }

  cout << ans << endl;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	int L; cin >> L;
	vector<int> T(N);
	for (int i = 0; i < N; i++) cin >> T[i];
	T.push_back(T.back()+L);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += min(T[i+1] - T[i], L);
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);++i)
bool a[256][256];
int main(){
	string s="n";
	printf("?%s\n",s.c_str());
	a['n'][' ']=true;
	char t='n';
	while(1){
		cin>>s;
		if(s.size()==1) s+=" ";
		if(a[s[0]][s[1]]||t!=s[0]){
			printf("!OUT\n");
			return 0;
		}
		a[s[0]][s[1]]=true;
		t=s[1];
		if(t==' ') t=s[0];
		if(!a[t]['n']){
			a[t]['n']=true;
			s[0]=t;
			s[1]='n';
		}
		else reep(i,'a','z'){
			if(!a[t][i]){
				s[0]=t;
				s[1]=i;
				a[t][i]=true;
				break;
			}
		}
		printf("?%s\n",s.c_str());
		t=s[1];
	}
}

Measured memory_bytes: 1256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N, K;
    cin >> N >> K;
    ll h[N];
    REP(i, 0, N) {
        cin >> h[i];
    }
    sort(h, h + N);
    ll ans = inf;
    REP(i, 0, N - K + 1) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}


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

const int oo = 1e9;

using namespace std;

void solve() {
    int n, w;
    cin >> n >> w;
    vector<int> W(n + 1), V(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> W[i] >> V[i];
    }
    vector<vector<long long>> dp(n + 1, vector<long long>(1e5 + 123));
    for (int i = 0; i <= w; i++) {
        dp[0][i] = 0;
    }
    for (int i = 1; i <= n; i++) {
        //cerr << 1 << endl;
        for (int j = w; j >= 1; j--) {
            // cerr << j << " ";
            if (j >= W[i]) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-W[i]] + V[i]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
            // cerr << 1 << endl;
        }
    }
    long long res = 0;
    for (int i = 1; i <= w; i++) {
        res = max(res, dp[n][i]);
    }
    cout << res;
}

int main() {
    #ifdef DEBUG
        freopen("solve.inp", "r", stdin);
        freopen("solve.out", "w", stdout);
    #endif
    solve();
    return 0;
}   

Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue> 
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
long long d[10000000],m,a,b;
bool isans(long long ex)
{
	long long dam=ex*b;
	long long sum=0;
	for (long long i=m-1;d[i]>dam;i--)
		sum+=(d[i]-dam-1)/(a-b)+1;
	return sum<=ex;
}

int main()
{
	cin>>m;
	cin>>a>>b;
	for(long long i=0;i<m;i++)
		cin>>d[i];
	sort(d,d+m);
	long long left=d[m-1]/a,right=(left+1)*m;
	while (left<right)
	{
		long long mid=(left+right)/2;
		if (isans(mid)) right=mid;
		else left=mid+1;
	}
	cout<<left<<endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# coding: utf-8

# In[30]:


import sys
#import numpy as np
#import itertools
input = sys.stdin.readline
N, K = map(int, input().split())
V = list(map(int, input().split()))


# In[36]:


#print(N, K)
#print(V)


# In[ ]:


"""
6 4
-10 8 2 1 2 6
"""


# In[46]:


ans = 0
for l in range(K+1):
    if l > N:
        continue
    for r in range(K+1-l):
        if l+r>K or l+r>N:
            continue
        d = K-(l+r)
        picked = V[:l] + V[-r:] if r != 0 else V[:l]
        #print("l:{}, r:{}, picked{}".format(l, r, picked))
        sp = sorted(picked)
        now = sum(picked)
        #print(sp)
        for i in range(d):
            if i >= len(picked):
                break
            if sp[i] > 0:
                break
            now -= sp[i]
        ans = max(ans, now)
print(ans)
        
"""
if N < K:
    scs = []
    for i in range(K-N):
        scs.append(sorted(V[i:]))
    s = max(scs)
else:
    scs = []
    for i in range(K//2):
        #print("{}個返す".format(i))
        scss = []
        for j in range(K+1-i):
            #print("左から{}個　右から{}個/{}".format(j,K-j-i, K-i))
            if j == K-i:
                choices = V[:j]
            else:
                choices = V[:j] + V[-K+j+i:]
            #print(choices)
            #print(sorted(choices)[i:])
            scss.append(sum(sorted(choices)[i:]))
        scs.append(max(scss))
    s = max(scs)
    s = 0 if s<0 else s
print(s)
"""


# In[ ]:






Measured memory_bytes: 3064
n, T = map(int, input().split())
list = []
ans = 1e9
for i in range(n) :
    c, t = map(int, input().split())
    if t <= T :
        if c < ans :
            ans = c;
if ans == 1e9 :
    print("TLE")
else :
    print(ans)


Measured memory_bytes: 2940