akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : ExhausiveSearch.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

void writeVector(const vector<bool>& v){
	for(int i=0; i<v.size(); i++){
		cout << v.at(i) << " ";
	}
	cout << "\n";
}

int main() {
	int n, input, total_sum;
	vector<int> A;
	vector<int> on_off;

	cin >> n;

	for(int i=0; i<n; i++){
		cin >> input;
		A.push_back(input);
		total_sum += input;
		on_off.push_back(0);
	}

	vector<bool> sum_list(total_sum+1);
	//writeVector(sum_list);

	for(int i=0; i<pow(2, n); i++){
		int position = 0;
		int sum = on_off.at(position);
		while(sum == 2){
			on_off.at(position) = 0;
			position += 1;
			on_off.at(position) += 1;
			sum = on_off.at(position);
			//cout << "here";
		}
		//writeVector(on_off);
		int sum_subset_A = 0;
		for(int j=0; j<A.size(); j++){
			sum_subset_A += A.at(j) * on_off.at(j);
		}
		sum_list.at(sum_subset_A) = 1;
		//cout << sum_subset_A << " ";

		on_off.at(0) += 1;
	}

	int q;
	cin >> q;

	for(int i=0; i<q; i++){
		cin >> input;
		if(input > sum_list.size()){
			cout << "no\n";
		}
		else if(sum_list.at(input)==0){
			cout << "no\n";
		}else{
			cout << "yes\n";
		}
		//cout << "here";
	}

	return 0;
}



Measured memory_bytes: 3400
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   string s,t;
   cin>>s>>t;
   int n=s.length();
   int m=t.length();
   int mn=1e9;
   for(int i=0;i<(n-m+1);i++)
   {   int cnt=0;
       for(int j=i;j<(i+m);j++)
       {
           if(s[j]!=t[j-i])cnt++;
       }
       mn=min(mn,cnt);
   }
   cout<<mn<<endl;
}


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

int seiyaku_check(double i,int Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b;
	int x,y,z;
	
	cin >> a >> b;
	seiyaku_check(a,-100,100);
	seiyaku_check(b,-100,100);
	
	x = a*b;
	y = a+b;
	z = a-b;
	
	if(x == y == z){
		cout << x << endl;
	}else if(x >= y && x >= z){
		cout << x << endl;
	}else if(y >= x && y >= z){
		cout << y << endl;
	}else if(z >= x && z >= y){
	cout << z << endl;
	}
	
	
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(N);
	for(int i=0; i<N; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	vector<pair<int, int>> p(M+1);
	for(int i=0; i<M; ++i){
	    cin >> p[i].second >> p[i].first;
	}
	p[M]=make_pair(0, 5);
	sort(p.begin(), p.end(), greater<pair<int, int>>());
	ll ans=0;
	int now=0, cnt=0;
	for(int i=0; i<N; ++i){
	    if(p[now].first>a[i]){
	        ans += p[now].first;
	        ++cnt;
	        if(cnt==p[now].second){
	            ++now;
	            cnt=0;
	        }
	    }
	    else ans += a[i];
	}
	cout << ans << endl;
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}


int main() {
  int n,x;cin>>n>>x;
  int d=0;
  int ans=1;
  REP(i,n){
    int l;
    cin>>l;
    d+=l;
    if(d>x){
      break;
    }
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    ll count=0;
    for(size_t i=0;i<N; i++)
    {
        ll d1, d2;
        cin >> d1 >> d2;
        if(d1==d2)
        {
            count++;
            if(count==3)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }else
        {
            count=0;
        }
    }
    cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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




int main() {
    string s;
    cin >> s;
    int l = s.length();
    int f = (l-1)/2;
    int se = (l+3)/2 -1;
    
    for(int i=0;i<f;i++){
        if(s[i] != s[se+i]){
            cout << "No" <<endl;
            return 0;
        }
    }

    cout << "Yes" <<endl;
  return 0;


}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn f(a0: i64, a1: i64, sum: i64) -> i64 {
    if a0 + a1 < sum || (a0 + a1 + sum) % 2 == 1 {
        return -1;
    }
    let goal = (a0 + a1 - sum) / 2;
    if (sum & goal) != 0 {
        return -1;
    }
    if goal > a0 {
        return -1;
    }
    let mut u = goal;
    for i in (0..60).rev() {
        if (sum & 1 << i) != 0 && (u | 1 << i) <= a0 {
            u |= 1 << i;
        }
    }
    if u == 0 { -1 } else { a0 - u }
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut sum = 0;
    for i in 2..n {
        sum ^= a[i];
    }
    puts!("{}\n", f(a[0], a[1], sum));
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2252
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int row = sc.nextInt();
        int col = sc.nextInt();
        
        int n=0,rowSum=0;
        int[] colSum = new int[col];
        for(int i=0; i<=row; i++){
            for(int j=0; j<col; j++){
            	if(i!=row) {
            		n = sc.nextInt();
            		rowSum += n;
            		colSum[j] += n;
            		System.out.print(n +" ");
            	}else {
            		System.out.print(colSum[j] +" ");
            		rowSum += colSum[j];
            	}
            }
            System.out.println(rowSum);
            rowSum = 0;
        }
    }
}


Measured memory_bytes: 40888
from collections import Counter
from itertools import permutations

def main():
    N, C = map(int, input().split())
    D = [[int(x) for x in input().split()] for _ in range(C)]

    cnt = [Counter() for _ in range(3)]

    for i in range(N):
        c = [int(x)-1 for x in input().split()]
        for j in range(3):
            cnt[j].update(c[(3-(i+2)+j)%3::3])

    ans = 1000*500*500+5
    for p in permutations(range(C), 3):
        s = 0
        for j in range(3):
            s += sum(D[k][p[j]] * v for k, v in cnt[j].items())
        ans = min(ans, s)
    print(ans)

main()


Measured memory_bytes: 3444
#include <cstdio>
#include <complex>
using namespace std;
typedef complex<double> P;

/* ?¨±?????????????????  */
#define EPS (1e-10)
/* 2?????????????????????????????????????????? */
#define EQ(a,b) (abs((a)-(b)) < EPS)

/* ?????? (cross product) : a??b = |a||b|sin */
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

/* ?????? (dot product) : a???b = |a||b|cos??  */
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}

/* 2??´????????´????????? : a??\b <=> dot(a, b) = 0 */
int isOrthogonal(P a1, P a2, P b1, P b2) {
  return EQ( dot(a1-a2, b1-b2), 0.0 );
}

/* 2??´?????????????????? : a//b <=> cross(a, b) = 0 */
int isParallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}


int main() {
  int n;
  int ax, ay, bx, by, cx, cy, dx, dy;
  scanf("%d", &n);

  while(n--) {
    scanf("%d %d %d %d %d %d %d %d", &ax, &ay, &bx, &by, &cx, &cy, &dx, &dy);
    P a(ax, ay), b(bx, by), c(cx, cy), d(dx, dy);
    if(isParallel(a, b, c, d)) puts("2");
    else if(isOrthogonal(a, b, c, d)) puts("1");
    else puts("0");
  }
  return 0;
}

Measured memory_bytes: 2672
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010;
int N,L,Q;
int a[maxn],f[maxn][21];
int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++)
		a[i]=read();
	L=read(),Q=read();
	for(int i=1;i<=N;i++)
		f[i][0]=lower_bound(a+1,a+1+N,a[i]+L+1)-a-1;
	for(int j=1;j<=20;j++)
		for(int i=1;i<=N;i++)
			f[i][j]=f[f[i][j-1]][j-1];
	while(Q--){
		int x=read(),y=read(),ans=0;
		if(x>y)swap(x,y);
		for(int i=20;i>=0;i--)
			if(f[x][i]<y)
				x=f[x][i],ans+=(1<<i);
		if(x<y)
			ans++;
		printf("%d\n",ans);
	}
	return 0;
}



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

int main(){

int N,K;
cin >> N >> K;

//vectorの前にNを入力
vector<long long> H(N);
for(int i=0; i<N; i++) cin >> H.at(i);

sort(H.begin(),H.end(),greater<int>());

long long sum = 0;
for(int i=K; i<N; i++){
    sum += H.at(i);
}

cout << sum << endl;
}

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

using namespace std;

int main(){

  vector<int> v;
  int n;
  int k;
  int temp;
  int ans = 0;
  
  cin >> n >> k;
  for( int i = 0; i < n; ++i){
    cin >> temp;
    v.push_back(temp);
  }
  sort( v.begin(), v.end());
  reverse( v.begin(), v.end());
  for( int i = 0; i < k; ++i){
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * Problem Description: Binary Search Tree III
 * Category: Binary Search Trees
 * Author: Khan
 * Date: 24th October, 2017
 */

#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;

struct Node
{
    int key;
    Node *r, *l, *p;
};

Node *root, *NIL;

void Insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;

    while(x != NIL)
    {
        y = x;
        if(z->key < x->key)
            x = x->l;
        else
            x = x->r;
    }

    z->p = y;
    if(y == NIL)
        root = z;
    else
    {
        if(z->key < y->key)
            y->l = z;
        else
            y->r = z;
    }
}

void Inorder(Node *u)
{
    if(u == NIL)
        return;
    Inorder(u->l);
    printf(" %d", u->key);
    Inorder(u->r);
}

void Preorder(Node *u)
{
    if(u == NIL)
        return;
    printf(" %d", u->key);
    Preorder(u->l);
    Preorder(u->r);
}

Node *find(Node *u, int k)
{
    while(u != NIL && k != u->key)
    {
        if(k < u->key)
            u = u->l;
        else
            u = u->r;
    }
    return u;
}

Node * treeMinimum(Node *x)
{
    while(x->l != NIL)
        x = x->l;
    return x;
}

Node * treeSuccessor(Node *x)
{
    if(x->r != NIL)
        return treeMinimum(x->r);
    Node *y = x->p;
    while(y != NIL && x == y->r)
    {
        x = y;
        y = y->p;
    }
    return y;
}

void treeDelete(Node *z)
{
    Node *y;
    Node *x;

    if(z->l == NIL || z->r == NIL)
        y = z;
    else
        y = treeSuccessor(z);

    if(y->l != NIL)
        x = y->l;
    else
        x = y->r;

    if(x != NIL)
        x->p = y->p;

    if(y->p == NIL)
        root = x;
    else
    {
        if(y == y->p->l)
            y->p->l = x;
        else
            y->p->r = x;
    }

    if(y != z)
        z->key = y->key;

    free(y);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int n, i, x;
    string cmd;

    scanf("%d", &n);

    for (int i = 0; i < n; ++i)
    {
        cin >> cmd;
        if(cmd[0] == 'f')
        {
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t != NIL)
                printf("yes\n");
            else
                printf("no\n");
        }
        else if(cmd[0] == 'i')
        {
            scanf("%d", &x);
            Insert(x);
        }
        else if(cmd[0] == 'p')
        {
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
        else if(cmd[0] == 'd')
        {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll k;
  string s;
  cin>>k>>s;
  ll n=s.size();
  if(n<=k) cout<<s<<endl;
  else{
    cout<<s.substr(0,k)+"..."<<endl;
  }
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(a: int, b: int):
    n = int(str(a) + str(b))
    if int(n ** 0.5) * int(n ** 0.5) == n:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int D;
    cin >> D;
    if(D == 25)
        cout << "Christmas" << endl;
    else if(D == 24)
        cout << "Christmas Eve" << endl;
    else if(D == 23)
        cout << "Christmas Eve Eve" << endl;
    else
        cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

from math import *

x = A1*T1 + A2*T2 - (B1*T1 + B2*T2)
y = A1*T1 - B1*T1
if(x ==0 or y==0):
    print('infinity')
elif(y * x > 0):
    print(0)
else:
    z = floor(abs(y) / abs(x))
    if abs(y) == z * abs(x):
        print(floor(abs(y)/abs(x))*2)
    else:
        print(floor(abs(y)/abs(x))*2+1)



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>


int main(){
	int n, a, b, c, d;
	std::string s;
	bool isAvailable= true;

	std::cin>>n>>a>>b>>c>>d;
	std::cin>>s;

	a= a-1;
	b= b-1;
	c= c-1;
	d= d-1;

	for(int i= a+1; i<c-1; i++)
		if(s[i]=='#' && s[i+1]=='#')
			isAvailable=false;
	
	for(int i= b+1; i<d-1; i++)
		if(s[i]=='#' && s[i+1]=='#')
			isAvailable=false;

	if(d-c> 0){
		if(isAvailable)
			std::cout<<"Yes"<<std::endl;
		else
			std::cout<<"No"<<std::endl;

		return 0;
	}
	else{
		bool isAvailable2=false;

		for(int i=b-1; i<d; i++)
			if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.')
				isAvailable2=true;


		if(isAvailable && isAvailable2)
			std::cout<<"Yes"<<std::endl;
		else
			std::cout<<"No"<<std::endl;


		return 0;
	}
}

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

int main(){
	int q,n,count,a,b,res;
	string s,s1,s2;

	cin >> q;
	for(int i = 0;i < q;i++){
		cin >> n;
		count = 0;
		while(1){
			res = 0;
			if(n/10 == 0)break;
			s = to_string(n);
			for(int j = 1;j < s.size();j++){
				s1.assign(s,0,j);
				s2.assign(s,j,s.size()-j);
				a = stoi(s1);
				b = stoi(s2);
				res = max(res,a*b);
			}
			n = res;
			count++;
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 3276
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                String S=sc.next();
                int n=S.length();
                int x=0;
                if(S.charAt(0)=='A'){
                        if(Character.isLowerCase(S.charAt(1))){
                                for(int i=2;i<n-1;i++){
                                        if((Character.isLowerCase(S.charAt(i)))||((S.charAt(i)=='C')&&(x==0))){
                                                if(S.charAt(i)=='C'){
                                                        x++;
                                                }

                                        }else{
                                                System.out.println("WA");
                                                x=100;
                                                break;
                                                
                                        }

                                }
                                if(x!=100){
                                if((Character.isLowerCase(S.charAt(n-1)))&&(x==1)){
                                        System.out.println("AC");
                                }else{
                                        System.out.println("WA");
                                }}



                        }else{
                                System.out.println("WA");
                        }
                }else{
                        System.out.println("WA");
                }


                
                
                
                


                
        }
        
        
        

		
	
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(Int i=0;i<h;i++) cin>>st[i];

  vector<Int> us,vs;
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(st[i][j]!='B') continue;
      us.emplace_back(i+j);
      vs.emplace_back(i-j);
    }
  }
  sort(us.begin(),us.end());
  sort(vs.begin(),vs.end());

  cout<<max(us.back()-us.front(),vs.back()-vs.front())<<endl;
  return 0;
}



Measured memory_bytes: 16036
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
bool valid(int x, int y, int n) {
	return x >= 0 && x < n&&y >= 0 && y < n;
}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,-1,0,1 };
void solve(vector<vector<int>>&field) {
	for (int n = 0; n < field.size(); ++n) {
		for (int k = 1; k <= n-1; ++k) {
			int nowy = k;
			int nowx = n - k;
			int uad = 0;
			const int uy = nowy - 1;
			const int ux = nowx;
			for (int way = 0; way < 3; ++way) {
				if (valid(ux+dx[way],uy+dy[way], field.size()) &&
					field[uy][ux] == field[uy+dy[way]][ux+dx[way]])uad++;
			}
			if (uad == 0 || uad == 3)assert(false);
			else if (uad == 1) {
				field[nowy][nowx] = field[uy][ux];
			}
			else {
				field[nowy][nowx] = !field[uy][ux];
			}
		}
	}
	for (int n = field.size(); n < 2 * field.size()-1; ++n) {
		for (int k = 1; k < 2*field.size()-n; ++k) {
			int nowy = k+n-field.size();
			int nowx = field.size()-k;
			int uad = 0;
			const int uy = nowy - 1;
			const int ux = nowx;
			for (int way = 0; way < 3; ++way) {
				if (valid(ux+dx[way], uy + dy[way], field.size()) &&
					field[uy][ux] == field[uy + dy[way]][ux+dx[way]])uad++;
			}
			if (uad == 0 || uad == 3)assert(false);
			else if (uad == 1) {
				field[nowy][nowx] = field[uy][ux];
			}
			else {
				field[nowy][nowx] = !field[uy][ux];
			}
		}
	}
}

int main() {
	while (1) {
		int N; cin >> N;
		long long int K; cin >> K;
		K--;
		if (!N)break;
		if (1ll << (N/2) <= K||N%2)cout << "No" << endl;
		else {
			bitset<64>bs(K);
			vector<vector<int>>field(N, vector<int>(N,-1));
			for (int i = 0; i < N/2; ++i) {
				for (int j = 0; j < 2; ++j) {

					field[0][i * 2+j ] = bs[N/2-1-i];

					field[i*2+j][0] = bs[N/2-1-i];
				}
			}
			solve(field);
			for (int y = 0; y < N; ++y) {
				for (int x = 0; x < N; ++x) {
					if (!field[y][x])cout << '.';
					else cout << 'E';

				}
				cout << endl;
			}
		}
		cout << endl;

	}
	return 0;
}

Measured memory_bytes: 3044
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
 
int main(){
     int x1,x2,x3,x4,x5;
     cin>>x1>>x2>>x3>>x4>>x5;
     if(x1==0){
          cout<<"1"<<endl;
     }
     else if(x2==0){
          cout<<"2"<<endl;
     }
     else if(x3==0){
          cout<<"3"<<endl;
     }
     else if(x4==0){
          cout<<"4"<<endl;
     }
     else{
          cout<<"5"<<endl;
     }

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e6+5;
const ll MOD = 1e6+3;

string str[MOD+5];

ll Hash(string s)
{
    ll ret = 0;
    int len = s.size();
    rep(i, 0, len-1){
        ret = (ret + 1ll * s[i]*(s[i]+i)*(s[i]*i)*(s[i]+len/(i+1))%MOD)%MOD;
    }
    return ret;
}

int H1(ll key){ return key % MOD; }
int H2(ll key){ return 1 + key % (MOD-1); }

void add(string s)
{
    ll key = Hash(s);
    int t = 0;
    while (true)
    {
        int p = (H1(key) + t++ * H2(key))%MOD;
        if (str[p] == "")
        {
            str[p] = s;
            break;
        }
    }
    return;
}

bool Find(string s)
{
    ll key = Hash(s);
    int t = 0;
    while (true)
    {
        int p = (H1(key) + t++ * H2(key))%MOD;
        if (str[p] == s)
            return 1;
        else if (str[p] == "")
            return 0;
    }
}

int main()
{
    IOS;
    int n;
    string ctrl, s;
    cin >> n;
    while (n--)
    {
        cin >> ctrl >> s;
        if (ctrl == "insert")
            add(s);
        else if (Find(s))
            cout << "yes\n";
        else
            cout << "no\n";
    }

    return 0;
}



Measured memory_bytes: 38352
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//map
int main()
{
    int cnt = 1;
    int tmp;
    while(true)
    {
        cin >> tmp;
        if(tmp == 0)break;
        cout << "Case " << cnt << ": " << tmp << endl;
        ++cnt;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<stack>
using namespace std;

int main()
{
        int train;
        stack<int> out;
        while(cin >> train)
        {
                if(train != 0){
                        out.push(train);
                }
                else{
                        cout << out.top() << endl;
                        out.pop();
                }
        }
        return 0;
}

Measured memory_bytes: 1196
#include <iostream>

int area(int a, int b) {
    return a * b;
}

int perimeter(int a, int b) {
    return (a + b) * 2;
}

int main() {
    for (int a, b; std::cin >> a >> b;) {
        std::cout << area(a, b) << " " << perimeter(a, b) << '\n';
    }
}


Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main(){
  int a, b, c, k;
  
  cin >> a >> b >> c >> k;
  
  if(k <= a){
    cout << k << endl;
    return 0;
  }
  
  if(k <= a + b){
    cout << a << endl;
    return 0;
  }
  
  cout << a - (k - a - b) << endl;
  
  return 0;
}

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

int main(){
  int X,N;
  int cnt = 0;
  int small,large;
  cin >> X >> N;
  small = X - 1;
  large = X + 1;
  if(N == 0){
    cout << X << endl;
    return 0;
  }
  vector <int> p(N);
  for(int i = 0; i < N; i++)
    cin >> p.at(i);
  
  for(int i = 0; i < N; i++){
    if(X == p.at(i))
      break;
    else
      cnt++;
  }
  if(cnt == N){
    cout << X << endl;
    return 0;
  }
  cnt = 0;
  while(1){
    for(int i = 0; i < N; i++){
      if(small == p.at(i)){
        small--;
        break;
      }
      else cnt++;
    }
    if(cnt == N){
      cout << small << endl;
      return 0;
    }
    cnt = 0;
    
    for(int i = 0; i < N; i++){
      if(large == p.at(i)){
        large++;
       	break;
      }
      else cnt++;
    }
    if(cnt == N){
      cout << large << endl;
      return 0;
    }
    cnt = 0;
  }
}

Measured memory_bytes: 3592
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    x = [int(e) for e in lines[0].split(' ')]

    return (x, )


def solve(x):



    return x.index(0) + 1
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 61996
using System;
using System.Linq;

class ITP1
{
    static void Main()
    {
            string str = Console.ReadLine();
            int a = int.Parse(str);
            int[] s = new int[14];
            int[] h = new int[14];
            int[] c = new int[14];
            int[] d = new int[14];
            for (int i = 0; i < a; i++)
            {
                str = Console.ReadLine();
                char mark = char.Parse(str.Split(' ')[0]);
                int rank = int.Parse(str.Split(' ')[1]);
                if (mark == 'S')
                {
                    s[rank]=1;
                }
                if (mark == 'H')
                {
                    h[rank]=1;
                }
                if (mark == 'C')
                {
                    c[rank]=1;
                }
                if (mark == 'D')
                {
                    d[rank]=1;
                }
            }
                
for(int i=1;i<14;i++)
{
    if(s[i]==0){Console.WriteLine("S {0}",i);
    }
}
for (int i = 1; i < 14; i++)
{
    if(h[i]==0){Console.WriteLine("H {0}",i);
    }
}
for (int i = 1; i < 14; i++)
{
    if(c[i]==0){Console.WriteLine("C {0}",i);
    }
}
for (int i = 1; i < 14; i++)
{
    if(d[i]==0){Console.WriteLine("D {0}",i);
    }
}

                    
                
        
    }
}

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

#define endl '\n'

bool is_strong_palindrome(const string& s)
{
    for (int i = 0; i < s.size()/2; i++)
        if (s[i] != s[s.size()-1-i]) return false;

    string temp = s.substr(0, s.size()/2);
    for (int i = 0; i < temp.size()/2; i++)
        if (temp[i] != temp[temp.size()-1-i]) return false;

    temp = s.substr(s.size()/2+1);
    for (int i = 0; i < temp.size()/2; i++)
        if (temp[i] != temp[temp.size()-1-i]) return false;
    return true;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;
    cout << (is_strong_palindrome(s) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var shops = new Pair[nm[0]];
            for (var i = 0; i < nm[0]; i++)
            {
                var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                shops[i] = new Pair { Price = ab[0], Count = ab[1] };
            }
            shops = shops.OrderBy(x => x.Price).ToArray();
            var money = 0L;
            var current = 0L;
            for (var i = 0; i < shops.Length; i++)
            {
                if (current < nm[1])
                {
                    current += shops[i].Count;
                    money += shops[i].Price * shops[i].Count;
                }
                if (current >= nm[1])
                {
                    money -= shops[i].Price * (current - nm[1]);
                    break;
                }
            }
            Console.WriteLine(money);
        }

        public struct Pair
        {
            public long Price { get; set; }
            public long Count { get; set; }
        }
    }
}


Measured memory_bytes: 26936
fn main() {
    proconio::input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    }

    let dq = vec![
        (1 % d, 1),
        (7 % d, 2),
        (23 % d, 4),
        (111 % d, 8),
        (351 % d, 16),
    ];
    let mut t = make_first_t(d, &c, &s);
    let mut sum_v = calc(d, &c, &s, &t).iter().sum::<i64>();

    for dqi in dq {
        let pret = t[dqi.0 - 1];
        t[dqi.0 - 1] = dqi.1;
        let sum_vi = calc(d, &c, &s, &t).iter().sum::<i64>();
        if sum_vi > sum_v {
            sum_v = sum_vi;
        } else {
            t[dqi.0 - 1] = pret;
        }
    }

    for di in 0..d {
        println!("{}", t[di]);
    }
}

fn make_first_t(
    d: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
) -> Vec<usize> {
    let mut t = vec![0; 365];
    let mut last_d = vec![0; 26];
    let mut prev = 0;
    for di in 0..d {
        let mut max_v = 0;
        let mut max_i = 0;
        for i in 0..26 {
            let pre_last_di = last_d[i];
            last_d[i] = di + 1;
            let v = sum_di(di, prev, &c, &s, i + 1, &last_d);
            last_d[i] = pre_last_di;
            if v > max_v {
                max_v = v;
                max_i = i;
            }
        }
        prev = max_v;
        last_d[max_i] = di + 1;
        t[di] = max_i + 1;
    }
    t
}

fn calc(d: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    t: &Vec<usize>,
) -> Vec<i64> {
    let mut last_d = vec![0; 26];

    let mut prev = 0;
    let mut v = vec![0; 365];
    for di in 0..d {
        last_d[t[di] - 1] = di + 1;
        prev = sum_di(di, prev, &c, &s, t[di], &last_d);
        v[di] = prev;
    }
    v
}

fn sum_di(
    di: usize,
    prev: i64,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    t: usize,
    last_d: &Vec<usize>,
) -> i64 {
    let mut v = prev + s[di][t - 1];
    for i in 0..26 {
        v -= c[i] * ((di + 1 - last_d[i]) as i64);
    }
    v
}


Measured memory_bytes: 2336
#include <stdio.h>
#include <ctype.h>
#define MAX 1202
#define alphaNum 26
 
int main(void){
    int i;
    char str[MAX];
    int count[alphaNum] = {0};
 
    while(fgets(str, MAX, stdin) != NULL){
        for(i = 0; str[i] != '\n'; i++){
            if(isalpha(str[i])){
                if(isupper(str[i])){
                    count[str[i] - 'A']++;
                }
                if(islower(str[i])){
                    count[str[i] - 'a']++;
                }
            }
        }
    }
 
    for(i = 0; i < alphaNum; i++){
        printf("%c : %d\n", i + 'a', count[i]);
    }
    return 0;
}

Measured memory_bytes: 948
#include <iostream>
#include<string>
using namespace std;
int main(){
    int n,q,v = 0,w = 0,s[10000],t[1000];
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> s[i];
    }
    cin >> q;
    for(int i = 0;i < q;i++){
        cin >> t[i];
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < q;j++){
            if(s[i] == t[j]){
               v++;
               break;
            }
        }
    }
    for(int i = 0;i < q;i++){
        for(int j = 0;j < n;j++){
            if(s[j] == t[i]){
               w++;
               break;
            }
        }
    }
    if(v <= w){
        cout << v << endl;
    }
    else{
        cout << w << endl;
    }
}


Measured memory_bytes: 3120
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;
int const N_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  if (!po[n]) {
    po[0] = 1;
    FOR(i, 1, n + 1) po[i] = po[i - 1] * i % MOD;
  }
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int H, W;
string ss[2001];
int hs[2001], ws[2001];
map<int, queue<int>> hg;
map<int, vector<int>> wg;

int main() {
  scanf("%d %d", &H, &W);
  rep(i, H) cin >> ss[i];

  rep(i, H) {
    rep(j, W) {
      string s = ss[i];
      char c = s[j];

      if (c == '#') {
        hg[i].push(j);
        wg[j].push_back(i);
      }
    }
  }

  int max_lamp = 0;
  rep(i, H) {
    int bef_w = 0;
    int af_w = W;
    rep(j, W) {
      if (ss[i][j] == '#') continue;

      if (af_w < j) {
        bef_w = af_w + 1;
        if (hg[i].empty()) af_w = W;
      }

      if (!hg[i].empty()) {
        if (!(j < af_w && af_w != W)) {

          int w = hg[i].front();
          hg[i].pop();
          while (w < j) {
            bef_w = w + 1;
            if (hg[i].empty()) {
              w = W;
              break;
            } else {
              w = hg[i].front();
              hg[i].pop();
            }
          }
          af_w = w;
        }
      }
      int w_lamp = af_w - bef_w;

      int bef_h = 0;
      int af_h = H;
      for (int h : wg[j]) {
        if (h < i) bef_h = h + 1;
        else {
          af_h = h;
          break;
        }
      }
      int h_lamp = af_h - bef_h;
      max_lamp = max(max_lamp, w_lamp + h_lamp - 1);
    }
  }
  printf("%d\n", max_lamp);
}



Measured memory_bytes: 38016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
void solve() {
	var(int, N, T);
	int c, t;
	priority_queue<int, vector<int>, greater<int>> pq;
	rep(i, 0, N) {
		cin >> c >> t;
		if (t <= T) {
			pq.em(c);
		}
	}
	if (!pq.empty()) {
		print(pq.top());
	} else {
		print("TLE");
	}
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int a;
  int b;
  int c,d,e;
  scanf("%d", &a);
  scanf("%d", &b);
  c = a+b;
   
  if(c%2 == 0){
    printf("%d",c/2);
  }else if(c%2 == 1){
    printf("IMPOSSIBLE");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n, k; cin >> n >> k;
    ll r, s, p; cin >> r >> s >> p;
    string t; cin >> t;
    t = '0'+t;

    // r:0 s:1 p:2
    vector<vector<ll>> dp(n+5, vector<ll>(3, 0));
    repr(i, 1, n+1) rep(j, 3) {
        if (i<=k) {
            if (j==0 && t[i]=='s') dp[i][j] = r;
            if (j==1 && t[i]=='p') dp[i][j] = s;
            if (j==2 && t[i]=='r') dp[i][j] = p; 
        } else {
            rep(q, 3) if (j!=q) {
                if (j==0) {
                    if (t[i]=='s') chmax(dp[i][j], dp[i-k][q]+r);
                    else chmax(dp[i][j], dp[i-k][q]);
                } else if (j==1) {
                    if (t[i]=='p') chmax(dp[i][j], dp[i-k][q]+s);
                    else chmax(dp[i][j], dp[i-k][q]);
                } else {
                    if (t[i]=='r') chmax(dp[i][j], dp[i-k][q]+p);
                    else chmax(dp[i][j], dp[i-k][q]);
                }
            }
        }
    }

    ll ans = 0;
    for(int i=n-k+1; i<=n; ++i) {
        ll tmp = 0;
        rep(j, 3) chmax(tmp, dp[i][j]);
        ans += tmp;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 5868
n = gets.to_i
csf = (n-1).times.map{gets.split.map &:to_i}

ans = Array.new(n, 0)
(n-1).times{|i|
  a = 0
  for j in i...n-1
    c,s,f = csf[j]
    a = s if a < s
    a += (f-(a-s)%f)%f
    a += c
  end
  ans[i] = a
}

ans.each{|t| p t}

Measured memory_bytes: 1916
#include <iostream>
#include <list>
#include <set>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <queue>

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

int main(){
  int n,k,ans=0;
  cin >> n >> k;
  vector<int> p(n);

  rep(i,n){
    cin>> p[i];
  }

  sort(p.begin(), p.end());
  rep(i,k){
    ans+=p[i];
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3608
#include <climits>
#include<iostream>

using namespace std;
int main()
{
    int N;
    cin >> N;
    
    int a;
    int min=INT_MAX;
    int max=0;
    
    for(int i=0;i<N;i++){
        cin >> a;
        if(min>a){
            min=a;
        }
        if(max<a){
            max=a;
        }
    }
    
    cout<< max-min << endl;
    
    return 0;
}


Measured memory_bytes: 256