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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

int solve(vector<vector<int>> a, int s) {
    int R = a.size(), C = a[0].size();
    rep(i, R) {
        if ((s >> i) & 1) {
            rep(j, C) a[i][j] ^= 1;
        }
    }
    int ret = 0;
    rep(j, C) {
        int n = 0;
        rep(i, R) {
            if (a[i][j]) n++;
        }
        ret += max(n, R - n);
    }
    return ret;
}

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

    int R, C;
    while (cin >> R >> C, R) {
        vector<vector<int>> a(R, vector<int>(C));
        rep(i, R) rep(j, C) cin >> a[i][j];
        int ans = 0;
        rep(s, 1 << R) {
            ans = max(ans, solve(a, s));
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 4508
use std::io::*;
use std::str::FromStr;

fn main(){
    let r = read::<u32>();
    println!("{}", if r < 1200 {"ABC"} else if r < 2800 {"ARC"} else {"AGC"});
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  ll a, b;
  cin >> a >> b;
  ll k;
  cin >> k;
  for (int i = a; i <= min(b, a + k - 1); i++)
  {
    cout << i << endl;
  }
  for (int i = max(b - k + 1, a + k); i <= b; i++)
  {
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n,c = gets.split.map(&:to_i)
a = Array.new(10**5+2, 0)

prev = -1
b = n.times.map{gets.split.map(&:to_i)}.sort{|a, b| x = a[2]<=>b[2]; x!=0? x:(a[0]<=>b[0])}

#p b
n.times{|i|
  s,t,ch = b[i]
  #p [s,b[i-1][1]]
  s -= 1 if !(prev == ch && (i>0 && s==b[i-1][1]))
  a[s] += 1
  a[t] -= 1
  prev = ch
}

max = 0
(a.size-1).times{|i|
  a[i+1] += a[i]
  max = a[i+1] if max < a[i+1]
}
#p a
p max

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

int main() {
	int M[28],A[31];
	for(int i=0;i<28;i++){
		cin >> M[i];
	}
	for(int i=0;i<28;i++){
		A[M[i]]=M[i];
	}
	for(int i=1;i<31;i++){
		if(A[i]==i){
			
		}
		else{
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

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

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	string a, b;
	cin >> a >> b;
	int n = stoi(a + b);
	cout << (floor(sqrt(n)) == ceil(sqrt(n)) ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int C[2005], x, y, n, i, j;
int main()
{
    cin >> n >> x >> y;
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            C[min(abs(j-i),abs(x-i)+1+abs(y-j))]++;
        }
    }
    for(i=1;i<n;i++)
        cout << C[i] << endl;
    return 0;
}


Measured memory_bytes: 3536
N = int(input())
A = list(map(int, input().split()))

p=1

for k in range(N):
    if A[k] == 0:
        p = 0
        break

if p == 0:
    print(p)    
else:   
    for i in range(N):
        p *= A[i]
        if p > 10 ** 18:
            p = -1
            break

    print(p)


Measured memory_bytes: 21556
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, U[210], chk[210];
char res[210];

int Query(vector<int> &A) {
	sort(A.begin(), A.end());
	printf("? ");
	for (auto &t : A)printf("%d ", t);
	puts("");
	fflush(stdout);
	char p[10];
	scanf("%s", p);
	if (p[0] == 'R')return 1;
	return 2;
}
int Query2(int a) {
	vector<int>T;
	for (int i = a; i < a + n; i++)T.push_back(i);
	return Query(T);
}
int main() {
	int i, j;
	scanf("%d", &n);
	U[1] = Query2(1);
	U[n + 1] = 3 - U[1];
	int b = 1, e = n + 1;
	while (b+1 < e) {
		int m = (b + e) >> 1;
		U[m] = Query2(m);
		if (U[b] == U[m])b = m;
		else e = m;
	}
	for (i = b + 1; i < b + n; i++)chk[i] = 1;
	for (i = 1; i <= n+n; i++)if (i<b || i>b + n)chk[i] = 2;
	for (i = 1; i <= n+n; i++) {
		int ck = 0;
		if (b <= i && i <= b + n) ck = 2;
		else ck = 1;
		vector<int>T;
		for (j = 1; j <= n+n; j++)if (chk[j] == ck)T.push_back(j);
		T.push_back(i);
		if (Query(T) == 1)res[i] = 'R';
		else res[i] = 'B';
	}
	printf("! %s\n", res + 1);
	fflush(stdout);
}

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

typedef long long int ll;
#define f(a, b) for(auto i = a;i < b;i++)

bool sortbysec(const pair<ll, ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 
void solve()
{
	return ;
}

int main()
{
	double  sum = 0;
	ll n , m;
	cin >> n >> m;

	vector < double > vect;

	f(0, n)
	{
		double a;
		cin >> a;
		sum += a;
		vect.push_back(a);
	} 

	ll cnt = 0;
	double x = (sum/4.0)/m;
	f(0, n)
	{
		if(vect[i] >= x)
			cnt++;
	}

	if(cnt >= m)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
import re
S = input()
T = input()

S = S.replace('?', '.')
t_len = len(T)
for i in reversed(range(len(S) - t_len + 1)):
    if re.match(S[i:i + t_len], T) is not None:
        S = S[:i] + T + S[i + t_len:]
        print(S.replace('.', 'a'))
        break
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3188
S = input()
N = len(S)
mod = 10**9+7
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    if S[i] == "?":
        for d in range(10):
            for k in range(13):
                dp[i+1][(k*10+d)%13] = (dp[i+1][(k*10+d)%13]+dp[i][k])%mod
    else:
        d = int(S[i])
        for k in range(13):
            dp[i+1][(k*10+d)%13] = (dp[i+1][(k*10+d)%13]+dp[i][k])%mod
print(dp[N][5]%mod)

Measured memory_bytes: 61916
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX_N = 1000;

int main(){
	int n;
	// p[id] := プログラマ id がログインした時刻
	int p[MAX_N+1];
	// time[id] := プログラマ id が女神と一緒にいた時間の和.
	int time[MAX_N+1];
	
	while( scanf("%d", &n) , n ){
		
		// 初期化
		for(int i=0 ; i <= n ; i++ ){
			p[i] = -1;
			time[i] = 0;
		}
		
		for(int i=0 ; i < n ; i++ ){
			int month, day, h, m, id;
			char log;
			scanf("%d/%d %d:%d %c %d", &month, &day, &h, &m, &log, &id);
			
			int t = h * 60 + m;
			if( id > 0 && log == 'I' ){
				p[id] = t;
			}else if( id > 0 && log == 'O' ){
				if( p[0] != -1 ){
					time[id] += t - p[id];
				}
				p[id] = -1;
			}else if( id == 0 && log == 'I' ){
				p[0] = t;
				for(int i=1 ; i <= n ; i++ ){
					if( p[i] != -1 ){
						p[i] = t;
					}
				}
			}else if( id == 0 && log == 'O' ){
				for(int i=1 ; i <= n ; i++ ){
					if( p[i] != -1 ){
						time[i] += t - p[i];
					}
				}
				p[0] = -1;
			}
		}
		
		int ans = time[1];
		for(int i=1 ; i <= n ; i++ ){
			ans = max( ans , time[i] );
		}
		printf("%d\n", ans);
	}
}

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

int main() {
    string s;
    cin >> s;
    int keta = s.size();
    int n = atoi(s.c_str());
    int ans = 0;
    for(int i=0; i<keta/2; i++){
        ans += 9*pow(10, 2*i);
    }
    if(keta%2==1){
        ans += n-pow(10, keta-1)+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#coding:utf-8
s = input()
l = len(s)

if len(s) % 2 != 0:
    print('No')
else:
    for i in range(0, l, 2):
        #print(s[i:i+2])
        if s[i:i+2] != 'hi':
            print('No')
            exit()
    print('Yes')


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

int main()
{
    string s; cin >> s;
    string ans;

    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0' or s[i] == '1') ans += s[i];
        if(s[i] == 'B') ans.pop_back();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#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
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
const double pi=3.141592653589793238;
int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,b*c,a*d,b*d}) << endl;
}



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

pair<string,pair<ll,ll>>p[214514];

int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i].first>>p[i].second.first;
		p[i].second.first*=-1;
		p[i].second.second=i+1;
	}
	sort(p,p+n);
	for(int i=0;i<n;i++)cout<<p[i].second.second<<endl;
	return 0;
}


Measured memory_bytes: 5248
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
vector<int> vertexs[300000];
long long pre[300000];
long long ans[300000];
long long go(long long now, long long back) {
	if (back != -1) {
		ans[now] = ans[back] + pre[now];
	}
	else {
		ans[now] = pre[now];
	}
	REP(q, vertexs[now].size()) {
		if (vertexs[now][q] != back) {
			go(vertexs[now][q], now);
		}
	}
	return 0;
}
int main() {
	int n;
	cin >> n;
	int query;
	cin >> query;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	REP(i, query) {
		int a, b;
		cin >> a >> b;
		pre[a] += b;
	}
	go(1,-1);
	REP(i, n) {
		cout << ans[i + 1] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 28928
import bisect
primes = [0,0] + [1]*49999
for i in range(2, 224):
    if primes[i]:
        for j in range(i*i, 50001, i):
            primes[j] = 0

values = [k for k, b in enumerate(primes) if b]
while True:
    n = int(input())
    if n == 0:
        break
    end = bisect.bisect_right(values, n//2)
    print(sum(1 for i in values[:end] if primes[n-i]))

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

using namespace std;

using int64 = long long;

int main() {
  int N, A[100005];

  cin >> N;
  for(int i = 1; i <= N; i++) {
    cin >> A[i];
  }

  int sum[100005] = {};
  for(int i = 1; i <= N + 1; i++) {
    sum[i] += sum[i - 1];
    sum[i] += abs(A[i] - A[i - 1]);
  }

  for(int i = 1; i <= N; i++) {
    int base = sum[N + 1];
    base -= abs(A[i] - A[i - 1]);
    base -= abs(A[i + 1] - A[i]);
    cout << base + abs(A[i - 1] - A[i + 1]) << endl;
  }
}

Measured memory_bytes: 2048
w = STDIN.gets.split[0]
ans = 0
while true do
  s = STDIN.gets
  break if(s.split[0] == "END_OF_TEXT")
  ar = s.split
  ar.length.times {|i|
    ans += 1 if 0==w.casecmp(ar[i])
  }
end
printf("%d\n",ans)

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

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

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

LL N;
V<LL> a;
V<LL> s;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> N;
    REP(i,N) {
        LL x; cin >> x;
        a.push_back(x);
    }
    std::sort(ALL(a));

    LL ans = N;
    LL cnt = 1;
    s.push_back(a[0]);
    FOR(i, 1, N) {
        if(2*s[i-1] < a[i]) {
            ans -= cnt; cnt = 0;
        }
        s.push_back(s[i-1] + a[i]);
        cnt++;
    }
    cout << ans << "\n";
}

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

int main() {
  int N, A, B;
  cin >> N;
  
  if (N == 1) {
     cout << "Hello World" << endl;
  }
  else { 
    cin >> A >> B;
    cout << A+B << endl;
  }
  
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    S = list(input())
    min_c = n
    count_e = S.count('E')
    count_w = 0

    for s in S:
        if s == 'E':
            count_e -= 1
        min_c = min(min_c, count_e + count_w)
        if s == 'W':
            count_w += 1

    print(min_c)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 6048
program prob5
    implicit none
    integer :: n, ans
    integer, allocatable :: h(:)
    read(*,*) n
    allocate(h(n))
    read(*,*) h

    ans = 0
    call solve(1, n)
    write(*,*) ans

    deallocate(h)

    stop
contains
recursive subroutine solve(left, right)
    implicit none
    integer :: i, mi
    integer :: left, right
    if(left == right) then
        ans = ans + h(left)
        return
    end if

    mi = minval(h(left:right))
    ans = ans + mi
    do i = left, right
        h(i) = h(i) - mi
    end do


    do i = left, right
        if(h(i) == 0) then
            if(i /= left) then
                call solve(left, i-1)
            end if
            if(i /= right) then
                call solve(i+1, right)
            end if
            return
        end if
    end do

    
    return
end subroutine solve

end program prob5

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	rep(i, n-2) {
		if (s[i] == 'A'&&s[i + 1] == 'B'&&s[i + 2] == 'C')ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))
if x not in p:
    print(x)
    exit()

small = x - 1
large = x + 1
while True:
    if small not in p:
        print(small)
        break
    elif large not in p:
        print(large)
        break
    else:
        small -= 1
        large += 1


Measured memory_bytes: 9108
#include <cstdio>
#include <cstring>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <limits.h>
#include <vector>
#include <set>
#include <stack>
#include <queue>

using namespace std;                

#define rep(i,a,b) for(int i = a; i < b; i++)
#define mp make_pair
#define pb push_back

typedef long long lld;
typedef long double llf;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(void){
    
    int N,ans=1;
    bool check;
    int inn[25];
    cin>>N;
    rep(i,1,N+1) cin>>inn[i];
    
    rep(i,2,N+1){
        check = true;
        rep(j,1,i){
            if(inn[j]>inn[i]){
                check = false;
                break;
            }   
        }
        if(check) ans++;
    }
    cout<<ans;
    return 0;	
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	for(int& x : a)
		cin >> x;
	for(int& x : b)
		cin >> x;
	for(int i = 1; i < n; ++ i)
	{
		a[i] += a[i - 1];
	}
	
	for(int i = 1; i < m; ++ i)
	{
		b[i] += b[i - 1];
	}
	b.push_back(inf);
	debug(a, b);
	int cnt = 0;
	int ind = upper_bound(all(b), k) - b.begin();
	cnt = ind;
	for(int i = 0; i < n; ++ i)
	{
		if(a[i] > k) continue;
		int lft = k - a[i];
		int ind = upper_bound(all(b), lft) - b.begin();
		-- ind;
		debug(i, lft, ind, b[ind]);
		cnt = max(cnt, i + ind + 2);
	}
	cout << cnt << '\n';
	
	return 0;
}






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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int a[3];
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==a[1])cout<<a[2]<<newl;
    else cout<<a[0]<<newl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        Tuple<char, int>[] cards = new Tuple<char, int>[n];
        for (int i = 0; i < n; i++)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            cards[i] = new Tuple<char, int>(inputs[0][0], int.Parse(inputs[1]));
        }
        Tuple<char, int>[] origin = new Tuple<char, int>[n];
        cards.CopyTo(origin, 0);
        QuickSort(ref cards, 0, cards.Length - 1);
        Console.WriteLine(IsStable(cards, origin) ? "Stable" : "Not stable");
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(cards[i].ToString());
        }
    }

    static void QuickSort(ref Tuple<char, int>[] A, int p, int r){
        if(p < r){
            int q = Partition(ref A, p, r);
            QuickSort(ref A, p, q - 1);
            QuickSort(ref A, q + 1, r);
        }
    }

    static int Partition(ref Tuple<char, int>[] A, int p, int r){
        int x = A[r].Item2;
        int i = p - 1;
        for (int j = p; j < r; j++)
        {
            if(A[j].Item2 <= x){
                i++;
                Swap(ref A, i, j);
            }
        }
        Swap(ref A, i + 1, r);
        return i + 1;
    }

    static void Swap(ref Tuple<char, int>[] A, int i, int j){
        try{
            Tuple<char, int> tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
        catch(IndexOutOfRangeException ex){
            Console.Error.WriteLine(ex.Message);
        }
    }

    static bool IsStable(Tuple<char, int>[] A, Tuple<char, int>[] B){
        if(A.Length != B.Length) return false;
        Tuple<char, int>[] stableA = B.OrderBy(elem => elem.Item2).ToArray();
        for (int i = 0; i < A.Length; i++)
        {
            if(A[i] != stableA[i]) return false;
        }
        return true;
    }
}

class Tuple<T, U>{
    public T Item1 {get; set;}
    public U Item2 {get; set;}

    public Tuple(T item1, U item2){
        this.Item1 = item1;
        this.Item2 = item2;
    }

    public override string ToString(){
        return string.Format("{0} {1}", this.Item1, this.Item2);
    }
}

Measured memory_bytes: 19832
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main{
    //WRWWRWRR     wwwrrrrwwwwrrr
    PriorityQueue<int[]> pq = new PriorityQueue<>((a,b)->(a[0]-b[0]));
    boolean[] dp = new boolean[100001];
    public void solve(int testNumber, InputReader in, PrintWriter out) {
       int n = in.nextInt();
       int k = in.nextInt();
       int[] arr = new int[n];
       for(int i=0;i<n;i++){
           arr[i] = in.nextInt();
       }
//       dfs(arr,k,0);
        dp[0] = false;
        for(int i=1;i<=k;i++){
            boolean find = false;
            for(int j=0;j<n;j++){
                if(i>=arr[j]){
                    find|=!(dp[i-arr[j]]);
                }
            }
            dp[i] = find;
        }
       if(dp[k]){
           out.println("First");
       }else{
           out.println("Second");
       }
    }

//    Boolean[][] dp = new Boolean[100001][2];
//    boolean dfs(int[] arr,int rem,int w){
//        if(rem<0) return true;
//        if(rem==0) return false;
//        boolean fina = false;
//        if(dp[rem][w]!=null) return dp[rem][w];
//        for(int i=0;i<arr.length;i++){
//            fina|=!dfs(arr,rem-arr[i],1-w);
//        }
//        return dp[rem][w] = fina;
//    }


    public static void main(String[] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main solver = new Main();
//        int num = in.nextInt();
//        while(num-->0){
//            solver.solve(1, in, out);
//        }
        solver.solve(1, in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 35332
import sys


def main():
    a, b, c, d = map(int, sys.stdin.readline().rstrip().split())

    ac = a * c
    bc = b * c
    ad = a * d
    bd = b * d

    if (a <= 0 and 0 <= b) or (c <= 0 and 0 <= d):
        print(max(ac, bc, ad, bd, 0))
    else:
        print(max(ac, bc, ad, bd))


main()


Measured memory_bytes: 9180
L = [list(map(int,input().split())) for _ in range(3)]
ans = 'Yes'

if L[0][0] + L[1][1] != L[0][1] + L[1][0]: ans = 'No'
if L[0][1] + L[1][2] != L[0][2] + L[1][1]: ans = 'No'
if L[1][0] + L[2][1] != L[1][1] + L[2][0]: ans = 'No'
if L[1][1] + L[2][2] != L[1][2] + L[2][1]: ans = 'No'

print(ans)

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

using namespace std;

#define endl '\n'


int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);

  int n,k;
  cin >> n >> k;
  int vet[n];
  for(int i=0;i<n;i++)
    cin >> vet[i];
  sort(vet,vet+n);

  int ans = 0;

  for(int i=0;i<k;i++)
    ans += vet[i];
  
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define inStrAftInSome cin.ignore(numeric_limits<streamsize>::max(),'\n')		//input string(with whitespace) after input something(char, int, bool, str)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define mt 			make_tuple
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define roff(i, n, f)	for(int i = n-1; i>=f; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef vector< int > 		vi;
typedef vector< vi >		vvi;
typedef pair<int, int> 		pii;
typedef tuple<int,int,int>  tiii;


char a[100010];

int main()
{
	int a, b;
	cin >> a >> b;
	if(a <10 && b < 10)
		cout << a*b << endl;
	else
		cout << "-1" << endl;	
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from decimal import Decimal

N = int(input())
A = [int(10**9*Decimal(input())) for _ in range(N)]

def count(a,p):
  n = a
  count = 0
  while n%p == 0 and count<18:
    n //= p
    count += 1
  return count

Z = np.zeros((19,19), dtype=np.int64)
answer = 0
for a in A:
  c2 = count(a,2)
  c5 = count(a,5)
  answer += Z[18-c2,18-c5]
  Z[:c2+1,:c5+1] += 1

print(answer)


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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


ll solve(ll n,vector<ll>v){
    ll op1,op2;
    vector<ll>dp(n+1);
dp[1]=0;
for(int i=2;i<=n;i++)
{
    op1=abs(v[i]-v[i-1])+dp[i-1];
    op2=(i==2)?INT_MAX:abs(v[i]-v[i-2])+dp[i-2];
    dp[i]=min(op1,op2);
}

return dp[n];

}

int main()
{
    FIO;
    ll a,b,c,d,e,f=0,sum=0,ans,ck=0,m,n,k,p,q,r,t,add=0,x,y,z;
    string s;

    cin>>n;
    vector<ll>v(n+1);
    for(int i=1;i<=n;i++){cin>>v[i];}
    ans=solve(n,v);
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 2560
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000009
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


int a[N];
int main(){
    int n,t,i,j,m,k;
    scanf("%d",&n);int ans=0;
    rep(i,0,n)scanf("%d",&a[i]),a[i]--;
    rep(i,0,n){
        j=a[i];
        if(a[j]==i)ans++;
    }
    printf("%d\n",ans/2);
    return 0;
}

Measured memory_bytes: 640
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 2000000000
#define inf 10000000000000000ll
#define ldb long double
#define pb push_back
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE ll i=p;i<=n;++i)
#define go(x) for(ll i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE ll i=n;i>=p;--i)
#define pii pair<ll,ll> 
#define mk make_pair
#define RE register
#define P 1000000007
#define S second
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define ull unsigned long long
#define S second
#define F first
#define l(p) t[p].l
#define r(p) t[p].r
#define sum(p) t[p].sum
#define tag(p) t[p].tag
#define zz p<<1
#define yy p<<1|1
#define mod 1000000007
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    RE ll x=0,f=1;char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const ll MAXN=100010;
ll n,k,ans;
ll f[MAXN],c[MAXN];
inline ll ksm(ll b,ll p)
{
	ll cnt=1;
	while(p)
	{
		if(p&1)cnt=cnt*b%mod;
		p=p>>1;b=b*b%mod;
	}
	return cnt;
}
signed main()
{
	//freopen("1.in","r",stdin);
	n=3;get(k);
	fep(k,1,i)
	{
		ll ww=k/i;
		f[i]=ksm(ww,n);
		for(int j=i+i;j<=k;j+=i)f[i]=(f[i]-f[j])%mod;
		ans=(ans+f[i]*i)%mod;
	}
	putl((ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 3772
//##MohK
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
using ld = long double;
using i= int ;
int main()
{
   ll n,t,conter=0;
   cin>>n>>t;
   int c[n],w[n];
   ll min=9999999;
   for(ll i=0;i<n;i++){
    cin>>c[i]>>w[i];
   }
   for(ll i=0;i<n;i++){
    if(w[i]>t)continue;
    else {
            if(c[i]<=min){
                min=c[i];
            }
            conter++;
    }
   }
   if(conter==0){
    cout<<"TLE"<<endl;
   }
   else {
    cout<<min<<endl;
   }


    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [input().split() for _ in range(n)]
for i in range(n):
    l[i][1] = 100 - int(l[i][1])
m = sorted(l, reverse = True)
for i in range(n):
    for j in range(n):
        if m[n - i - 1] == l[j]:
            print(j + 1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






// youtube解説

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    // n = 13
    // A 65 0 13
    // Z 90 25 37 11
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i, sz(s)) {
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }
    cout << s << endl;
}




Measured memory_bytes: 256
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n = ni()

for i in range(n, -1, -1):
    if bin(i)[2:].count('1') == 1:
        print(i)
        exit()


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        PriorityQueue<Integer> sKouho = new PriorityQueue<>();
        HashSet<Integer> eKouho = new HashSet<>();

        for (int i = 0; i < m; i++) {
            int s = sc.nextInt();
            int e = sc.nextInt();
            if (s == 1) {
                sKouho.add(e);
            } else if (e == n) {
                eKouho.add(s);
            }
        }

        String ans = "IMPOSSIBLE";

        int count = sKouho.size();
        int eCount = eKouho.size();

        for (int i = 0; i < count; i++) {
            eKouho.add(sKouho.poll());
            if (eCount == eKouho.size()) {
                ans = "POSSIBLE";
                break;
            } else {
                eCount++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 105064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int INF=1e9;

int main(){
    int n,c,k;cin>>n>>c>>k;
    vector<int> t(n);
    for(int i=0;i<n;i++) cin>>t[i];
    sort(t.begin(),t.end());
    int ans=0;
    int pa=0;
    int tm=0;
    for(int i=0;i<n;i++){
        if(pa==0) tm=t[i]+k;
        if(pa<c&&t[i]<=tm) pa++;
        if(pa==c||i==n-1||t[i+1]>tm){
            ans++;
            pa=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	sc.Split(bufio.ScanWords)
	c := make([]int, 26)

	for i := 0; i < 26; i++ {
		c[i] = nextInt()
	}

	s := make([][]int, n)
	for i := 0; i < n; i++ {
		s[i] = make([]int, 26)
		for j := 0; j < 26; j++ {
			s[i][j] = nextInt()
		}
	}

	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[i] = nextInt() - 1 // X日目が配列とずれるから1引く
	}

	for i := 1; i <= n; i++ { // X日目が配列とずれるから1足す
		fmt.Println(culcSatisfuctionScore(c, s, t, i))
	}

}

func culcSatisfuctionScore(c []int, s [][]int, t []int, day int) int {
	var score int

	lastdi := make([]int, 26)
	for i := 0; i < day; i++ {
		score += s[i][t[i]]
		lastdi[t[i]] = i + 1
		for j := 0; j < 26; j++ {
			score -= c[j] * (i + 1 - lastdi[j])
		}
	}
	return score
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1992
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	if (a + b == c || a+c==b || b+c==a) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}


	return 0;
}


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

using namespace std;

int main () {
	int n; cin >> n; int a[n];
	long long c[n];
	for(int i = 0; i < n; i++) {cin >> a[i]; if(i ==0) c[i] = a[i]; else c[i] =  c[i-1] + a[i];}

	long long ans = 0;
	map<long long, int> seen;
	for(int i = 0; i < n; i++){
		long long cur = c[i];
		if(cur == 0){
			ans += (seen[cur] + 1);
		}
		else {
			ans += seen[cur];
		}
		seen[cur]++;
	}

	cout << ans << endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;

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

    sort(d, d + N);

    cout << d[N / 2] - d[N / 2 - 1] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if(s=="SUN"){
        cout << 7 << '\n';
    }
    else if(s=="MON"){
        cout << 6 << '\n';
    }
    else if(s=="TUE"){
        cout << 5 << '\n';
    }
    else if(s=="WED"){
        cout << 4 << '\n';
    }
    else if(s=="THU"){
        cout << 3 << '\n';
    }
    else if(s=="FRI"){
        cout << 2 << '\n';
    }
    else if(s=="SAT"){
        cout << 1 << '\n';
    }
}

Measured memory_bytes: 256
main=print.last.foldl f[1,0,0,0]=<<getLine
f d s=zipWith3(g s)(0:d)d".ABC"
g s u v c
 |s=='?'=mod(v*3+u)$10^9+7
 |s==c=mod(v+u)$10^9+7
 |True=v


Measured memory_bytes: 64124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

int main(){
	int n;cin>>n;
	string ans="No";
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			if(n==i*j)
			{
				ans="Yes";
				i=10,j=10;
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
lst = [int(i) for i in input().split()]
lst.sort()
dst = []

if n>=m:
    print(0)
    exit()

for i in range(1,m):
    dst.append(lst[i]-lst[i-1])
dst.sort()
if n==1:
    ans = sum(dst)
else:
    ans = sum(dst[:-n+1])
print(ans)

Measured memory_bytes: 13840