akhauriyash/Code-Regression huggingface dataset:
def solve():
    ans=0
    count=0
    if n%2!=0:
        print(0)
    else:
        ini=0
        while count==0:
            ini+=1
            a=n//(5**ini)
        
            if a==0:
                count=-1
            else:
                ans+=a//2
            
        print(ans)

n=int(input())
solve()

Measured memory_bytes: 38384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A[222222], F[222222];

  long long K, S = 0;

  std::cin >> N >> K;

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

    S += A[i];
  }

  if (K >= S) {
    std::cout << 0 << std::endl;

    return 0;
  }

  for (int i = 0; i < N; i ++)
    std::cin >> F[i];

  std::sort(A, A + N);
  std::sort(F, F + N, std::greater<int>());

  long long l = -1, u = INF;

  while (u - l > 1) {
    long long m = (l + u) / 2, S = 0;

    for (int i = 0; i < N; i ++)
      S += std::max(A[i] - m / F[i], 0LL);

    (S <= K ? u : l) = m;
  }

  std::cout << u << std::endl;

  return 0;
}


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

using namespace std;

int main()
{
    int n,k,c=0;
    cin>>n>>k;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        if (a[i]>=k)
            c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
using namespace std;
const int N = 10;
int a[N][N], l[N], r[N];
int main() {
	int H, W; scanf("%d%d",&H,&W);
	rep(i,1,H) {
		rep(j,1,W) {
			char c = getchar();
			while (c != '#' && c != '.') c = getchar();
			if (c == '#') { if (!l[i]) l[i] = j; r[i] = j; a[i][j] = 1; } else a[i][j] = 0;
		}
		rep(j,l[i],r[i]) if (!a[i][j]) { printf("Impossible\n"); return 0; }
		if (i == 1) {
			if (l[i] > 1) { printf("Impossible\n"); return 0; }
		} else if (l[i] != r[i - 1]) { printf("Impossible\n"); return 0; }
		if (i == H && r[i] != W) { printf("Impossible\n"); return 0; }
	}
	printf("Possible\n");
	return 0;
}

Measured memory_bytes: 256
// abc054_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  int n, m;
  bool ans = false;
  cin >> n >> m;
  char a[n][n],b[m][m];
  rep(i, n) rep(j, n) cin >> a[i][j];
  rep(i, m) rep(j, m) cin >> b[i][j];

  for (int ny = 0; ny <= n - m; ++ny) {
    for (int nx = 0; nx <= n - m; ++nx) {
      bool match = true;
      for (int my = 0; my < m; ++my) {
        for (int mx = 0; mx < m; ++mx) {
          if(a[ny+my][nx+mx] != b[my][mx]) match = false;
        }
      }
      if(match) ans=true;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=list(map(int,input().split()))
import heapq
q=[]
for i in l:
  heapq.heappush(q,-i)
for i in range(m):
  num=heapq.heappop(q)
  if num%2==0:
    num=num//2
  else:
    num=num//2+1
  heapq.heappush(q,num)
sum=0
for i in range(n):
  sum+=-q[i]
print(sum)

Measured memory_bytes: 14224
//插入部分代码一致，多了搜索

#include <iostream>
#include<string>
using namespace std;
#define MAX  500000
#define NIL  -1
string judge[MAX];//储存yes/no
struct node
{
	int key;//键值
	struct node *parent, *left, *right;
};
struct node *head = NULL, *movepoint;
void includeConnectNode()//链接结点
{
	struct node *moveparent = NULL, *movehead;
	if (head == movepoint)//根
		return;

	else
	{
		movehead = head;
		while (movehead != NULL)
		{
			moveparent = movehead;
			if (movehead->key > movepoint->key) //左子树键值比父的小
				movehead = movehead->left;
			else //右子树键值比父大,这里要注意:left,right可以为NULL，即跳出循环的条件;
				movehead = movehead->right;
		}
		movepoint->parent = moveparent;//父节点
		if (movepoint->key < moveparent->key)
			moveparent->left = movepoint;
		else
			moveparent->right = movepoint;

	}



}
void includeCreatNode()//建立结点
{
	movepoint = new  node;
	movepoint->parent = NULL;
	movepoint->left = NULL;
	movepoint->right = NULL;
	if (head == NULL)
		head = movepoint;
	cin >> movepoint->key;
	includeConnectNode();
}
void includePrintInorderData(struct node *next)//中序打印;
{
	if (next == NULL)
		return;
	includePrintInorderData(next->left);

	cout << " " << next->key;

	includePrintInorderData(next->right);
}
void includePrintPreorderData(struct node *next)
{
	if (next == NULL)
		return;

	cout << " " << next->key;

	includePrintPreorderData(next->left);
	includePrintPreorderData(next->right);

}
node* includeSearchData(node *search, int key)//搜索
{
	if (search == NULL)
		return NULL;
	else
	{
		while (search != NULL && key != search->key)
		{
			if (search->key > key)
				search = search->left;
			else 
				search = search->right;
		}
	}
	return search;

}
int main()
{
	int total,searchnumber,count=0;
	node *search;
	string order;
	cin >> total;
	for (int i = 0; i < total; i++)
	{
		cin >> order;
		if ("insert" == order)
			includeCreatNode();
		else if ("find" == order)//搜索
		{
			cin >> searchnumber;
			search = includeSearchData(head, searchnumber);
		if (search == NULL)
				cout << "no" << endl;	//judge[count++] = "no";
			else
				cout << "yes" << endl;//judge[count++] = "yes";

		}
		else if ("print" == order)
		{
			/*if (count > 0)//打印judge
				for (int i = 0; i < count; i++)
					cout << judge[i] << endl;*/
			includePrintInorderData(head);
			cout << endl;
			includePrintPreorderData(head);
			cout << endl;
		}

	}
	if (head != NULL)
		delete head;

	return 0;
}


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

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

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

    for (int i=1; i<n; i++) {
        v[i] = (v[i-1]+v[i]) / 2;
    }
    cout << v[n-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VI u, v, w;
void push(int x, int y, int z){
    u.push_back(x);
    v.push_back(y);
    w.push_back(z);
}

int main() {
    int x;
    cin >> x;
    x--;
    int n = 20;

    REP(i,n-2){
        push(n-1-i, n-i, 0);
        push(n-1-i, n-i, 1<<i);
    }

    while (x >= 0){
        FORR(i,n-3,-1){
            int y = (1 << (i+1)) - 1;
            if (y > x) continue;
            push(1, n-1-i, x-y);
            x = x - y - 1;
            break;
        }
    }

    cout << n << " " << u.size() << endl;
    REP(i,u.size()){
        cout << u[i] << " " << v[i] << " " << w[i] << endl;
    }

    return 0;
}


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

using namespace std;

int n, a[12345], t[12345];

void init()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d", &t[i], &a[i]);
	}
	long long vote1 = 1, vote2 = 1;
	for (int i = 0; i < n; ++i)
	{
		long long can1 = (vote1  + t[i] - 1) / t[i];
		long long can2 = (vote2 + a[i] - 1) / a[i];
		long long res = max(can1, can2);
		vote1 = res * t[i];
		vote2 = res * a[i];
	}
	long long total = vote2 + vote1;
	printf("%lld\n", total);
	total = 0;
}
int main()
{
	init();

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    int N, T, A;
    scanf("%d %d %d",&N,&T,&A);
    int H[N];
    double min = 10000;
    int num = 0;
    for (int i = 0; i < N; i++){
        scanf("%d", &H[i]);
        if (min > fabs(A - (T - H[i] * 0.006))) {
            min = fabs(A - (T - H[i] * 0.006));
            num = i+1;
        }
    }
    printf("%d\n", num);
    return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    ll now = 100;
    int ans = 0;
    while (now < x) {
        ans++;
        now += now / 100LL;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn tansaku_fn(iti: usize, n: usize, kyori: &mut Vec<i32>, map: &Vec<Vec<bool>>, ans: &mut Vec<usize>) {
    let mut tansaku1: Vec<usize> = Vec::new();
    for j in 0..n {
        if map[iti][j] == true {
            tansaku1.push(j);
        }
    }
    let mut tansaku2: Vec<usize> = Vec::new();
    for j in tansaku1 {
        if kyori[j] > kyori[iti] + 1 {
            kyori[j] = kyori[iti] + 1;
            ans[j] = iti;
            tansaku2.push(j);
        }
    }
    for iti1 in tansaku2{
        tansaku_fn(iti1, n, kyori, map, ans);
    }
}
fn main() {
    let (a, b) = read_two::<i32>();
    println!("{}", a * b);
}

Measured memory_bytes: 2136
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int p; cin>>p;
    rep(hogehoge,p){
        vi v(10,0);rep(i,10)cin>>v[i];
        vb flag(11,false);flag[v[0]]=true;
        pii num=pii(v[0],INF);
        rep(i,10){
            if(i==0)continue;
            if(num.first<v[i]){flag[v[i]]=true; num.first=v[i];}
        }
        rep(i,10){
            if(flag[v[i]])continue;
            else if(num.second==INF){num.second=v[i];flag[v[i]]=true;}
            if(num.second<v[i]){flag[v[i]]=true; num.second=v[i];}
        }
        bool judge=true;
        rep(i,10)if(!flag[i+1])judge=false;
        if(judge)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3080
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int m = 0;
		int f = 0;
		int r = 0;
		
		int count = 0;
		ArrayList<String> e = new ArrayList<String>();
		
		while(true){
			int i = 0;
			m = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			
			if(m == -1 && f == -1 && r == -1){
					break;
			}else{
				if(m == -1 || f == -1){
					e.add("F");
				}else if(m + f >= 80){
					e.add("A");
				}else if(m + f >= 65 && m + f < 80){
					e.add("B");
				}else if(m + f >= 50 && m + f < 65){
					e.add("C");
				}else if(m + f >= 30 && m + f < 50){
					if(r >= 50){
						e.add("C");
					}else{
						e.add("D");
					}
				}else if(m + f < 30){
					e.add("F");
				}
			}
		}
		
		for(int j = 0; j < e.size(); j++){
			System.out.println(e.get(j));
		}
	}
}

Measured memory_bytes: 26372
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string str;
	
	cin >> str;
	
	if(str[0] == str[2])
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

#define MAX 200

int main(void) {
	while(1) {
		int Xof[MAX], Yof[MAX];
		int N, num, dist;
		const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
		int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
		
		Xof[0] = Yof[0] = 0;
		scanf("%d", &N);
		if(!N) break;
		for(int i = 1; i < N; i++) {
			scanf("%d %d", &num, &dist);
			Xof[i] = Xof[num] + dx[dist];  Yof[i] = Yof[num] + dy[dist];
			if(Xof[i] < xmin) xmin = Xof[i];
			if(Xof[i] > xmax) xmax = Xof[i];
			if(Yof[i] < ymin) ymin = Yof[i];
			if(Yof[i] > ymax) ymax = Yof[i];
		}
		printf("%d %d\n", xmax - xmin + 1, ymax - ymin + 1);
	}
	return 0;
}

Measured memory_bytes: 1188
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s=reader.readLine())!=null){
			String[] t=s.split(" ");
			int[] in=new int[2];
			for(int i=0;i<2;i++)
				in[i]=Integer.parseInt(t[i]);
			int a=in[0];
			int b=in[1];
			if(a<b){int tmp=a;a=b;b=tmp;}
			while(b!=0){
				int tmp=a%b;a=b;b=tmp;
			}
			System.out.println(a+" "+(long)in[0]*in[1]/a);
		}
	}
}

Measured memory_bytes: 15088
N=int(input())
data={}
for i in range(N):
    name=input()
    if data.get(name) == None:
        data[name]=0
    data[name] += 1
data = sorted(data.items(),key=lambda x:x[1])
if len(data) == 1:
    print(data[-1][0])
else:
    mx=data[-1][1]
    l=[]
    for i in range(N):
        if data[len(data)-i-1][1] == mx:
            l.append(data[len(data)-i-1][0])
        else:
            break
    l.sort()
    for i in l: print(i)

Measured memory_bytes: 43228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i1,n) for(int i=(int)(i1);i<(int)(n);i++)
#define ll long long
#define vi vector<int>

int main() {
  int n,k=0;
  cin>>n>>k;
  vi vec(n);
  rep(i,0,n){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  int sum=0;
  
  rep(i,0,k){
    sum+=vec.at(i);
  }
  cout<<sum;
}

Measured memory_bytes: 3620
s, t = [s.strip() for s in open(0)]

ans = 'UNRESTORABLE'
for i in range(len(s) - len(t), -1, -1):
    for j in range(len(t)):
        if s[i+j]!='?' and s[i+j]!=t[j]:
            break
    else:
        ans = s[:i] + t + s[i+len(t):]
        ans = ans.replace('?', 'a')
        break
print(ans)

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main()
{
	int i,N,L,sum = 0;
	bool p = false;

	cin >> N >> L;

	for (i = 1; i <= N ; i++)
	{
		sum += L + i - 1;
		if (L + i - 1 == 0) p = true;
	}
	i--;

	if (p) cout << sum << endl;
	else
	{
		if (L + i - 1 < 0) cout << sum - (L + i - 1) << endl;
		else cout << sum - L << endl;

	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)o.size())
#define run(x) for(int k=head[x];k;k=e[k].ne)
#define v e[k].t
#define all(a) o.begin(),o.end()
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<int,int> pa;
const int N=1e6+5;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il void judge(){
	freopen("dato.in","r",stdin);
	freopen("dato.out","w",stdout);
}int T[N],n,m;
ll f[N],fl[N],fr[N],sum[N],q[N],g[N],top;
db slope(int i,int j){return 1.0*(g[i]-g[j])/(i-j);}
void pop(int i){while(top>1&&slope(q[top],q[top-1])<i)top--;}
void push(int i){
	while(top>1&&slope(i,q[top])>slope(q[top],q[top-1]))top--;
	q[++top]=i;
}
#define now q[top]
void gao(ll*f){
	rep(i,1,n)sum[i]=sum[i-1]+T[i];
	q[top=1]=0;
	rep(i,1,n){
		pop(i);
		f[i]=max(f[i-1],g[now]-now*i+1ll*i*(i+1)/2-sum[i]);
		g[i]=f[i]+1ll*(i-1)*i/2+sum[i];
		push(i);
	}
}
#define mid (l+r>>1)
ll h[N];
void solve(int l,int r){
	if(l==r)return;
	top=0;
	rep(i,l,mid){
		g[i]=fl[i]+1ll*i*(i-1)/2+sum[i];
		push(i);
	}
	rep(i,mid+1,r){
		pop(i);
		h[i]=g[now]-now*i+1ll*i*(i+1)/2-sum[i]+fr[i+1];
	}
	repd(i,r-1,mid+1)gmax(h[i],h[i+1]);
	rep(i,mid+1,r)gmax(f[i],h[i]);
	solve(l,mid);solve(mid+1,r);
}
int main(){
	read(n);rep(i,1,n)read(T[i]),f[i]=-linf;
	gao(fl);
	reverse(T+1,T+1+n);
	gao(fr);
	reverse(T+1,T+1+n);reverse(fr+1,fr+1+n);
	rep(i,1,n)sum[i]=sum[i-1]+T[i];solve(0,n);
	reverse(T+1,T+1+n);reverse(f+1,f+1+n);reverse(fl+1,fl+1+n);reverse(fr+1,fr+1+n);swap(fl,fr);
	rep(i,1,n)sum[i]=sum[i-1]+T[i];solve(0,n);
	reverse(T+1,T+1+n);reverse(f+1,f+1+n);reverse(fl+1,fl+1+n);reverse(fr+1,fr+1+n);swap(fl,fr);
	read(m);rep(cas,1,m){
		int p,x;read(p,x);
		ll r1=fl[p-1]+fr[p+1];
		ll r2=T[p]+f[p]-x;
		printf("%lld\n",max(r1,r2));
	}
}

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

int main() {
    double r, l;
    vector<int> sum_r(4), sum_l(4);
    while (cin >> l >> r) {
        
        auto add = [](double x, vector<int> &vec) {
            if (x >= 1.1) vec[0]++;
            else if (x >= 0.6) vec[1]++;
            else if (x >= 0.2) vec[2]++;
            else vec[3]++;
        };

        add(l, sum_l);
        add(r, sum_r);

    }

    for (int i = 0; i < 4; i++) {
        cout << sum_l[i] << " " << sum_r[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <vector>

using namespace std;

bool check(const vector<int>& w, int k, int P) {
  int sum = 0;
  int count = 1;
  for (int i = 0; i < w.size(); ++i) {
    if (w[i] > P) {
      return false;
    }
    sum += w[i];
    if (sum > P) {
      ++count;
      if (count > k) {
        return false;
      }
      sum = w[i];
    }
  }
  return true;
}

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

  int n, k;
  vector<int> w;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int w_;
    cin >> w_;
    w.push_back(w_);
  }

  int l = 0, r = 100000 * 10000;
  while (l < r) {
    int m = (l + r) / 2;
    if (check(w, k, m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  cout << l << endl;
}



Measured memory_bytes: 3436
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,a,b,c,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>a>>b>>c>>k;
        ll x=0;
        while(b<=a)
        {
            b *=2;
            x++;
        }
        while(c<=b)
        {
            c *= 2;
            x++;
        }
        if(x>k)
            cout<<"No\n";
        else
            cout<<"Yes\n";
    }
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] > key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; 
	int right = (int)meguru.size();
	key = key - 1;
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	return left;
}
vector<long long int >megurulow;
bool SisOK(int index, int key) {
	if (megurulow[index] > key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int Sbinary_search(int key) {
	int left = -1;
	int right = (int)megurulow.size();
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (SisOK(mid, key)) right = mid;
		else left = mid;
	}
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
double PI = 3.141592653589793238;
vector<vector<int>>G(100030);
int seen[1000][1000] = {};
char s[1000][1000] = {};
int main() {
	int  k;
	cin >> k;
	string ans = "";
	for (int i = 0; i < k; i++) {
		ans = ans + "ACL";
	}
	cout << ans;
}
	

Measured memory_bytes: 5392
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s;
 string l;
 getline(cin,s);
 getline(cin,l);
int c=0;
 for(int i=0;i<s.size();i++){
 	if(s[i] != l[i]){
 		c++;
 	}
 }
 cout<<c<<endl;
 return 0;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string s; cin >> s;
  vector<char> c(s.size(), 'x');
  string ans(c.begin(), c.end());
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
n = int(input())
p = [int(s) - 1 for s in input().split()]

a = [40000 * (i + 1) for i in range(n)]
b = list(reversed(a))
for i in range(n):
    a[p[i]] += i

print(' '.join(map(str, a)))
print(' '.join(map(str, b)))

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

int n, k;

bool maxLoadingCapa(vector<int> w, int p){
    /*
    input: vector<int> w 荷物の重さ
           int p 各トラックの最大積載量
    output: wをk台のトラックで運べるかどうか

    */
    int weight = 0;
    int k_cnt = 1; //最大積載量がpのときにwを運ぶのに必要となるトラックの台数

    for(int i = 0; i < n; i++){
        if(w.at(i) > p){
            return false;
        }

        int tmp = weight + w.at(i);

        if(tmp > p){
            k_cnt++;
            weight = w.at(i);
            if(k_cnt > k){
                return false;
            }
        }else{
            weight = tmp;
        }
    }

    // cout << k_cnt << " trucks are need! (p = " << p << ")" << endl;
    return true;
}
int main(){
    cin >> n >> k;
    vector<int> w(n);

    int pMax = 0;
    for(int i = 0; i < n; i++){
        cin >> w.at(i);
        pMax += w.at(i);
    }


    int right = pMax;
    int left = 0;

    while(left < right){
        int mid = (right + left) / 2;
        int canLoad = maxLoadingCapa(w, mid);
        // cout << left << " " << right << " " << mid << " " << canLoad << endl;
        if(canLoad == 0){
            left = mid + 1;
        }else if(canLoad == 1){
            right = mid;
        }
    }
    cout << left << endl;

}


Measured memory_bytes: 3672
import math
import fractions
import collections
import itertools
import pprint
from collections import deque
N,K=map(int,input().split())
A=list(map(int,input().split()))
plist=[]
mlist=[]
ans=1
p=10**9+7
for i in range(N):
    if A[i]>=0:
        plist.append(A[i])
    else:
        mlist.append(A[i])
if len(plist)==0:
    if K%2==1:
        A.sort(reverse=True)
    else:
        A.sort()
    for i in range(K):
        ans=(ans*A[i])%p
    print(ans%p)
elif len(plist)==1:
    #print(plist,mlist)
    mlist.sort()
    if K%2==1:
        ans=plist[0]
    for i in range(K-1):
        ans=(ans*mlist[i])%p
    print(ans%p)
else:
    ans=1
    plist.sort(reverse=True)
    mlist.sort()
    pmap=deque()
    mmap=deque()
    if K%2==1:
        ans=plist[0]%p
        plist.pop(0)
        K=K-1
    #print(plist,mlist)
    for i in range(0,len(plist)-1,2):
        pmap.append(plist[i]*plist[i+1])
    if len(plist)>0:
        pres=plist[len(plist)-1]
    if len(mlist)>0:
        mres=mlist[len(mlist)-1]
    for i in range(0,len(mlist)-1,2):
        mmap.append(mlist[i]*mlist[i+1])
    #print(K)
    mapnum=K//2
    #print(mapnum)
    #print(pmap,mmap,ans)
    for i in range(mapnum):
        if (len(pmap)>0)and(len(mmap)>0):
            pl=pmap.popleft()
            mi=mmap.popleft()
            if pl>mi:
                ans=(ans*pl)%p
                mmap.appendleft(mi)
            else:
                ans=(ans*mi)%p
                pmap.appendleft(pl)
        elif (len(pmap)==0)and(len(mmap)>0):
            mi=mmap.popleft()
            ans = (ans *mi) % p
        elif (len(mmap)==0)and(len(pmap)>0):
            pl=pmap.popleft()
            ans = (ans *pl) % p
        else:
            ans=(ans*pres*mres)%p
    print(ans)



Measured memory_bytes: 109636
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int A, B;
    std::cin >> A >> B;

    int count = 0;
    for (int i = A; i <= B; i++) {
        std::string s = std::to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) {
            count++;
        }
    }

    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 256
N,Y = (int(i) for i in input().split())
a,b,c = -1,-1,-1
for n_10000 in range(N+1):
    for n_5000 in range(N-n_10000+1):
        n_1000 = N-n_10000-n_5000
        if 10000*n_10000+5000*n_5000 +1000*n_1000 == Y:
            a,b,c = n_10000,n_5000,n_1000
print(a,b,c)



Measured memory_bytes: 3060
/*
ID:njbxgub1
PROG:palsquare
LANG:C++
*/
//******************
//*   I<3   C++    *
//*  I WANT ANY AC *
//* I LOVE PROGRAM!*
//*IT'S INTERESTING*
//* I LOVE PROGRAM!*
//*  IN CONTESTS   *
//*   GET SCORE    *
//*    AC CODE     *
//*     LET'S      *
//*      GO        *
//*  Written by:   *
//*    gbc		   *
//******************/
#include <bits/stdc++.h>
using namespace std;

int n;
int a[3][105];
bool vis[3][105];
int max1=0,s=0;
int dx[5]={0,1,0},dy[5]={0,0,1};

void dfs(int xi,int xj)
{
	if(xi==2 && xj==n)
	{
		if(s+a[xi][xj]>=max1) max1=s+a[xi][xj];
		return;
	}
	vis[xi][xj]=1;
	s+=a[xi][xj];
	for(int i=1;i<=2;i++)
	{
		int xx=xi+dx[i],yy=xj+dy[i];
		if(!vis[xx][yy]&&xx<=2&&yy<=n) dfs(xx,yy);
	}
	s-=a[xi][xj];
	vis[xi][xj]=0;
}
int main()
{
//	freopen("x.in","r",stdin);
//	freopen("x.out","w",stdout);
	cin>>n;
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];	
		}
	}
	dfs(1,1);
	cout<<max1<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int H = int.Parse(str[0]);
        int W = int.Parse(str[1]);
        bool[,] b = new bool[H,W];
        for(int i=0;i<H;i++){
            str = Console.ReadLine().Split(' ');
            for(int j=0;j<W;j++){
                b[i,j] = str[j] == "1";
            }
        }
        int[,] L = new int[H,W];
        for(int i=0;i<H;i++){
            int p = 0;
            for(int j=0;j<W;j++){
                if(b[i,j]){
                    p = j+1;
                }
                L[i,j] = p;
            }
        }
        int[,] U = new int[H,W];
        for(int i=0;i<W;i++){
            int p = 0;
            for(int j=0;j<H;j++){
                if(b[j,i]){
                    p = j+1;
                }
                U[j,i] = p;
            }
        }
        int[,] DP = new int[H,W];
        int max = 0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(!b[i,j]){
                    if(i == 0 || j == 0){
                        DP[i,j] = 1;
                    }
                    else{
                        int min = DP[i-1,j-1] + 1;
                        min = Math.Min(min,j-L[i,j]+1);
                        min = Math.Min(min,i-U[i,j]+1);
                        DP[i,j] = min;
                    }
                    max = Math.Max(max,DP[i,j]);
                }
            }
        }
        sb.Append(max*max+"\n");
    }
}

Measured memory_bytes: 35748
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; i++) cin >> x[i];
  lint ans = INF;
  for(int i = 0; i <= 2000; i++) {
    lint cost = 0;
    for(int j = 0; j < n; j++) cost = max(cost, (lint)abs(i - x[j]));
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3112
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define POPCNTI(a) __builtin_popcount(a)
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>


#include <bits/stdc++.h>
using namespace  __gnu_pbds; 
using namespace std;

 
// #ifndef _LOCAL_DEFINE
// inline int getchar_unlocked(){return _getchar_nolock();}
// inline void putchar_unlocked(char c) {_putchar_nolock(c);}
// #endif
 
typedef long long ll;  
typedef pair<int,int> pr; 
 
const ll MOD = 1e9 + 7,OOl=LLONG_MAX;
const int N = 1e6+1, M = 1e6+1, OO = INT_MAX,OOmem = 0x4f4f4f4f;
 
inline void WRITE_CHAR(char c)  {putchar_unlocked(c);}
 
template<typename T> 
inline bool READn (T &result) {
  int minus = 1;
  char ch;
  result=0;
  ch = (char) getchar_unlocked();
  if(ch!='-') while (!isdigit(ch) && ch!=EOF) ch= (char) getchar_unlocked(), minus = (ch == '-'? -1 : minus);
 
  if(ch==EOF) return false;
  while (isdigit(ch))  result = result*10 + (int) (ch - '0'),ch = (char) getchar_unlocked();
  
  result *= minus;
  return ch != '\n';
}
template<typename T>
inline void WRITEn(T x) {
  if (x < 0) {putchar_unlocked('-'); x = -x; }
  char writeBuffer[20], *writePtr = writeBuffer;
  do {
    *writePtr++ = (char)('0' + x % 10);
    x /= 10;
  }
  while (x);
  do  { putchar_unlocked(*--writePtr); }
  while (writePtr > writeBuffer);
}
inline bool Read_CHAR(char &c)
{
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  c = READ_CHARACTER;
  return true;
} 
inline bool READ_CHAR_ARRAY(char (&x)[N]) {
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  char *ptr = &x[0];
  while ((READ_CHARACTER != '\n' && READ_CHARACTER != '\t' && READ_CHARACTER != ' ' && READ_CHARACTER != EOF)) *ptr++ = READ_CHARACTER, READ_CHARACTER = (char)getchar_unlocked();
  *ptr = '\0';
  return true;
}
inline void WRITE_CHAR_ARRAY(const char *x) {
  while(*x != '\0')
    putchar_unlocked(*x++);
}
char s[N],t[N];
int dp[3003][3003];
int main()
{
  
  READ_CHAR_ARRAY(s),READ_CHAR_ARRAY(t);
  int n=strlen(s),m=strlen(t);
  dp[0][0]=0;
  
  int i=1,j=1;
  for(i=1;i<=n;++i)
    for(j=1;j<=m;++j)
    {
      dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      if(s[i-1]==t[j-1]) dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1);
    }

  vector<char> ans(dp[n][m]+1);
  int k=0;
  while(i && j)
  {
    if(s[i-1]==t[j-1])
    {
      ans[k++] = s[i-1];
      i--,j--;
    }
    else if(dp[i-1][j]>dp[i][j-1]) i--;
    else j--;     
  }
  while(--k) WRITE_CHAR(ans[k]);
  return 0;
}




Measured memory_bytes: 37120
n, m = map(int, input().split())
point = [0] * m
ans = 0
for i in range(n) :
    data = list(map(int, input().split()))
    for j in range(1,data[0]+1) :
        point[data[j]-1] += 1
for k in range(m) :
    if point[k] == n :
        ans += 1
print(ans)


Measured memory_bytes: 9116
fun main(args: Array<String>) {
    val (N, T) = readInputLine().split(" ").map{it.toInt()}
    
    var ans = Int.MAX_VALUE
    
    for (i in 1..N) {
        val (c, t) = readInputLine().split(" ").map{it.toInt()}
        
        if (t <= T && c <= ans) {
            ans = c
        }
    }
    
    if (ans == Int.MAX_VALUE) {
        println("TLE")
    } else {
        println(ans)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main(){
  int64_t n,m,v,p;
  cin >> n >> m >> v >> p;
  vector<int64_t> a(n);
  rep(i,n) cin >> a.at(i);
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int64_t criteria = a.at(p-1);
  int64_t sabun = 0;
  int64_t dame = 0;
  int64_t priorproblem = -1;
  vector<int64_t> gabage(n);
  rep(i,n){
    if(a.at(i) > criteria){
      priorproblem = i;
    }else{
      if(i != 0){
        gabage.at(i) = gabage.at(i-1)+a.at(i);
      }else{
        gabage.at(0) = a.at(0);
      }
    }
  }
  
  for(int64_t i=0;i < n;i++){
    int64_t hoge = priorproblem+1+(n-i);//ゴミ捨て場の数
    int64_t gabagepoint = (hoge)*m;//捨てれるごみ
    if(a.at(i) < criteria){
      if(a.at(i) + m < criteria){
          dame++;
      }else{
        int64_t honu = (i-priorproblem-1);
        if(gabage.at(i)-a.at(i)+(m*v)-gabagepoint
           > (a.at(i) + m)*honu){
          dame++;
        }
      }
    }
  }
  cout << n - dame << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int n,k;
  cin>>n>>k;
  int sum=0;
  for(int i=0;i<n;i++){
	int p;
    cin>>p;
    int min;
    if(p<(k-p)){
      min=p;
    }else{
      min=k-p;
    }
    sum=sum+2*min;
  }
  cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  double a[50], A, M=0;
  int n, i, j;

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

//配列を小さい順に並び変え。大きいほうから順に確定させていってる。
  for (i = 0; i < n-1; i++) {
    for (j = 0; j < n-1-i; j++) {
      if (a[j] > a[j+1]) {
        A = a[j];
        a[j] = a[j+1];
        a[j+1] = A;
      }
    }
  }

  M = a[0];
  for (i = 0; i < n-1; i++) {
    M = (M + a[i+1])/2 ;
  }

  printf("%lf\n", M);

  return 0;
}


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

int main() {

	int n;
	cin >> n;
	set<string> t;

	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		t.insert(s);
	}

	cout << t.size() << '\n';

	return 0;
}


Measured memory_bytes: 19260
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

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

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll Q;
    cin >> Q;
    vector<bool> is_prime(100001, true);
	/* 配列を初期化 */
	is_prime[ 1 ] = false;


	/* エラトステネスのふるい */
	for(ll i = 2; i*i < 100001; i++)
		if(is_prime[ i ])
			for(ll j = i*2; j < 100001; j += i)
				is_prime[ j ] = false;	
    
    vector<ll> sum(100001, 0);
    for(ll i = 3; i < 100001; i += 2) {
        if (is_prime[i] && is_prime[(i+1) / 2]) {
            sum[i] = 1; 
        }
    }
    rep(i, 100000) sum[i+1] += sum[i]; 
    rep(i, Q) {
        ll l, r;
        cin >> l >> r;
        if (sum[l-1] == sum[l]-1) {
            print(sum[r] - sum[l] + 1);
        } else {
            print(sum[r] - sum[l]);
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> t3;
typedef map<int, int> mi;
#define fi first
#define se second
#define vt vector
#define be begin()
#define ed end()
#define sz size()
#define cl clear()
#define pb push_back
#define eb emplace_back
#define is insert
#define all(x) x.begin(), x.end()
#define lb(v, x) lower_bound(v.begin(), v.end(), x)
#define lbi(v, x) (lb(v, x) - v.begin())
#define tp(t, x, y) t x, y; tie(x, y)
#define tp3(t, x, y, z) t x, y, z; tie(x, y, z)
#define mp make_pair
#define mt make_tuple
#define co const
#define fc(x) for(int x = 1, _end = ri(); x <= _end; x++)
void uni(vi &v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }

db rd() { db x; cin >> x; return x; }
ll ri() { ll x; cin >> x; return x; }
string rs() { string s; cin >> s; return s; }
pi rpi() { pi x; cin >> x.fi >> x.se; return x; }
vi rvi(int n, int f = 0) { vi v(n + f); for (int i = f; i < v.size(); i++) cin >> v[i]; return v; }
void pr() {}; template <class T, class ...U> void pr(T x, U ...y) { cout << x << ' ', pr(y...); }
void prl() { cout << '\n'; }; template <class T, class ...U> void prl(T x, U ...y) { cout << x << ' ', prl(y...); }
void pr(const vi &v, int f = 0) { for (int i = f; i < v.size(); i++) cout << v[i] << ' '; }
void prl(const vi &v, int f = 0) { pr(v, f); cout << '\n'; }
void kk() { cerr << endl; }; template <class T, class ...U> void kk(T x, U ...y) { cerr << x << ' ', prl(y...); }

#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (l); i >= (r); --i)

const int N = 3e5 + 5, M = 1e9 + 7;
int main() {
  int n = ri();
  ll lst = 0;
  vt<ll> a;
  rep(i, 0, n) {
    int flg = 1;
    if (i) flg = rs() == "+";
    int x = ri();
    if (flg) lst += x;
    else a.pb(lst), a.pb(-x), lst = 0;
  }
  if (lst) a.pb(lst);
  vt<ll> b(a.sz + 1);
  rep(i, 0, a.sz) {
    b[i+1] = b[i] + a[i];
  }
  ll ans = b[a.sz], sum = abs(a.back());
  per(i, a.sz - 1, 1) {
    if (a[i-1] > 0) sum += a[i-1];
    else {
      if (a[i] > 0) ans = max(ans, sum - 2 * a[i] + a[i-1] + b[i-1]);
      else ans = max(ans, sum + a[i-1] + b[i-1]);
      sum -= a[i-1];
    }
  }
  prl(ans);
}


Measured memory_bytes: 6356
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */
class Counter<T> extends HashMap<T,Integer>{
    public Counter(){
        super();
    }
    public Integer get(Object elm){
        return getOrDefault(elm,0);
    }
    public void add(T elm, int amount){
        if(!this.containsKey(elm)) put(elm, amount);
        else replace(elm, get(elm)+amount);
    }
    public void addOne(T elm){
        add(elm, 1);
    }
    public void remove(T elm, int amount){
        replace(elm, Math.max(get(elm)-amount, 0));
    }
    public void removeOne(T elm){
        remove(elm, 1);
    }
}

public class Main {

    public static Counter<Long> fact(long N){
        Counter<Long> divisors = new Counter<>();
        long d = 2;
        while(d*d <= N){
            if(N%d==0) {
                divisors.addOne(d);
                N /= d;
            }
            else d++;
        }
        if(N>1) divisors.addOne(N);
        return divisors;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long P = sc.nextLong();

        Counter<Long> divisors = fact(P);

        long ans = 1;
        for(long d: divisors.keySet()){
            int a = divisors.get(d);
            for(long i=0; i<a/N; i++) ans *= d;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636