akhauriyash/Code-Regression huggingface dataset:
/**
 * Created by hiramekun at 01:18 on 2020-05-12.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#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 each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */


void solve() {
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }

    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') continue;
            vector<vector<ll>> d(h, vector<ll>(w, ll_inf));
            d[i][j] = 0;

            ll tmp = 0;
            auto rec = [&](auto &&f, vector<P> &nxt) -> void {
                if (nxt.empty()) return;
                vector<P> nxt2;
                each(e, nxt) {
                    ll x = e.first, y = e.second;
                    rep(k, 4) {
                        ll nx = x + dx[k], ny = y + dy[k];
                        if (nx < 0 || h - 1 < nx || ny < 0 || w - 1 < ny) continue;
                        if (s[nx][ny] == '#' || d[nx][ny] < ll_inf) continue;
                        d[nx][ny] = d[x][y] + 1;
                        tmp = max(tmp, d[nx][ny]);
                        nxt2.emplace_back(make_pair(nx, ny));
                    }
                }
                f(f, nxt2);
            };
            vector<P> now{make_pair(i, j)};
            rec(rec, now);
            ans = max(ans, tmp);
        }
    }

    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<ll, int> ll_i;
const int MOD = 1e9 + 7;
const ll INF = LLONG_MAX / 2;
struct edge { int v, w; };

vector<ll> dijkstra(int N, vector<vector<edge> >& G, int s) {
	vector<ll> d(N, INF); d[s] = 0;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > pq;
	pq.push(ll_i(0, s));
	while (pq.size()) {
		ll_i p = pq.top(); pq.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (edge e: G[u])
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				pq.push(ll_i(d[e.v], e.v));
			}
	}
	return d;
}

int main() {
	int N; cin >> N;
	vector<vector<edge> > G(N);
	rep(i, N - 1) {
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		u--, v--;
		G[u].pb(edge{v, w});
		G[v].pb(edge{u, w});
	}
	int Q, x; cin >> Q >> x;
	x--;
	vector<ll> d = dijkstra(N, G, x);
	while (Q--) {
		int u, v; scanf("%d%d", &u, &v);
		u--, v--;
		printf("%lld\n", d[u] + d[v]);
	}
}


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

#define x first
#define y second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define REP(i, a) FOR(i, 0, a)
#define TRACE(x) cout << #x << " " << x << endl
#define _ << " _ " <<

using namespace std;

#define task "b"

int erat[1000005];

ll pot(ll a, ll b, ll c){
  if (b == 0) return 1;
  ll r = pot((a*a)%c, b/2, c);
  if (b&1) r = (r*a)%c;
  return r;
}

int gcd(int a, int b){
  while (b) a %= b, swap(a, b);
  return a;
}

int main(){

  FOR(i,2,1000005)
    if (!erat[i])
      for (int j = i; j < 1000005; j += i)
	erat[j] = i;

  while (true){
    int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) return 0;
    int g = gcd(a, b);
    a /= g, b /= g;
    int t = 0, u = 0;
    while (b % 2 == 0) ++t, b /= 2;
    while (b % 5 == 0) ++u, b /= 5;
    cout << max(t, u) << " ";

    int bb = b, phi = 1;
    while (bb != 1){
      int p = erat[bb];
      bb /= p;
      phi *= p-1;
      while (erat[bb] == p) phi *= p, bb /= p;
    }

    FOR(i,2,phi+1)
      while (phi%i == 0 && pot(10, phi/i, b) == 1) phi /= i;

    if (b == 1) phi = 0;
    cout << phi << endl;
  }
  
  return 0;
}

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

#define rep(i,a,b) for (int i = (a); i < (b); i++ )

int main() {
	int a, s, d, f, k;
	cin >> a >> s >> d >> f >> k;

	int ans = (60 * d + f) - (60 * a + s) - k;
	cout << ans << endl;

	}

Measured memory_bytes: 3652
// Practice AtCoder
// author: Loenardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let k = get!();
    let mut ps = vec![];
    let mut fs = vec![];
    for _ in 0 .. n {
        ps.push(get!());
    }
    for _ in 0 .. n {
        fs.push(get!());
    }
    ps.sort();
    fs.sort();
    fs.reverse();
    
    let mut m = (1 << 61) - 1;
    for z in 0 .. 61 {
        let z = 60 - z;
        let hp = m - (1 << z);
        let mut sum = 0;
        for i in 0 .. n {
            let e = hp / fs[i];
            if ps[i] > e {
                sum += ps[i] - e;
            }
        }
        if sum <= k {
            m -= 1 << z;
        }
    }
    println!("{}", m);
}


Measured memory_bytes: 14584
n, m = map(int, input().split())
d = list(map(int, input().split()))
dp = [10000 for i in range(n + 1)]
dp[0] = 0

for i in range(0, n + 1):
    if dp[i] < 10000:
        for j in d:
            if i + j <= n:
                dp[i + j] = min(dp[i] + 1, dp[i + j])

print(dp[n])

Measured memory_bytes: 9396
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJDPL_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            int[] dp = new int[n].Select(x => int.MaxValue).ToArray();
            for (int i = 0; i < n; i++)
            {
                int b = LowerBound(dp, a[i]);
                dp[b] = Math.Min(dp[b], a[i]);
            }

            Console.WriteLine(LowerBound(dp, int.MaxValue));
            Console.ReadKey();
        }


        /// <summary>
        /// 二分探索 vを超える最低
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="a"></param>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int LowerBound<T>(T[] a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 24260
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
	string s;
	cin >> s;

	for (ll i = 0; i < 3; i++)
	{
		if(s[i] == s[i+1]){
			cout << "Bad" << endl;
			exit(0);
		}
	}
	cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;	//
  
  cin >> a >> b; 

  if ((a * b) % 2 == 0 ){
    cout << "Even" << endl ;	//偶数
  }
  else {
    cout << "Odd" << endl ;      
  }
}

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

int main() {
    //
    int num;
    int a, b, forA, forB;
    string str;
    int Max = 0;
    int sCnt = 0;
    int tmp = 0, tmp2 = 0;
    bool chk = false;

    cin >> num >> a >> b >> forA >> forB;
    cin >> str;
    for (int i = 0; i < num; i++) {
        if (str.at(i) == '.') {
            tmp++;
            if (tmp2 >= 2) {
                if ((a < i && i < forA) || (a > i && i > forA)) {
                    cout << "No";
                    return 0;
                }
                if ((b < i && i < forB) || (b > i && i > forB)) {
                    cout << "No";
                    return 0;
                }
            }
            tmp2 = 0;
        } else {
            tmp2++;
            Max = max(Max, tmp);
            if (tmp >= 3 && i-1 >= b && i-1 <= forB) chk = true;
            tmp = 0;
        }
    }

    if (forA <= forB){
        if (Max >= 2)
            cout << "Yes";
        else
            cout << "No";
    } else {
        if (chk == true)
            cout << "Yes";
        else
            cout << "No";
    }
    //
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int AC=0;
  int WA=0;
  int TLE=0;
  int RE=0;
  cin>>N;
  vector<string>vec(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
    if(vec.at(X)=="AC"){
      AC++;
    }
    else if(vec.at(X)=="WA"){
      WA++;
    }
    else if(vec.at(X)=="TLE"){
      TLE++;
    }
    else{
      RE++;
    }
  }
  cout<<"AC"<<" "<<"x"<<" "<<AC<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<WA<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<TLE<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<RE<<endl;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, cnt=0;
    scanf("%d", &n);
    int number[n];
    for(i=0; i<n; i++)
        scanf("%d", number+i);
    for(i=0; i<n-1; i++)
    {
        if(number[i]==number[i+1])
        {
            cnt++;
            i++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
q = gets.split(" ").map(&:to_i)[1]
ary = gets.chomp.split("")
c = [0]

now = 0
ary.each_with_index do |a, i|
  now += 1 if a == 'C' && ary[i-1] == 'A'
  c << now
end

q.times do
  a, b = gets.chomp.split(" ").map(&:to_i)

  puts c[b] - c[a]
end


Measured memory_bytes: 10876
import java.util.Scanner;

public class Main {
	
	  
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			int a = in.nextInt();
			int b = in.nextInt();
			int ans = Math.max(Math.max(a+b, a-b), a*b);
			System.out.println(ans);
		}
	}
}

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

int main(){
    ll N, M; cin >> N >> M;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

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

    ll lb = 0, ub = 2 * A[N-1] + 1;
    while(ub - lb > 1){
        ll m = (lb + ub ) / 2;
        ll sum = 0;
        rep(i, 0, N){
            if(m-A[i] >= 0) sum += distance(lower_bound(A.begin(), A.end(), m - A[i]), A.end());
            else sum += N;
        }
        if(sum >= M) lb = m;
        else ub = m;
    }
    //cerr << lb << endl;
    ll ans = 0, cnt = 0;
    rep(i, 0, N){
        ll tcnt = 0;
        tcnt = 2 * distance(upper_bound(A.begin(), A.end(), lb - A[i]), A.end());
        /* if(*upper_bound(A.begin(), A.end(), lb - A[i]) >= A[i]){
            tcnt--;
        } */
        //cerr << i <<  " " <<tcnt << endl;
        ans += tcnt * A[i];
        cnt += tcnt;
    }
    //cout << ans << endl;
    ans += (2 * M - cnt) / 2 * lb;
    cout << ans << endl;
    
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

const int maxn = 1005;
int dis[maxn][maxn];

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

bool in(int x, int y){
    return 0 <= x and x < H and y >= 0 and y < W;
}

string s[maxn];

void bfs(){
    queue<pi> q;
    memset(dis, 0x3f, sizeof(dis));
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(s[i][j] == '#'){
                q.push(mp(i, j));
                dis[i][j] = 0;
            }
        }
    }
    int ans = 0;
    while(!q.empty()){
        pi p = q.front(); q.pop();
        int x = p.first;
        int y = p.second;
        for(int i = 0;i < 4;i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(in(nx, ny) and s[nx][ny] == '.'){
                if(dis[nx][ny] > dis[x][y] + 1){
                    dis[nx][ny] = dis[x][y] + 1;
                    ans = max(ans, dis[nx][ny]);
                    q.push(mp(nx, ny));
                }
            }
        }
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> H >> W;
    for(int i = 0;i < H;i++){
        cin >> s[i];
    }
    bfs();
    return 0;
}


Measured memory_bytes: 13456
main = do
    str <- getLine
    let [h, w] = map read $ words $ str :: [Int]
    if h == 0 && w == 0
        then return ()
        else do
            putStrLn $ replicate w '#'
            putStr . unlines $ replicate (h - 2) ("#" ++ replicate (w - 2) '.' ++ "#")
            putStrLn $ replicate w '#' ++ "\n"
            main

Measured memory_bytes: 4036
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <cstdint>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

bool schedule[31][50];

int main() {
	int n;
	while(cin >> n, n){
		fill_n((bool *)schedule, 31 * 50, false);
		REP(i, n){
			int m;
			cin >> m;
			REP(j, m){
				int d;
				cin >> d;
				schedule[d - 1][i] = true;
			}
		}

		vector<uint64_t> dp(n, 0);

		uint64_t one = 1;
		REP(i, n){
			dp[i] = (one << (uint64_t)i);
		}

		uint64_t goal = (one << n) - 1;

		int res = -1;
		REP(d, 30 + 1){
			uint64_t trg = 0;
			REP(i, n){
				if(schedule[d][i]){
					trg |= dp[i];
				}
			}

//			LOG("day -- %lld %lld\n", d, trg);
			if(trg == goal){
				res = d + 1;
				break;
			}

			REP(i, n){
				if(schedule[d][i]){
					dp[i] = trg;
				}
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    tezi;
    ll a, b = 0;
    string s;
    cin >> a >> s;
    for(int i = 0; i < 4; ++i){
        if(s[i] == '.') continue;
        b = b * 10 + s[i] - '0';
    }
    ll pro = (a * b) / 100;
    cout << pro << "\n";
    return 0;
}


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

int main()
{
    string N;
    char checkValue;

    cin >> N;

    checkValue = N[1];
    
    if ((N[0] == checkValue && N[2] == checkValue) || (N[2] == checkValue && N[3] == checkValue)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int h, w, ans, k;
bool grid[10][10];

int main() {
	fastio; cin >> h >> w >> k;
	FOR(i, 0, h-1) FOR(j, 0, w-1) {
		char ch; cin >> ch;
		grid[i][j] = (ch == '#');
	}
	FOR(i, 0, (1<<h)-1) FOR(j, 0, (1<<w)-1) {
		int cur = 0;
		FOR(x, 0, h-1) FOR(y, 0, w-1) {
			if (!(i & (1<<x)) and !(j & (1<<y)) and grid[x][y]) cur++;
		}
		if (cur == k) ans++;
	}
	cout << ans;
}


Measured memory_bytes: 3668
cnt = 0
def water(lst):
    global cnt
    if len(lst) == 0:
        return
    if len(lst) == 1:
        cnt = cnt + lst[0]
        return
    
    m = min(lst)
    cnt += m
    
    lst = [i - m for i in lst]
    while 0 in lst:
        water(lst[:lst.index(0)])
        lst = lst[lst.index(0)+1:]
    water(lst)


n = int(input())
lst = list(map(int,input().split()))
water(lst)
print(cnt)

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
	boost;

    //code
	int n , d , x , y;
	cin >> n;
	int a[n];
	int s = 0;
	for(int i = 0  ; i < n ; ++i){
		cin >> a[i];
		s += a[i];
	}

	cin >> d;

	while(d--){
		cin >> x >> y;
		x--;
		cout << s + (-a[x] + y) << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>


int main() {

	int n = 0;
	std::cin >> n;
	std::vector<std::string>str(n);
	std::vector<std::pair<char, int>>str_char_pair{};

	bool enable = false;
	for (int i = 0; i < n; i++)
	{
		std::cin >> str[i];
		for (char c = 'a'; c <= 'z'; c++)
		{
			int count = std::count(str[i].begin(), str[i].end(), c);

			if (count >= 1) {
				str_char_pair.emplace_back(c, count);
			}
		}
	}
	std::sort(str_char_pair.begin(), str_char_pair.end());
	std::vector<std::pair<char, int>>enable_str_pair;
	for (char c = 'a'; c <= 'z'; c++)
	{
		int count = std::count_if(str_char_pair.begin(), str_char_pair.end(), [&c](std::pair<char, int>p) ->bool {return p.first == c;});
		if (count == n)
		{
			auto it = std::find_if(str_char_pair.begin(), str_char_pair.end(), [&c](std::pair<char, int>&p) ->bool {return p.first == c;});
			for (size_t i = 0; i < n; i++)
			{
				enable_str_pair.push_back(*(it + i));
			}
		}
	}

	for (char c = 'a'; c <= 'z'; c++)
	{
		for (auto& i : enable_str_pair)
		{
			if (i.first == c)
			{
				for (int j = 0; j < i.second; j++)
				{
					std::cout << c;
					enable = true;
				}
				break;
			}
		}
	}
	if (!enable)std::cout << "";
	std::cout << std::endl;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  ll a, b;
  cin >> n >> a >> b;

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

  ll sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    ll dist = vx[i + 1] - vx[i];
    sum += min(a * dist, b);
  }

  cout << sum << '\n';
}

Measured memory_bytes: 3996
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  rep(i,0,3)cin >> d[i];
  sort(d,d+3);
  print(d[0] + d[1]);
  return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()

ans = 0
for i in b:
    k = bisect.bisect_left(a, i)
    l = bisect.bisect_right(c, i)
    ans += k * (n - l)
print(ans)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int S = 0;
  cin >> N;
  int temp = N;
  while(temp) {
    S += temp % 10;
    temp = temp / 10;
  }
  if(N % S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
a=[input() for i in range(2)]

a1=a[0]
p=a[1]

a1=[int(i) for i in a1.split()]
p=[int(i) for i in p.split()]

p_up=sorted(p)

sum=0

for i in range(a1[1]):
	sum+=p_up[i]

print(sum)

Measured memory_bytes: 9124
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    if((x+y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }
    int X = x - (x+y) / 3;
    int Y = y - (x+y) / 3;
    if(Y > X) swap(X, Y);
    mint ans = choose(X+Y, X);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])
now=0
ans=0
for i in range(n):
  if now+ab[i][1]<=m:
    now += ab[i][1]
    ans += ab[i][0]*ab[i][1]
  else:
    ans += ab[i][0]*(m-now)
    break
print(ans)

Measured memory_bytes: 93440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    unordered_map<string,ll> summary;
    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        summary[s]++;
    }
    ll ans = 0;
    for(auto itr = summary.begin(); itr != summary.end(); ++itr){
        ll num = itr->second;
        ans += (num*(num-1))/2;
    }
    cout << ans;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  if (A <= 5) {
    cout << "0\n";
  } else if(A <= 12) {
    cout << B / 2 << "\n";
  } else {
    cout << B << "\n";
  }
  return 0;
}

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

using namespace std;


int main() {
  
    int n;
    scanf("%d",&n);
  set<long int > s;
  long int l[n],r[n],i,j;
  for(i=0;i<n;++i)
  {
    scanf("%ld%ld",&l[i],&r[i]);
    for(j=l[i];j<=r[i];++j)
    {
      s.insert(j);
    }
    
  }
  
  cout<<s.size();
  
    	return 0;
}

Measured memory_bytes: 4992
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        long[] sizes = { 25, 50, 100, 200 };
        Queue<Tee> queue = new PriorityQueue<>();
        for (int i = 0; i < 4; i++) {
            long cost = in.nextLong();
            queue.add(new Tee(cost, sizes[i]));
        }
        long N = in.nextLong() * 100;

        long ans = 0;
        long tmpSize = 0;
        for (Tee t : queue) {
            while (true) {
                if (tmpSize + t.size > N) {
                    break;
                }

                tmpSize += t.size;
                ans += t.cost;
            }
        }

        out.println(ans);
    }
}

class Tee implements Comparable<Tee> {
    long cost;
    long size;
    double value;

    Tee(long cost, long size) {
        this.cost = cost;
        this.size = size;
        this.value = 100 * cost / size;
    }

    @Override
    public int compareTo(Tee o) {
        if (this.value == o.value) {
            if (this.size > o.size) {
                return 1;
            } else {
                return -1;
            }
        } else if (this.value > o.value) {
            return 1;
        } else {
            return -1;
        }
    }

    @Override
    public String toString() {
        return String.valueOf(this.value);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

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

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<string>
using namespace std;
int a[30];
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		a[s[i]-'a']++;
	}
	bool flag=false;
	for(int i=0;i<26;i++)
		if(a[i]==0)
		{
			flag=true;
			cout<<char('a'+i);
			break;
		}
	if(!flag)
		cout<<"None";
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main(){
	int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
	ans=(n-d)*2*(long long)(m-1);
	if(d==0) ans/=2;
	double sum=ans/(double)(n*(long long)n);
	printf("%.10f\n",sum);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
V = list(map(int, input().split()))


def m():
    first = V[0::2]
    second = V[1::2]
    fdic = {}
    sdic = {}
    for i in range(N//2):
        if fdic.get(first[i], 0) == 0:
            fdic[first[i]] = 1
        else:
            fdic[first[i]] +=1

        if sdic.get(second[i], 0) == 0:
            sdic[second[i]] = 1
        else:
            sdic[second[i]] +=1
    flist = list(fdic.items())
    slist = list(sdic.items())

    flist.sort(reverse=True, key=lambda x:x[1])
    slist.sort(reverse=True, key=lambda x:x[1])

    if len(flist) == 1 and len(slist) == 1:
        if flist[0][0] == slist[0][0]:
            return N//2
        return 0
    if len(flist) == 1:
        return N//2 - slist[0][1]
    if len(slist) == 1:
        return N//2 - flist[0][1]

    if flist[0][0] != slist[0][0]:
        ans = 0
        for k, v in flist:
            if k != flist[0][0]:
                ans += v
        for k, v in slist:
            if k != slist[0][0]:
                ans += v
        return ans

    fans = 0
    sans = 0
    for k, v in flist:
        if k != flist[0][0]:
            fans += v
    for k, v in slist:
        if k != slist[1][0]:
            fans += v

    for k, v in flist:
        if k != flist[1][0]:
            sans += v
    for k, v in slist:
        if k != slist[0][0]:
            sans += v
    return min(fans,sans)

print(m())

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using pll = pair < ll , ll >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vl  = vector < ll >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 100 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;
int a[N];

int calc(int x){
    int sum = 0;
    for(int i = 0 ; i < n ; i ++){
        int diff = x - a[i];
        sum += diff * diff;
    }
    return sum;
}

void solve(){
    scanf("%d" , &n);

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

    avg /= n;

    printf("%d\n" , min(calc(avg) , calc(avg+1)));
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}





Measured memory_bytes: 256
#153_F
from bisect import bisect_right
n, d, a = map(int, input().split())
mons = sorted([tuple(map(int, input().split())) for _ in range(n)])
x = [mons[i][0] for i in range(n)]
h = [mons[i][1] for i in range(n)]
damage = [0 for _ in range(n+1)]
cnt = 0
for i in range(n):
    if i > 0:
        damage[i] += damage[i-1]
        if h[i] <= damage[i]:
            continue
    
    cur_cnt = -(-(h[i]-damage[i]) // a)
    cnt += cur_cnt
    damage[i] += cur_cnt * a
    idx = bisect_right(x, x[i] + 2 * d)
    damage[idx] -= cur_cnt * a
    
print(cnt)

Measured memory_bytes: 41132
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    HashMap<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();
    for(int i = 0; i < m; i++) {
      int k = sc.nextInt();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int j = 0; j < k; j++) {
        int s = sc.nextInt();
        list.add(s - 1);
      }
      map.put(i, list);
    }
    int[] p = new int[m];
    for(int i = 0; i < m; i++) {
      p[i] = sc.nextInt();
    }

    int ans = 0;
    for(int i = 0; i < (int)Math.pow(2, n); i++) {
      int t = 1;
      for(int j = 0; j < m; j++) {
        ArrayList<Integer> list2 = map.get(j);
        int sum = 0;
        for(int k = 0; k < list2.size(); k++) {
          if((i & (1 << list2.get(k))) != 0) sum++;
        }
        if((sum % 2) != p[j]) t = 0;
      }
      if(t == 1) ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
n = gets.to_i
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

ans = 0
bs.each_with_index do |b, i|
  d = as[i] <= b ? as[i] : b
  as[i] -= d
  ans += d

  b -= d

  d = as[i + 1] <= b ? as[i + 1] : b
  as[i + 1] -= d
  ans += d
end

puts ans


Measured memory_bytes: 15388
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int n, ans;
int a[25], b[25], c[25];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) 
        cin >> a[i];
    for (int i = 0; i < n; ++i) 
        cin >> b[i];
    for (int i = 1; i < n; ++i) 
        cin >> c[i];
    ans += b[a[0] - 1];
    for (int i = 1; i < n; ++i) {
        ans += b[a[i] - 1];
        if (a[i - 1] + 1 == a[i]) ans += c[a[i] - 1];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="SAT")
        cout<<"1"<<endl;
    else if(s=="SUN")
        cout<<"7"<<endl;
    else if(s=="FRI")
        cout<<"2"<<endl;
    else if(s=="THU")
        cout<<"3"<<endl;
    else if(s=="WED")
        cout<<"4"<<endl;
    else if(s=="TUE")
        cout<<"5"<<endl;
    else if(s=="MON")
        cout<<"6"<<endl;
    return 0;
}


Measured memory_bytes: 256
let threshold = 1000000007
var fac: [Int] = [1]
var ifac: [Int] = [1]

func comb(_ n: Int, _ k: Int) -> Int {
  return ((fac[n] * ifac[k]) % threshold) * ifac[n-k] % threshold
}

func powd(_ x: Int, _ n: Int) -> Int {
  var result = 1
  var n = n
  var x = x
  while n != 0 {
    if n & 1 == 1 {
      result = result * x % threshold
    }
    x = x * x % threshold
    n >>= 1
  }
  return result
}

let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let M = input[1]
let K = input[2]
for i in 1...N*M {
  fac.append(fac[i-1] * i % threshold)
  ifac.append(ifac[i-1] * powd(i, threshold - 2) % threshold)
}



var coe = comb(N * M - 2, K - 2)
var ans = 0
var a = 0
for i in 1..<N {
  a = i * (N - i)
  a %= threshold
  a *= (M * M)
  a %= threshold
  ans += a
  ans %= threshold
}
for i in 1..<M {
  a = i * (M - i)
  a %= threshold
  a *= (N * N)
  a %= threshold
  ans += a
  ans %= threshold
}

ans = coe * ans % threshold
print(ans)


Measured memory_bytes: 11388
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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


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

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    string S[N];
    int P[N];
    REP(i, N) cin >> S[i] >> P[i];

    vector< pair<pair<string, int>, int> > v;
    REP(i, N) v.push_back( make_pair(make_pair(S[i], P[i]), i + 1));

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

    REP(i, N) {
        cout << v[i].second << endl;
    }


    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  vector<int> xs({1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51});
  int k;
  cin >> k;
  cout << xs[k - 1] << endl;
}

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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop0(i,n) for(int i=0; i<(n); i++)
#define loop1(i,n) for(int i=1; i<=(n); i++)
#define fori(a,b,i) for(int i=(a); i<=(b); i++)
#define ford(a,b,i) for(int i=(a); i>=(b); i--)
#define fast_io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ign cin.ignore(numeric_limits<streamsize>::max(),'\n')

#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef map<int,int> MCI;
typedef unordered_map<int,int> UMII;
typedef unordered_map<char,int> UMCI;
typedef set<int> SI;
typedef long long int llint;

// Display Map
//~for (auto const& pair: m) {
//~std::cout << "{" << pair.first << ": " << pair.second << "}\n";
//~}

// Extract word(w) from sentence(s)
//~stringstream str(s);
//~string w;
//~while(str >> w){
//~// w is your word
//~}

//Memset Syntax
// memset(array, value,sizeof(array)) val is 0,-1 or bool only

// To get accurate precision
//~cout.precision(20);

int main() {
    fast_io;
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	for(auto &i : v) cin >> i;
	sort(v.begin(),v.end())	;
	llint sum = 0;
	for(int i = 0; i < k; i++) sum+= v[i];
	cout << sum << endl;
}


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int N; scanf("%d", &N);
  long ans{1};
  for (int i{1}; i <= N; ++i) {
    ans *= i;
    ans %= 1000000007;
  }

  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,r=1;
  int v;
  scanf("%d%d",&x,&y);
  if(y>x){
    v=x;
    x=y;
    y=v;
  }
  while(r!=0){
    r=x%y;
    x=y;
    if(r!=0){
    y=r;
    }
  }
  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a;
    rep(i, n){
        ll x;
        cin >> x;
        a.push_back(x);
    }

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

    vector<P> cb;
    rep(i, m){
        ll b, c;
        cin >> b >> c;
        cb.push_back(make_pair(c*(-1), b));
    }

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

    ll now = 0;
    bool flag = true;

    rep(i, m){
        ll cnt=0;
        if(a[now] >= cb[i].first*(-1)){
            break;
        }
        while(cnt<cb[i].second){
          if (a[now] >= cb[i].first * (-1)) {
            break;
          } else {
            a[now++] = cb[i].first * (-1);
            cnt++;
          }
            if(now >= n){
                flag = false;
                break;
            }
        }
        if(!flag){
            break;
        }
    }

    ll sum=0;

    rep(i, n){
        sum += a[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 6164
#include <iostream>
#include <cstdlib>
#include <cmath>

bool prime(int a); 

int main(void) {
    int n;
    std::cin >> n;
    int result = 0;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        if (prime(a) == true) {
            result++;
        }
    }
    std::cout << result << std::endl;
    return EXIT_SUCCESS;
}

bool prime(int a) {
    int root = (int)(sqrt(a)); 
    if (a == 2) {
        return true;
    } else {
        for (int i = 2; i <= root; i++) {
            if (a % i == 0) {
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 3092
nums = [int(e) for e in input().split()]
a = nums[0]
b = nums[1]
c = nums[2]
k = nums[3]
total = 0

if a > k:
    total = 1 * k
elif b > (k-a):
    total = 1 * a
else:
    total = 1 * a + (-1) * (k-a-b)

print(total)


Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

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

  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H + 2,vector<char>(W + 2,'#'));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a[i+1][j+1];
    }
  }
  for(int i = 0; i < H + 2; i++){
    for(int j = 0; j < W + 2; j++){
      cout << a[i][j];
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 256
use proconio::*;
use std::cmp::min;

fn main() {
    input! {
        n: usize,
        tl: i64,
        ct: [(i64, i64); n],
    }
    let mut res = 10000i64;
    for i in 0..n {
        if ct[i].1 <= tl {
            res = min(res, ct[i].0);
        }
    }
    if res == 10000 {
        println!("TLE");
    } else {
        println!("{}", res);
    }
}


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

int main() {
  ll n, p; cin >> n >> p;
  string s; cin >> s;
  ll r=0, ans=0, acc=1;
  if (p == 2) {
    for (int i = 0; i < n; i++) {
      if ((s[i]-'0')&1^1) ans+=i+1;
    }
    cout << ans;
    return 0;
  }
  if (p == 5) {
    for (int i = 0; i < n; i++) {
      if (s[i] == '0' || s[i] == '5')
        ans+=i+1;
    }
    cout << ans;
    return 0;
  }
  map<ll, ll> mp;
  mp[0] = 1;
  for (int i = n-1; ~i; i--, acc = ((acc*10)%p + p)%p) {
    r = (((acc*(s[i]-'0') + r) % p) + p) % p;
    if (mp.find(r) != mp.end())
      ans+=mp[r];
    else
      mp.insert({r, 0});
    mp[r]++;
  }
  cout << ans;
}


Measured memory_bytes: 1028
N = int(input())
a = list(map(int, input().split()))

arai = sum(a)-a[0]
sunuke = a[0]
ans = abs(sunuke-arai)
for i in a[1:-1]:
    sunuke += i
    arai -= i
    ans = min(abs(sunuke-arai), ans)

print(ans)

Measured memory_bytes: 23800
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

signed main() {
  IOS
  int x, a;
  cin >> x >> a;
  
  if (x < a){
    cout << 0 << endl;
  }
  else{
    cout << 10 << endl;
  }

}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  vector<int> A(N); cin >> A;
  map<int, int> m;
  rep(i, N) {
    m[A[i]]++;
  }
  int ans = m.size();
  bool f = 0;
  for(auto e: m) {
    f ^= e.second % 2 == 0;
  }
  ans -= f;
  cout << ans << endl;
}


Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;

const int N=100009;
const ll Inf=1e18;

int n,t,e;
int x[N];
ll f[N],smn,ff[N];

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}
inline void chkmin(ll &a,ll b){if(a>b)a=b;}

int main()
{
	n=read();
	e=read();
	t=read();
	for(int i=1;i<=n;i++)
		x[i]=read();

	f[0]=0;
	ff[0]=-2*x[1];
	int ptr=0;
	for(int i=1;i<=n;i++)
	{
		while(2ll*(x[i]-x[ptr+1])>t)ptr++;
		f[i]=f[ptr]+t;
		if(ptr)chkmin(f[i],2*x[i]+ff[ptr-1]);
		ff[i]=min(f[i]-2*x[i+1],ff[i-1]);
	}

	printf("%lld\n",f[n]+e);
	return 0;
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int A[100000];
int Max[100000];
int Cnt[100000];
int main() {
	int N, T;
	cin >> N >> T;
	rep(i, N) cin >> A[i];
	Max[N - 1] = A[N - 1];
	Cnt[N - 1] = 1;
	int max_d = 0;
	for (int i = N - 2; i >= 0; i--) {
		max_d = max(max_d, Max[i + 1] - A[i]);
		Max[i] = Max[i + 1];
		Cnt[i] = Cnt[i + 1];
		if (Max[i + 1] == A[i]) {
			Cnt[i] = Cnt[i + 1] + 1;
		}
		else if (Max[i + 1] < A[i]) {
			Max[i] = A[i];
			Cnt[i] = 1;
		}
	}
	int sum = 0;
	int tmp = 1 << 30;
	rep(i, N-1) {
		if (Max[i + 1] - A[i] == max_d && tmp > Max[i + 1]) {
			tmp = Max[i + 1];
			sum += Cnt[i + 1];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  ll n, m;
  vector<ll> v[8];
  cin >> n >> m;

  REP(i, n) {
    ll a, b, c;
    cin >> a >> b >> c;
    REP(j, 8) {
      v[j].pb(((j & 1) ? a * -1 : a) + (((j >> 1) & 1) ? b * -1 : b) + (((j >> 2) & 1) ? c * -1 : c));
    }
  }
  REP(i, 8) {
    sort(v[i].begin(), v[i].end(), greater<ll>());
  }
  ll ret = 0;
  REP(i, 8) {
    ll sum = 0;
    REP(j, m) {
      sum += v[i][j];
    }
    ret = max(ret, sum);
  }
  cout << ret << endl;
}

Measured memory_bytes: 384