akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int cnt=0;
    rep(i, n-2){
        if(s.substr(i, 3) == "ABC"){
            cnt++;
        }
    }
    cout << cnt;
}

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

int main() {
	int r, c;
	cin >> r >> c;

	int rxc[101][101] = {};
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> rxc[i][j];
			rxc[i][c] += rxc[i][j];
			rxc[r][j] += rxc[i][j];
			rxc[r][c] += rxc[i][j];
		}
	}

	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c + 1; j++) {
			cout << rxc[i][j];
			(j == c)?cout << endl:cout << " ";
		}
	}
	

	return 0;
}


Measured memory_bytes: 3144
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		boolean bl = true;
		int tmp;
		while(bl){
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			if(x == 0 && y == 0) break;
			if(x > y){
				tmp = x;
				x = y;
				y = tmp;
			}
			System.out.println(x +" "+ y);
		}
	}
}

Measured memory_bytes: 35244
using System;
using System.Linq;
class program
{
  static void Main(string[] args)
  {
    string s = Console.ReadLine();
    string t = Console.ReadLine();
    
    char[] s_ary = s.ToArray();
    char[] t_ary = t.ToArray();
    
    Array.Sort(s_ary);
    Array.Sort(t_ary);
    Array.Reverse(t_ary);
    
    string s_ = string.Join("",s_ary);
    string t_ = string.Join("",t_ary);
    
    string ans = "No";
    
    if (String.Compare(s_,t_) == -1)
    {
      ans = "Yes";
    }

    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 26648
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    int h,w;
    cin>>h>>w;
    char c[h][w];
    rep(i,h)rep(j,w)cin>>c[i][j];
    rep(i,w+2)cout<<'#';
    cout<<endl;
    rep(i,h){
        cout<<'#';
        rep(j,w)cout<<c[i][j];
        cout<<'#'<<endl;
    }
    rep(i,w+2)cout<<'#';
    cout<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=1e5+5;


void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n;cin>>n;
    bool ok=0;
    while(n){
        if(n%10==7) ok=1;
        n/=10;
    }
    if(ok) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>> N;
    string s="No";
    int c,d;
    for (int i = 0; i <=25 ; i++)
    {
        for (int j = 0; j <15 ; j++)
        {
            int total=4*i+7*j;
           if (N==total)
           {
               s="Yes";
           }
           
        }
        
    }
    cout<< s<< endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
func init_for_competitive_programing() {
	sc.Split(bufio.ScanWords)
}
func nextInt() int {
	sc.Scan()
	i,e := strconv.Atoi(sc.Text())
	if e!=nil {
		panic(e)
	}
	return i
}


func main(){
	init_for_competitive_programing()
	
	n := nextInt()

	var res string
	switch n%10{
	case 2,4,5,7,9: res = "hon"
	case 0,1,6,8: res = "pon"
	case 3: res = "bon"
	}
	
	fmt.Println(res)
	
}




Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n, K; cin >> n >> K;
  vector<int> v(n); REP (i, n) cin >> v[i];
  int ans = -1e18;
  REP (i, n) {
    REPI (j, i, n + 1) {
      dump(i, j);
      vector<int> tmp;
      REP (k, i) tmp.push_back(v[k]);
      REPI (k, j, n) tmp.push_back(v[k]);
      sort(RALL(tmp));
      int num = i + (n - j);
      if (num > K) continue;
      REP (k, K - num) {
        if (tmp.size() > 0 && tmp.back() < 0) tmp.pop_back();
      }
      int acc = accumulate(ALL(tmp), 0LL);
      dump(tmp);
      chmax(ans, acc);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
bool check(string buys,string defs){
  REP(i,8){
    if(defs[i] != '*'&&defs[i] != buys[i])
      return false;
  }
  return true;
}

int main(void){  
  int n,m;
  while(cin>>n>>m){
    int money[100];
    vector<string> number;
    string bf;
    if(!n) break;
    int out = 0;
    REP(i,n){
        cin >> bf;
        number.push_back(bf);
      
      cin >> money[i];
    }
    while(m--){
      string num;
      cin >> num;
      REP(i,n){
        if(check(num,number[i])){
          out += money[i];
          break;
        }
      }
    }
    cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 936
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 100005
using namespace std;
int n,a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(n%3){
		for(int i=1;i<=n;i++)
			if(a[i]!=0){
				puts("No");
				return 0;
			}
		puts("Yes");
		return 0;
	}
	else{
		sort(a+1,a+1+n);
		int len=n/3;
		for(int j=0;j<3;j++)
			for(int i=len*j+1;i<=len*(j+1);i++)
				if(a[i]!=a[len*j+1]){
					puts("No");
					return 0;
				}
		if(a[1]^a[len+1]^a[len*2+1]){
			puts("No");
			return 0;
		}
		puts("Yes");
		return 0;
	}
	return 0;
}


Measured memory_bytes: 640
unittest
{
	assert( [ "7", "3 1 4 1 5 9 2" ].parse.expand.solve == 4 );
	assert( [ "10", "0 1 2 3 4 5 6 7 8 9" ].parse.expand.solve == 3 );
	assert( [ "1", "99999" ].parse.expand.solve == 1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	as.sort();
	as = -100 ~ as ~ -100;
	
	auto r = 0L;
	auto gs = as.group.array;
	foreach( i; 1 .. gs.length - 1 )
	{
		auto sa = gs[ i ][ 1 ];
		auto sb = ( gs[ i - 1 ][ 0 ] == gs[ i ][ 0 ] - 1 ) ? gs[ i - 1 ][ 1 ] : 0L;
		auto sc = ( gs[ i + 1 ][ 0 ] == gs[ i ][ 0 ] + 1 ) ? gs[ i + 1 ][ 1 ] : 0L;
		auto s = sa + sb + sc;
		if( r < s ) r = s;
	}
	
	return r;
}


Measured memory_bytes: 7088
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main () {
	const long long int llone = 1;
	long long int a, b;
	cin >> a >> b;
	b++;
	long long int res = 0;
	for (int i = 1; i <= 63; i++) {
		long long int ca = a / (llone << i) * (llone << (i - 1)) + (a % (llone << i) > (llone << (i - 1)) ? a % (llone << i) - (llone << (i - 1)) : 0);
		long long int cb = b / (llone << i) * (llone << (i - 1)) + (b % (llone << i) > (llone << (i - 1)) ? b % (llone << i) - (llone << (i - 1)) : 0);
		res += ((cb - ca) % 2) * ((long long int)1 << (i - 1));
		// cout << a / (llone << i) * (llone << (i - 1)) << " " << a % (llone << i) << " " << (llone << (i - 1)) << " ";
		// cout << cb << " " << ca << endl;
		// cout <<  ((long long int)1 << (i - 1)) << " ";
	}
	cout << res;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1

const int maxn = 1e5 + 7;

int a[maxn];

int main() {
    int h,b;
    while(cin >> h >> b) {
        int sum = 0;
        for(int i = 1 ; i <= b ; i++) {
            cin >> a[i];
            sum += a[i];
        }
        if(sum >= h) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


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


int main() {
    int a,b;
    cin >> a >> b;
    int ans = 0;
    rep(i,2){
        ans += max(a,b);
        if(a > b)a--;
        else b--;
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){
  long long int N;
  scanf("%lld", &N);

  std::cerr << "Answer:" << std::endl;
  std::cout << (N-1)/2 << std::endl;

  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int N;
    long long K;
    cin >> N >> K;
    long long A[N];
    long long maxa = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(maxa < A[i]) maxa = A[i];
    }
    int n = 1;
    int m = 1;
    while(1){
        if(K < (long long)1<<n) break;
        n++;
    }
    while(1){
        if(maxa < (long long)1<<m) break;
        m++;
    }
    long long x = 0;
    long long ans = 0;
    if(m > n){
        for(; m>n; m--){
            int num1 = 0;
            for(int i=0; i<N; i++){
                if(A[i] & (long long)1<<m-1) num1++;
            }
            ans += num1*((long long)1<<m-1);
        }
    }
    for(; n>0; n--){
        int num1 = 0;
        for(int i=0; i<N; i++){
            if(A[i] & (long long)1<<n-1) num1++;
        }
        if(num1 < N-num1 && x + ((long long)1<<n-1) <= K){
            x += (long long)1<<n-1;
            ans += (N-num1)*((long long)1<<n-1);
        }
        else ans += num1*((long long)1<<n-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

int sum(int a, int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int sub(int a, int b) {
    return a - b < 0 ? a - b + MOD : a - b;
}
int mul(int a, int b) {
    return (1LL*a*b)%MOD;
}
int pw(int a, int b) {
	if (!b) return 1;
	int r = pw(a, b/2);
	r = mul(r, r);
	if (b%2) r = mul(r, a);
	return r;
}

const int MAXN = 2e6+7;
int fact[MAXN], ifact[MAXN];

int nCr(int n, int r) {
    if (r < 0 || n < r) return 0;
    return mul(fact[n], mul(ifact[r], ifact[n-r]));
}

int palpha[MAXN];
int pbeta[MAXN];

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

    fact[0] = 1;
    for (int i = 1; i < MAXN; i++) fact[i] = mul(i, fact[i-1]);
    ifact[MAXN-1] = pw(fact[MAXN-1], MOD-2);
    for (int i = MAXN-2; i >= 0; i--) ifact[i] = mul(i+1, ifact[i+1]);

    palpha[0] = pbeta[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        palpha[i] = mul(26, palpha[i-1]);
        pbeta[i] = mul(25, pbeta[i-1]);
    }

    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;
    for (int bam = 0; bam <= k; bam++) {
        ans = sum(ans, mul(mul(nCr(bam+n-1, n-1), pbeta[bam]), palpha[k-bam]));
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 35512
// 6/18 振り返り
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) res.push_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

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

    ll ans = 0;

    // N-1の約数は全て条件を満たす。
    vector<ll> div1 = divisor(N - 1);
    ans += div1.size() - 1;  // 1の場合だけ引いておく。

    // Nの約数のうち、割れるだけ割った後にmod kが1だったらOK。
    vector<ll> div2 = divisor(N);
    for (auto d : div2) {
        if (d == 1) continue;

        ll n = N;
        while (n % d == 0) {
            n /= d;
        }

        if (n % d == 1) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
            sum+=i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3596
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

n_list = []
for i in range(1,n+1):
    n_list.append(i)
    
p_position = 0
for j in itertools.permutations(n_list, n):
    p_position += 1
    if tuple(p) != j:
        continue
    else:
        break

q_position = 0
for j in itertools.permutations(n_list, n):
    q_position += 1
    if tuple(q) != j:
        continue
    else:
        break
        
if p_position > q_position:
    print(p_position-q_position)
else:
    print(q_position-p_position)

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

int main() {
	int n;
	int t_score = 0, h_score = 0;
	string taro, hanako;
	bool is_draw;

	cin >> n;
	for (int i = 0; i < n; i++){
		is_draw = true;
		cin >> taro >> hanako;
		for (int j = 0; j < (taro.size() > hanako.size() ? hanako.size() : taro.size()); j++){
			if (taro[j] > hanako[j]) {
				t_score += 3; 
				is_draw = false;
				break;
			} else if (hanako[j] > taro[j]) { 
				h_score += 3;
				is_draw = false;
				break;
			}
		}
		if (is_draw && taro.size() == hanako.size()) {
			t_score++;
			h_score++;
		} else if (is_draw) {
			taro.size() > hanako.size() ? t_score += 3 : h_score += 3;
		}
	}
	
	cout << t_score << " " << h_score << endl;

	return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  bool state[11][11][11] = { };
  state[10][10][10] = true;
  for (int i = 0; i < n; i++) {
    int c = s.at(i) - '0';
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        state[j][k][c] = state[j][k][10];
      }
      state[j][c][10] = state[j][10][10];
    }
    state[c][10][10] = true;
  }
  int count = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        if (state[i][j][k]) count++;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

map<ll,ll> M;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll N,m;
  COMinit();
  cin >> N >> m;
  Rep(i,2,sqrt(m)+1){
    while(m%i==0){
      M[i]++;
      m/=i;
    }
  }
  if(m>1){
    M[m]++;
  }
  ll ans=1;
  for(auto P : M){
    ans*=COM(N+P.sc-1,P.sc);
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

const ll MOD = (ll)(1e9) + (ll)7;
int N, K;
vector<ll> S;

void input_init(void) {
	cin >> N >> K;
	S.resize(N + 1, (ll)0);
	for (int i = 1; i <= N; ++i)
		S[i] = S[i - 1] + (ll)i;
}

ll solve(void) {
	ll cnt = (ll)0;
	for (int i = K; i <= N + 1; ++i) {
		ll min_v = S[i - 1];
		int id = max(N + 1 - i - 1, 0);
		ll max_v = S[N] - S[id];
		ll d = max_v - min_v + 1;
		d %= MOD;
		cnt += d;
		cnt %= MOD;
	}
	return cnt;
}

int main(void) {
	input_init();
	ll ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	string x;
	int ans = 0;
	cin >> n >> x;
	int pop = 0;
	for (char i: x) {
		pop += (i == '1');
	}
	ll up = 0LL, down = 0LL;
	VV tri(n, V(2, 0LL));  // pop+1, pop-1
	tri[n - 1][0] = 1LL % (pop + 1);
	if (pop >= 2) {
		tri[n - 1][1] = 1LL % (pop - 1);
	} else {
		tri[n - 1][1] = INFLL;
	}
	rrep(i, n) {
		if (i != n - 1) {
			tri[i][0] = tri[i + 1][0] * 2;
			tri[i][0] %= (pop + 1);
		}
		if (x[i] == '1') {
			up += tri[i][0];
			up %= (pop + 1);
		}
	}
	if (pop >= 2) {
		rrep(i, n) {
			if (i != n - 1) {
				tri[i][1] = tri[i + 1][1] * 2;
				tri[i][1] %= (pop - 1);
			}
			if (x[i] == '1') {
				down += tri[i][1];
				down %= (pop - 1);
			}
		}
	} else {
		down = INFLL;
	}
	//clog << tri << endl;
	ll at     = 0LL;
	int count = 0LL;
	bool zero;
	//clog << up << " " << down << endl;
	rep(i, n) {
		count = 0;
		zero = (x[i] == '1');
		if (zero) {
			at = down;
		} else {
			at = up;
		}
	//	clog << at << endl;
		if (at == INFLL) {
			cout << 0 << endl;
			continue;
		}
		//clog << solve(zero) << endl;
		if (zero) {
			at -=tri[i][1];
		} else {
			at += tri[i][0];
		}
	//	clog << at << endl;
		at %= (pop + 1 - zero*2);
		at += pop + 1 - zero*2;
		at %= (pop + 1 - zero*2);
		count++;
	//	clog << at << endl;
		while (at != 0) {
			at %= __builtin_popcount(at);
			count++;
		//	clog << at << endl;
		}
	//	clog << "!";
		cout << count << endl;
	}
}

Measured memory_bytes: 14428
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int n, h[100010], memo[100010];

int dp(int pos) {
	int ret;
	if (pos == n)
		return 0;
	if (memo[pos] != -1)
		return memo[pos];
	ret = dp(pos + 1) + abs(h[pos + 1] - h[pos]);
	if (pos + 2 <= n)
		ret = min(ret, dp(pos + 2) + abs(h[pos + 2] - h[pos]));
	memo[pos] = ret;
	return ret;
}

int main() {
	int ans;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &h[i]);
	memset(memo, -1, sizeof memo);
	ans = dp(1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(int argc, char const *argv[]) {
    long long int a,b,x,cnt=0;
    cin>>a>>b>>x;
    if(a%x==0) cnt++;
    a=a/x;
    b=b/x;
    cnt+=b-a;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
sList = list(map(int, input().split()))

lCnt = 0
rCnt = 0
for i in sList:
    if X < i:
        lCnt += 1
    elif X > i:
        rCnt += 1

ans = min(lCnt, rCnt)
print(ans)

Measured memory_bytes: 3060
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans = 0
for i in range(N-1):
    if a[i] > x:
        break
    else:
        x -= a[i]
        ans += 1

if x == a[-1]:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<int> v(n),wow(n,0);
    for(int i=0;i<n;i++)cin>>v[i];
    int sum=0;
    for(int i=1;i<n-1;i++){
        if(v[i]>v[i-1]&&v[i]<v[i+1])sum++;
      else  if(v[i]<v[i-1]&&v[i]>v[i+1])sum++;

    }
    cout<<sum;
}

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

#define PI 3.14159265358979323846264338327950L
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll sum = 0;
    for (ll i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << "\n";



}


Measured memory_bytes: 3564
#include<stdio.h>
#include<string.h>
 
int main() {
    char w[11], t[1001];
    int cnt = 0;
    int i = 0;
    scanf("%s", w);
    for(i=0; w[i]!='\0'; i++) {
        if('A' <= w[i] && w[i] <= 'Z') {
            w[i] += 'a' - 'A';
        }
    }
    while(1) {
        scanf("%s", t);
        if( !strcmp("END_OF_TEXT", t) ) break; 
        for(i=0; t[i]!='\0'; i++) {
            if('A' <= t[i] && t[i] <= 'Z') {
                t[i] += 'a' - 'A';
            }
        }
        if( !strcmp(w, t) ) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i=0;i<s.size()-8;i++){
        cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args : Array<String>) {
    val scan = Scanner(System.`in`)

    var s = scan.next()
    val q = Integer.parseInt(scan.next())

    var rvFlag = false

    val front = mutableListOf<String>()
    val end = mutableListOf<String>()

    repeat(q) {
        val q1 = Integer.parseInt(scan.next())

        if (q1 == 1) {
            rvFlag = !rvFlag
        } else {
            val q2 = Integer.parseInt(scan.next())
            val c = scan.next()

            if (rvFlag) {
                if (q2 == 1) {
                    end.add(c)
                } else {
                    front.add(c)
                }
            } else {
                if (q2 == 1) {
                    front.add(c)
                } else {
                    end.add(c)
                }
            }
        }
    }

    s = front.reversed().joinToString(separator = "") + s + end.joinToString(separator = "")

    if (rvFlag) {
        println(s.reversed())
    } else {
        println(s)
    }
}

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



 int main(){
    long long n;
    cin>>n;
   long long x;
   cin>>x;
  for(long long i=1;i<=x;i++){
      if((n*i)%x == 0){
          cout<<n*i;
          break;
      }
  }

     

       
 }

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> H(N);
  vector<int> Ans(N);
  rep(i,N){cin>>H.at(i);
          Ans.at(i)=1;}
  
  int A,B;
  rep(i,M){cin>>A>>B;
          if(H.at(A-1)>H.at(B-1)){Ans.at(B-1)=0;}
           else if(H.at(A-1)<H.at(B-1)){Ans.at(A-1)=0;}
           else{Ans.at(A-1)=0;Ans.at(B-1)=0;}
          }
  int SUM=0;
  rep(i,N){SUM+=Ans.at(i);}
  cout<<SUM<<endl;
}

Measured memory_bytes: 4056
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// [0,n) ???????????? i ???????????????primes[i] != 0 ??? i ????´???°
vector<int> erat(int n) {
    vector<int> primes(n);
    for (int i = 2; i < n; ++i) primes[i] = i;
    for (int i = 2; i*i < n; ++i)
        if (primes[i])
            for (int j = i*i; j < n; j+=i) primes[j] = 0;
    // ?´???°?????????vector???????´?????????´????????\?????????????????? (0 ??§??????????´??????¨??????)
    primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}

signed main() {
    int n, p;
    vector<int> primes = erat(1000000);
    while(cin >> n >> p) {
        if(n == -1 && p == -1) break;

        int st = upper_bound(primes.begin(), primes.end(), n) - primes.begin();

        vector<int> v;
        rep(i,st,st+110) {
            rep(j,i,st+110) {
                v.pb(primes[i] + primes[j]);
            }
        }
        sort(v.begin(), v.end());
        cout << v[p-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 10508
/* 
  問題:
    - H×Wのマス目が与えられる
    - 入力において、全てのマスは文字で表されており、'o'は空きマス、'#'は爆弾マスに対応する
    - マス目は H個の文字列 S_1...S_H で表現される
    - 文字列 S_iの j文字目は、マス目の上から i番目、左から j番目のマスに対応
    - 各空きマスに対応する'o'を、その空きマスの周囲8方向に隣接するマスにおける爆弾マス'#'の個数を表す数字で置き換える
    - 上記規則で置き換えられた後のマス目を出力
  入力:
    ```
    <H> <W>
    <S_1> # 1行目のマスを表す文字列（文字数: W）
     :    # H回繰り返し
    <S_H> # H行目のマスを表す文字列（文字数: W）
    ```
  例:
    - 入力:
      ```
      3 5
      ooooo
      oxoxo
      ooooo
      ```
    - 出力:
      ```
      11211
      1x2x1
      11211
      ```
 */
#include <bits/stdc++.h>
using namespace std;

/*
  設計: 2次元データを1次元に変換
    - 入力:
      ```
      3 5
      ooooo
      oxoxo
      ooooo
      ```
    - 変換:
      ```
      index:  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
      string: o o o o o o x o x o o  o  o  o  o
      ```
    - 周辺8方向:
      - 左: index - 1 (>= 0 && index%W != 0)
      - 右: index + 1 (< H*W && index%W != W-1)
      - 上: index - W (>= 0 && index >= W)
      - 下: index + W (< H*W && index < W*(H-1))
      - 左上: index - W - 1 (>= 0 && index%W != 0 && index >= W)
      - 右上: index - W + 1 (>= 0 && index%W != W-1 && index >= W)
      - 左下: index + W - 1 (< H*W && index%W != 0 && index < W*(H-1))
      - 右下: index + W + 1 (< H*W && index%W != W-1 && index < W*(H-1))
 */

// index番目の文字の周辺8文字にある'#'の数を数える関数
int countBomb(const string &map, int index, int H, int W) {
  int i, count = 0;
  // 左のマス: (存在する AND 右端ではない) ならそのマスを見る
  i = index - 1;
  if (i >= 0 && i % W != W - 1 && map.at(i) == '#') count++;
  // 右のマス: (存在する AND 左端ではない) ならそのマスを見る
  i = index + 1;
  if (i < H*W && i % W != 0 && map.at(i) == '#') count++;
  // 上のマス: (存在する) ならそのマスを見る
  i = index - W;
  if (i >= 0 && map.at(i) == '#') count++;
  // 下のマス: (存在する) ならそのマスを見る
  i = index + W;
  if (i < H*W && map.at(i) == '#') count++;
  // 左上のマス: (存在する AND 右端ではない) ならそのマスを見る
  i = index - W - 1;
  if (i >= 0 && i % W != W - 1 && map.at(i) == '#') count++;
  // 左下のマス: (存在する AND 右端ではない) ならそのマスを見る
  i = index + W - 1;
  if (i < H*W && i % W != W - 1 && map.at(i) == '#') count++;
  // 右上のマス: (存在する AND 左端ではない) ならそのマスを見る
  i = index - W + 1;
  if (i >= 0 && i % W != 0 && map.at(i) == '#') count++;
  // 左下のマス: (存在する AND 左端ではない) ならそのマスを見る
  i = index + W + 1;
  if (i < H*W && i % W != 0 && map.at(i) == '#') count++;
  return count;
}

int main() {
  int H, W;
  string map;
  // 入力 => 2次元のマス目 => 1次元の文字列に変換
  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    string line;
    cin >> line;
    map += line;
  }
  // 出力
  // 各マス（文字）について周辺8マスの爆弾の数を数える
  for (int i = 0; i < H * W; ++i) {
    if (map.at(i) == '#') {
      // 自身が爆弾ならそのまま出力
      cout << '#';
    } else{
      // 周辺8マスの爆弾の数を出力
      cout << countBomb(map, i, H, W);
    }
    // 右端になったら（i % W == W - 1）改行
    if (i % W == W - 1) {
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int a[100005];
int cmp(const void*a,const void*b)
{
    return (*(int *)a-*(int *)b);
}
int main()
{
    int n,k,i,j;
    int count=0;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    qsort(a,n,sizeof(a[0]),cmp);
    for(i=0;i<n;)
    {
       for(j=i+1;j<i+k&&j<n;j++)
            a[j]=a[i];
            i+=(k-1);
            count++;
            if(i==n-1)
                break;
    }
    printf("%d",count);
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int now = 1;
    int kudaita = 0;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        if(tmp == now) now ++;
        else kudaita ++;
    }
    if(kudaita == N) cout << -1 << endl;
    else cout << kudaita << endl;
}

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

int N, A[MAXN + 3], cnt[MAXN + 3];
LL allWays;

LL C2(int n) {
    return ((LL) n * n - n)/2;
}

int main() {
    cin >> N;

    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= N; i++) {
        cin >> A[i];

        cnt[A[i]] += 1;
    }

    allWays = 0;
    for (int i = 1; i <= MAXN; i++) allWays += C2(cnt[i]);

    for (int k = 1; k <= N; k++) {
        cout << allWays - C2(cnt[A[k]]) + C2(cnt[A[k]] - 1) << endl;
    }
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,k;cin>>h>>w>>k;
    int h0,w0;
    vector<string> s(h);
    rep(i,h){cin>>s[i];}
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='S'){
                h0=i;
                w0=j;
            }
        }
    }
    queue<pair<int,int>> que;
    vector<vector<bool>> check(h,vector<bool>(w,false));
    int d = h0;
    chmin(d, w0);
    chmin(d, w-1-w0);
    chmin(d,h-1-h0);
    que.emplace(h0,w0);
    while(!que.empty()){
        auto now = que.front();
        int x = now.first,y=now.second;
        DEBUG{
            cout << x << " " << y << " " << endl;
        }
        que.pop();
        for(int i=-1;i<=1;i+=2){
            if(x+i>=0&&x+i<h&&s[x+i][y]=='.'
                &&!check[x+i][y]&&abs(h0-x-i)+abs(w0-y)<=k){
                check[x+i][y]=true;
                que.emplace(x+i,y);
                chmin(d,x+i);
                chmin(d,y);
                chmin(d,h-1-x-i);
                chmin(d,w-1-y);
            }
            if(y+i>=0&&y+i<w&&s[x][y+i]=='.'
                &&!check[x][y+i]&&abs(h0-x)+abs(w0-y-i)<=k){
                check[x][y+i]=true;
                que.emplace(x,y+i);
                chmin(d,x);
                chmin(d,y+i);
                chmin(d,h-1-x);
                chmin(d,w-1-y-i);
            }
        }
    }
    if(d==0){
        cout << 1 << endl;
        return 0;
    }
    ll res = 1;
    res += (d-1)/k+1;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
l = [input() for i in range(N)]
print("AC x {0}".format(l.count('AC')))
print("WA x {0}".format(l.count('WA')))
print("TLE x {0}".format(l.count('TLE')))
print("RE x {0}".format(l.count('RE')))

Measured memory_bytes: 16300
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define PB push_back

int main(void) {
    int n, t, p_cost, p_time;
    vector<int> ret;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> t;
    REP(i, n) {
        cin >> p_cost >> p_time;
        if (p_time <= t) {
            ret.PB(p_cost);
        }
    }

    if (ret.size() == 0) {
        cout << "TLE" << "\n";
    } else {
        cout << *min_element(ret.begin(), ret.end()) << "\n";
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int m[22][22];
bool went[(1<<21)];
int gone[(1<<21)];
int n;
int go(int a,int j)
{
	if(a==n)
	{
		return 1;
	}
	if(went[j])
	{
		return gone[j];
	}
	went[j]=1;
	int mx=0;
	for(int i=0;i<n;i++)
	{
		if((j&(1<<i))==0)
		{
			double mx1=m[a][i]*go(a+1,j|(1<<i))%1000000007;
			mx+=mx1;
			mx%=1000000007;
		}
	}
	return gone[j]=mx%1000000007;
}
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
	{
		cin>>m[i][j];
	}
}
cout<<go(0,0)<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/

Measured memory_bytes: 10496
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    vector<string> W(N);

    rep(i, N) cin >> W[i];

    vector<int> L(N);

    rep(i, N) L[i] = W[i].size();

    for (int i = 0; i < N-1; ++i) {
        for (int j = i+1; j < N; ++j) {
            if(W[i]==W[j]) { cout << "No" << endl; goto xyz; }
        }
    }

    for (int i = 0; i < N-1; ++i) {
        if (W[i][L[i] - 1] != W[i + 1][0]) { cout << "No" << endl; goto xyz; }
    }

    cout << "Yes" << endl;

xyz:;
}

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

#define fi first
#define se second
#define ll long long

const int N = 100100;
const long long mod = 1e9 + 7;

using namespace std;

int n;
long long m;
long long d[N];
long long res[N];
vector < int > v[N];

void dfs(int x, int p = -1)
{
        d[x] = 1;
        for(int y: v[x]){
                if(y == p){
                        continue;
                }
                dfs(y, x);
                d[x] = d[x] * d[y] % m;
        }
        d[x] = (d[x] + 1) % m;
}

void solve(int x, long long u, int p = -1)
{
        vector < long long > g;
        for(int y: v[x]){
                if(y == p){
                        continue;
                }
                g.push_back(d[y]);
        }
        g.push_back(1);
        reverse(g.begin(), g.end());
        for(int i = 1; i < g.size(); i++){
                g[i] = g[i - 1] * g[i] % m;
        }
        res[x] = (d[x] - 1) * u % m;
        if(res[x] < 0){
                res[x] += m;
        }
        long long l = 1;
        for(int y: v[x]){
                if(y == p){
                        continue;
                }
                g.pop_back();
                long long nu = u * l % m;
                nu = nu * g.back() % m;
                nu = (nu + 1) % m;
                l = l * d[y] % m;
                solve(y, nu, x);
        }

}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n >> m;
        for(int i = 1; i < n; i++){
                int x, y;
                cin >> x >> y;
                v[x].push_back(y);
                v[y].push_back(x);
        }
        dfs(1);
        solve(1, 1);
        for(int i = 1; i <= n; i++){
                cout << res[i] << "\n";
        }
}


Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(){
    ll N,K;
    cin>>N>>K;
    ll ans=0ll,st=0ll,ed=0ll;
    for (ll i = 1ll; i <= N+1; ++i) {
        st+=i-1;
        ed+=N+1-i;
        //cout<<i<<":"<<st<<" "<<ed<<endl;
        if(i>=K) (ans+=ed-st+1)%=MOD;
    }
    cout<<ans<<endl;
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    sort(all(A));
    sort(all(B));
    sort(all(C));
    vector<int> numAs_vs_B(N);
    vector<int> numBs_vs_C(N);
    rep(i,0,N) {
        numAs_vs_B[i] = lower_bound(all(A),B[i]) - A.begin();
        numBs_vs_C[i] = lower_bound(all(B),C[i]) - B.begin();
    }
    vector<ll> sum_nAvB(N);
    ll tmp = 0;
    rep(i,0,N) {
        tmp += numAs_vs_B[i];
        sum_nAvB[i] = tmp;
    }
    ll ans = 0;
    rep(i,0,N) {
        ans += numBs_vs_C[i] > 0 ? sum_nAvB[numBs_vs_C[i]-1] : 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long H, long long W, long long h, long long w){
    cout << H*W - (h * W) - (w * (H - h)) << "\n";
}

int main(){

    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}



Measured memory_bytes: 256