akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
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; }
inline ll pow2(const int n) { return 1ll << n; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

int collatz(int x){
    return x % 2 ? 3 * x + 1 : x / 2;
}

int s;
set<int> memo;

int main() {
    cin >> s;
    memo.insert(s);
    
    int ans;
    for (int i = 2, a = s; ; ++i){
        a = collatz(a);
        auto it = memo.find(a);
        if (it != memo.end()){
            ans = i;
            break;
        }
        else {
            memo.insert(a);
        }
    }
    write(ans);
}

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

using namespace std;

int main(void) {
	int N,D;
	cin >> N >> D;
	vector< vector<int> > p(N,vector<int>(D));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < D; ++j) {
			cin >> p[i][j];
		}
	}
	int res = 0;
	for (int i = 0; i < N-1; ++i) {
		for (int j = i+1; j < N; ++j) {
			int sum = 0;
			for (int k = 0; k < D; ++k) {
				sum += pow(abs(p[i][k]-p[j][k]),2);
			}
			if (sqrt(sum) == (int)sqrt(sum)) {
				++res;
			}
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;
using ll = long long;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll  group = n/(a+b);
    ll total =  group*a ;  
    total += min ( n%(a+b) , a );
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    srand((unsigned)time(NULL));
    lint N;
    cin >> N;
    lint A[N],B[N];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    lint cnta[N+1]={};
    lint cntb[N+1]={};
    rep(i,N) cnta[A[i]]++;
    rep(i,N) cntb[B[i]]++;
    multiset<lint> nums;
    rep(i,N) nums.insert(B[i]);
    bool chk=true;
    lint half=N/2+1;
    lint maxi=0;
    lint mst=0;
    rep(i,N+1){
        if(cnta[i]+cntb[i]>N) chk=false;
        if(maxi<cnta[i]+cntb[i]) mst=i;
        maxi=max(maxi,cnta[i]+cntb[i]);
    }
    if(!chk) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        lint ans[N];
        rep(i,N) ans[i]=B[i];
        queue<int> same;
        rep(i,N) if(A[i]==ans[i]) same.push(i);
        while(!same.empty()){
            int now=same.front();
            same.pop();
            int to=rand()%N;
            if(A[now]!=ans[to] && A[to]!=ans[now]) swap(ans[now],ans[to]);
            else same.push(now);
        }
        rep(i,N) cout << ans[i] << " ";
        cout << endl;
    }
}


Measured memory_bytes: 21564
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
    ll a;
    cin >> a;
    ll b = a;
    ll sn = 0;
    while (b >= 10) {
        sn += b % 10;
        b /= 10;
    }
    sn += b;
    if (a % sn) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll sumA = 0, sumB = 0, bCnt = 0, aCnt = 0;
    rep(i,n){
        sumA += a[i];
        sumB += b[i];
        if (a[i] > b[i]) bCnt += a[i] - b[i];
        else if (a[i] < b[i]) aCnt += ceil(((double)b[i]- a[i]) / 2);
    } 
    if (sumA > sumB){
        cout << "No" << endl;
    }
    else if (sumB - sumA >= bCnt && sumB - sumA >= aCnt){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3792
from operator import itemgetter

n, m = map(int, input().split())
money = 0
li = [list(map(int, input().split())) for _ in range(n)]
li.sort(key=itemgetter(0))

for j in range(n):
    shop = li.pop(0)
    if m < shop[1]:
        money += m * shop[0]
        break
    money += shop[0] * shop[1]
    m -= shop[1]

print(money)



Measured memory_bytes: 28968
#include <stdio.h>
#include <stdbool.h>

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

typedef struct{
    int y;
    int x;
} pos_t;

char a[512*512];
char out[8*1024*1024];

inline static int s(int y, int x, int w){
    if(y%2==0){
        return y*w+x;
    }else{
        return y*w+(w-1-x);
    }
}

inline static pos_t xy(int n, int w){
    int q = n/w;
    int r = n%w;
    pos_t t;
    t.y = q+1;
    if(q%2==0){
        t.x = r+1;
    }else{
        t.x = w-r;
    }
    return t;
}

int main(void){
    int h=gl(), w=gl();
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int t=getchar_unlocked()-48;
            a[s(i,j,w)] = t;
            getchar_unlocked();
        }
    }
    bool haveCoin = false;
    int count = 0;
    size_t pos = 0;
    for(int i=0; i<h*w-1; i++){
        if(a[i]%2==1){
            haveCoin = !haveCoin;
        }
        if(haveCoin){
            const pos_t p=xy(i, w);
            const pos_t q=xy(i+1, w);
            size_t len = sprintf(out+pos, "%d %d %d %d\n", p.y, p.x, q.y, q.x);
            pos += len;
            count++;
        }
    }
    printf("%d\n", count);
    fputs(out, stdout);
    return 0;
}


Measured memory_bytes: 6144
d=int(input())
c = list(map(int,input().split()))

s=[None]*d
for i in range(d):
    s[i] = list(map(int,input().split()))
t=[0]*d
for i in range(d):
    t[i]=int(input())

last=[0]*26
satis=0
pena=0
for j in range(d):
    ss=s[j]
    tt=t[j]
    satis += ss[tt-1]
    
    last[tt-1]=j+1
    
    pena += sum(c[i]*(j+1-last[i]) for i in range(26))
    print(satis-pena)

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

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

    int N, A;
    cin >> N >> A;
    cout << N*N-A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N],k,vis[N];
int main()
{
	int x,num=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x),a[x]++;
		if(!vis[x])
			vis[x]=1,num++;
	}
	if(num<=k)
		cout<<0<<endl;
	else
	{
		num-=k;
		sort(a+1,a+N);
		int i;
		for(i=1;i<N;i++)
			if(a[i])
				break;
		int ans=0;
		for(int x=i;x<N&&num;x++,num--)
			ans+=a[x];
		cout<<ans<<endl;
	}
	
	return 0;	
} 

Measured memory_bytes: 1792
n, t = list(map(int, input().split(' ')))

cs = []; ts = []
for i in range(n):
    cc, tt = list(map(int, input().split(' ')))
    cs.append(cc)
    ts.append(tt)

minc = -1
for i in range(n):
    if ts[i] <= t:
        if minc < 0 or minc > cs[i]:
            minc = cs[i]

if minc < 0:
    print("TLE")
else:
    print(minc)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int32_t main()
{
    FastIO;
    int n,t=0;
    cin>>n;
    int a[n],s=0,ans=INT_MAX;
    for(int i=0;i<n;++i)
    {
      cin>>a[i];
      s+=a[i];
    }
    //sort(a,a+n);
    for(int i=0;i<n-1;++i)
    {
      t+=a[i];
      s-=a[i];
      ans=min(ans,abs(s-t));
    }
    cout<<ans<<endl;


}

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

int main(void) {
	int A, B;
	scanf("%d%d", &A, &B);
	int card[13];
	for (int i = 0; i < 12; i++) {
		card[i] = i + 2;
	}
	card[12] = 1;
	int a, b;
	for (int i = 0; i < 13; i++) {
		if (card[i] == A) a = i;
		if (card[i] == B) b = i;
	}

	if (a > b) {
		printf("Alice\n");
	} else if (a < b) {
		printf("Bob\n");
	} else {
		printf("Draw\n");
	}
	return 0;
}


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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    ll cnt = 0;
    for(int i = 1; i <= n; i++){
        ll x;
        cin >> x;
        cnt ^= x;
    }
    if(cnt == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
n, k = map(int,input().split())
gates = [0]*(n+1)
for i in range(k):
  l,r = map(int,input().split())
  gates[l-1] += 1
  gates[r] -= 1
print(np.count_nonzero(np.cumsum(gates) == k))


Measured memory_bytes: 29300
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll a=in(),v=in(),b=in(),w=in(),t=in();
    cout<<(t*(v-w)<abs(a-b)?"NO":"YES")<<endl;
}



Measured memory_bytes: 3612
#include<iostream>
#include<vector>
using namespace std;
const int MAX_T = 3000, MAX_M=300;
int M, start, goal,dice[6], *N;
 
bool isPositionValid(int p){return 0<=p && p<M;}
 
int* MakePath(int *path, int from){
    static vector<bool> visit(MAX_M);
    static auto checkPath = [&path](int moveto)->int{
        if(!isPositionValid(moveto))	return 2*MAX_T;
        else{
            int position = moveto+ N[moveto];
            if(!visit[position]) MakePath(path, position);
            return  path[position]+1;
        }
    };
 
    if(path==NULL){
        path = new int[M];
        for(int m=0; m<M; m++) path[m] = MAX_T+1;
    }
 
    visit[from] = true;
    int bestpath = MAX_T;
    if(from==goal)  bestpath = 0;
    else{
        for(int d : dice){
            bestpath = min(bestpath, checkPath(from + d));
            bestpath = min(bestpath, checkPath(from - d));
        }
    }
    path[from] = bestpath;
    return path;
}
 
int main(){
    // 入力
    cin >> M;
    for(int r=0; r<6; r++)   cin >> dice[r];
    cin >> start >> goal;
	start--, goal--;
	N = new int[M];
    for(int m=0; m<M; m++)   cin >> N[m];
	
	// 最短経路の探索
    int* path = MakePath(NULL, start);
     
    // 本番
    int position = start;
    for(int t=0; t<MAX_T; t++){
        if(position == goal) break;
     
        int r;
        cin >> r;
        int d = dice[r-1];
 
        static auto tryMove = [&path](int moveto, int& position)->bool{
			if(isPositionValid(moveto)){
				int new_position = moveto + N[moveto];
                if(path[position] > path[new_position]){
					position = new_position;
					return true;
				}
			}
            return false;
        };
     
		int output;
        if     (tryMove(position + d, position)) output = 1;
		else if(tryMove(position - d, position)) output = -1;
		else output = 0;
		cout << output << endl;
    }
 
    delete[] N;
    delete[] path;
    return 0;
}

Measured memory_bytes: 1304
//                                               KEEP GRINDING
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<"\n========================================\n";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define PQ priority_queue
#define mx(a) *max_element(a)
#define mn(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 

#define fr first
#define sc second

#define MAXN 2000100
#define INF 9223372036854775807
void solve(){
	int n,ans=0;
	cin>>n;
	f(i,1,n+1){
		for(int j=i;j<=n;j+=i){
			ans+=j;
		}
	}
	cout<<ans;
}
signed main(){
    fastio
    int t=1;
    for(;t--;solve());
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

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

Measured memory_bytes: 256
//
//  main.cpp
//  Pana2020D
//
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
    int N;
void dfs(string s,int mx){
    if (s.size()==N) {
        cout<<s<<endl;
        return;
    }
    for (int c='a'; c<=mx+1; c++) {
        string t=s;
        t+=c;
        dfs(t, max(mx,c));
    }
}
int main(int argc, const char * argv[]) {

    cin>>N;
    dfs("",'a'-1);
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
typedef pair<int,int> pii;
typedef long long ll;
template<typename A,size_t N,typename T>
void Fill(A (&array)[N],const T &val)
{
    std::fill( (T*)array,(T*)(array+N),val );
}

ll gcd(ll a, ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}

int main(void)
{
    int A,B;
    cin >> A >> B;
    for(double i=1.0;i<=1250.0;i+=1.0)
    {
        //cout << i*0.08 << ' ' << i*0.1 << endl;
        if(floor(i*0.08)==A && floor(i*0.1)==B)
        {
            cout << floor(i) << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int main(){
  int N,W;
  cin >> N >> W;
  long long weight[N],value[N];
  for(int i=0;i<N;i++){
    cin >> weight[i] >> value[i];
  }
  long long dp[110][100100];
  for(int i=0;i<110;i++){
    for(int j=0;j<100100;j++){
      dp[i][j] = 1LL<<60;
    }
  }
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<100100;j++){
      if(j>=value[i]){
        dp[i+1][j]=min(dp[i][j-value[i]]+weight[i],dp[i][j]);
      }
      else{
        dp[i+1][j]=dp[i][j];
      }
    }
  }
  long long a=0;
  for(int j=0;j<100100;j++){
      if(dp[N][j]<=W){
        a = j;
    }
  }
  cout << a;
}
  

Measured memory_bytes: 86272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20192abc2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');

            int[] TA = new int[N];
            int maxTA = 0;
            int totTA = 0;

            for(int i = 0; i < N; i++)
            {
                TA[i] = int.Parse(s[i]);
                maxTA = Math.Max(TA[i], maxTA);
                totTA += TA[i];
            }

            if(maxTA < totTA - maxTA)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int coin[6] = {500,100,50,10,5,1};

int main(){
  int n;
  while(cin >> n,n){
    n = 1000-n;
    int pos = 0, ans = 0;
    while(n){
      if(n>=coin[pos]){
	n -= coin[pos];
	ans++;
      }else{
	pos++;
      }
    }
    cout << ans << endl;
  }
}
      

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

using namespace std;

int main() {
  char c;
  cin >> c;
  unordered_set<char> S = {'a', 'e', 'i', 'o', 'u'};
  if (S.count(c)) {
    cout << "vowel";
  } else {
    cout << "consonant";
  }
  return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    int n;
    cin >> n;
    map<string, int> vis;
    string s;
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        sort(s.begin(), s.end());
        if (vis.count(s)) res+=vis[s], vis[s]++;
        else vis[s] = 1;
    }
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 11264
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

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

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

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

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

func main() {
	defer stdout.Flush()
	n := readInt64()
	m := readInt64()
	d := readInt64()

	x := 2 * (n - d)
	if d == 0 {
		x = n - d
	}

	println(float64(x) / float64(n) / float64(n) * float64(m-1))
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c;
  cin>>a>>b>>c;
  int cnt = 0;
  while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0 && cnt <= 100) {
    int ta = a, tb = b, tc = c;
    a = (tb + tc) / 2;
    b = (ta + tc) / 2;
    c = (tb + ta) / 2;
    cnt++;
  }
  if(cnt > 70) cnt = -1;
  cout << cnt << endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


int main(){
  int a[32];
  a[0] = 1;
  a[1] = 1;
  a[2] = 1;
  a[3] = 2;
  a[4] = 1, 
  a[5] = 2, 
  a[6] = 1, 
  a[7] = 5, 
  a[8] = 2, 
  a[9] = 2, 
  a[10] = 1, 
  a[11] = 5,
  a[12] = 1 ,  
  a[13] = 2, 
  a[14] = 1,
    a[15] = 14, 
    a[16] = 1, 
    a[17] = 5, 
    a[18] = 1, 
    a[19] = 5, 
  a[20] = 2, 
  a[21] = 2, 
  a[22] = 1, 
  a[23] = 15, 
  a[24] = 2, 
  a[25] = 2, 
  a[26] = 5, 
  a[27] = 4, 
  a[28] = 1, 
  a[29] = 4, 
  a[30] = 1, 
  a[31] = 51;
  int k; cin >> k; k--;
  cout << a[k] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, M;
int D[1010];
int C[1010];
int dp[1010][1010];


signed main(){
    cin >> N >> M;
    rep(i, 0, N) cin >> D[i];
    rep(i, 0, M) cin >> C[i];

    rep(i, 1, N+1) fill(dp[i], dp[i]+M+1, INF32);
    rep(i, 0, N) rep(j, 0, M) dp[i+1][j+1] = min(dp[i+1][j], dp[i][j]+D[i]*C[j]);

    cout << *min_element(dp[N], dp[N]+M+1) << endl;

    return 0;
}


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

int main(int argc, char *argv[])
{
  int n, k;
  string s;
  cin >> n >> k >> s;
  s[k-1] = tolower(s[k-1]);
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
// Aizu 2218: K Poker
// 2017.9.23 bal4u@uu
// ?????????????????????????????\????????????????????????????????????????????????

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int d, s; } T;	// ??????????????± d:?????° s:?????????
T card[5];
int base[4][14];	// ?????¬???????????±
int rate[9];		// ??????????????±

int dcnt[14];		// ????????°????????????????????????
int scnt[4];		// ????????????????????????????????????
int tr['Z'];		// ????????¨

int cmp(T *a, T *b) { return a->d - b->d; }

int calc()
{
	int i, f, ans = 0;

	// ?????¬???
	for (i = 0; i < 5; i++)	ans += base[card[i].s][card[i].d];

	// ????????????????????¬????????????????????\
	if (card[0].d == 1) {
		for (i = 1; ; i++) {
			if (i == 5) return ans * rate[8];
			if (card[i].s != card[0].s || card[i].d != 9+i) break;
		}
	}

	// ????????¬????????????????????\
//	if (card[0].d != 1) {
		for (i = 1; ; i++) {
			if (i == 5) return ans * rate[7];
			if (card[i].s != card[0].s || card[i].d != card[0].d+i) break;
		}
//	}

	// ??????????????????
	for (i = 1; i <= 13; i++) if (dcnt[i] == 4) return ans * rate[6];

	// ???????????????
	f = 0;
	for (i = 1; i <= 13; i++) {
		if      (dcnt[i] == 3) f |= 1;
		else if (dcnt[i] == 2) f |= 2;
	}
	if (f == 3) return ans * rate[5];

	// ??????????????\
	for (i = 0; i < 4; i++) if (scnt[i] == 5) return ans * rate[4];

	// ????????¬??????
	if (card[0].d == 1) {
		for (i = 1; ; i++) {
			if (i == 5) return ans * rate[3];
			if (card[i].d != 9+i) break;
		}
	}
//	else {
		for (i = 1; ; i++) {
			if (i == 5) return ans * rate[3];
			if (card[i].d != card[0].d+i) break;
		}
//	}

	// ??????????????????
	for (i = 1; i <= 13; i++) if (dcnt[i] == 3) return ans * rate[2];

	// ???????????¢ or ???????????¢
	f = 0;
	for (i = 1; i <= 13; i++) if (dcnt[i] == 2) f++;
	if (f == 2) return ans * rate[1];
	if (f == 1) return ans * rate[0];

	// ??????
	return 0;
}


int main()
{
	int n, i, j;
	char s[3];
	int cno = 0;

	tr['S'] = 0, tr['C'] = 1,  tr['H'] = 2,  tr['D'] = 3;
	for (i = 2; i <= 9; i++) tr[i+'0'] = i;
	tr['A'] = 1, tr['T'] = 10, tr['J'] = 11, tr['Q'] = 12, tr['K'] = 13;

	while (scanf("%d", &n) == 1) {
		if (cno++) putchar('\n');		// ???????????±??????????????????

		for (i = 0; i < 4; i++) for (j = 0; j < 13; j++) scanf("%d", &base[i][j+1]);
		for (i = 0; i < 9; i++) scanf("%d", rate+i);
		while (n-- > 0) {
			for (i = 0; i < 5; i++) {	// ??????????????±
				scanf("%s", s); 
				card[i].d = tr[s[0]], card[i].s = tr[s[1]];
			}
			for (i = 0; i < 4; i++) qsort(card, 5, sizeof(T), cmp);  // ?????°??§???????????????
			memset(dcnt, 0, sizeof(dcnt)), memset(scnt, 0, sizeof(scnt));
			for (i = 0; i < 5; i++) {
				dcnt[card[i].d]++;		// ???????????°????????°???????¨?
				scnt[card[i].s]++;		// ???????????????????????°???????¨?
			}
			printf("%d\n", calc());
		}
	}
	return 0;
}

Measured memory_bytes: 1740
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,A,B,C;
    cin >> a >> b >> c;
    if(b<a){
        A=b;
        b=a;
        a=A;
    }
    if(c<b){
        C=b;
        b=c;
        c=C;
    }
    if(b<a){
        A=b;
        b=a;
        a=A;
    }
    cout << a << " " << b << " " << c << endl;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> likeCount(M + 1);
    for(int i = 0; i < N; i++)
    {
        int K;
        cin >> K;
        for(int j = 0; j < K; j++)
        {
            int A;
            cin >> A;
            likeCount.at(A)++;
        }
    }
    ll answer = 0;
    for(int i = 1; i <= M; i++)
    {
        if(likeCount.at(i) == N)
        {
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		
		int price = 0;
		
		for(int i = 1; i <= n; i++){
			if(i <= k)price += x;
			else price += y;
		}
		System.out.print(price);
	}

}

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

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

    int m,n;
    cin>>n>>m;

    int ab,ac,ad;
    int bb,bc,bd;
    int ans;

    ac = 2;
    bc = 2;

    if(m == 1)
    {
        //bc = 1;
        ab = n * (n-1);
        ad = ab / ac;

        //bb = m * (m-1);
        bd = 0;

        ans = ad + bd;

        cout<<ans<<endl;
        return 0;
    }
    else if(n == 1)
    {
        //ac = 1;
        //ab = n * (n-1);
        ad = 0;

        bb = m * (m-1);
        bd = bb / bc;

        ans = ad + bd;

        cout<<ans<<endl;
        return 0;
    }
    else if(n == 1 && m && 1)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {

    ab = n * (n-1);
        ad = ab / ac;

        bb = m * (m-1);
        bd = bb / bc;

        ans = ad + bd;

        cout<<ans<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        list.add(sc.nextInt());
        list.add(sc.nextInt());
        list.add(sc.nextInt());

        Optional<Integer> s = list.stream().max(Comparator.naturalOrder());
        int r = list.stream().mapToInt(x -> x).sum();
        System.out.println(r - s.get());
    }
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int a, b, c, d, op1, op2, op3, ans;
    a = s.at(0) - '0';
    b = s.at(1) - '0';
    c = s.at(2) - '0';
    d = s.at(3) - '0';

    for(int in=0;in<8;in++) {
        ans = 0;
        op1 = in & 1;
        op2 = (in>>1) & 1;
        op3 = (in>>2) & 1;
        if(op1==1) ans += a + b;
        else ans += a - b;
        if(op2==1) ans += c;
        else ans -= c;
        if(op3==1) ans += d;
        else ans -= d;

        if(ans==7) {
            cout << a;
            if(op1==1) cout << "+";
            else cout << "-";
            cout << b;
            if(op2==1) cout << "+";
            else cout << "-";
            cout << c;
            if(op3==1) cout << "+";
            else cout << "-";
            cout << d;
            cout << "=" << 7 << endl;
            break;
        }
     }
    return 0;
}


Measured memory_bytes: 256
N = int(input())

def f(n):
    n = str(n)
    res = 0
    for i in range(len(n)):
        res += int(n[i])
    return res

ans = 1000000
for i in range(1, N//2+1):
    ans = min(ans, f(i)+f(N-i))
print(ans)

Measured memory_bytes: 9124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;

import java.util.Arrays;

public class Main {
		
	// ??????????????????????????????????????§?????¨??????????????°??? O(V*(V+E)) ??§?§£???
	// L <- ?????´?????????????????? : [0, L)
	public static int maximumBipartiteMatching(int L, ArrayList<HashSet<Integer>> adj){
		boolean[] visited = new boolean[adj.size()];
		int[] match = new int[adj.size()];
		Arrays.fill(match, -1);

		int count = 0;
		for(int curr = 0; curr < L; curr++){
			Arrays.fill(visited, false);

			if(augment(adj, curr, match, visited)){ count++; }
		}

		return count;
	}

	private static boolean augment(ArrayList<HashSet<Integer>> adj, int curr, int[] match, boolean[] visited) {
		if(curr < 0){return true; }

		for(final int next : adj.get(curr)) {
			if(visited[next]){ continue; }

			visited[next] = true;
			if(augment(adj, match[next], match, visited)) {
				match[curr] = next;
				match[next] = curr;
				return true;
			}
		}

		return false;
	}
		
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int X = sc.nextInt();
		final int Y = sc.nextInt();
		final int E = sc.nextInt();
		
		final int size = X + Y;
		ArrayList<HashSet<Integer>> adj = new ArrayList<HashSet<Integer>>();
		for(int i = 0; i < size; i++){ adj.add(new HashSet<Integer>()); }
		
		for(int i = 0; i < E; i++){
			final int x = sc.nextInt();
			final int y = sc.nextInt();
			
			adj.get(x).add(X + y);
		}
		
		System.out.println(maximumBipartiteMatching(X, adj));
	}
	
	public static class Scanner implements AutoCloseable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {tok = new StringTokenizer(br.readLine());}
			} catch(IOException e){ /* ignore */ }
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine(); return tok.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}
		// ??????nextXXX???XXX.parseXXX()????????????????????£?????????????????§?????\

		public void close() {
			try{ br.close(); } catch (IOException e){ /*ignore*/ }
		}
	}
}

Measured memory_bytes: 32320
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong(), K = sc.nextLong();
		long[] mon = new long[(int)N];
		for(int i = 0; i < N; i++) {
			mon[i] = sc.nextLong();
		}
		Arrays.sort(mon);
		if(N<=K) {
			System.out.println(0);
		}else {
			for(int j = (int)N-1; j >= N-K; j--) {
				mon[j] = 0;
			}
			long sum = Arrays.stream(mon).sum();
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 64972
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define si scanf
#define so printf
#define N 5100
#define M 
#define INF  
#define mod %P
#define nxt t[j]
template<typename TP>inline bool rd(TP& r)
{
	r=0;
	char tmp=getchar();
	while(tmp<'0'||tmp>'9')
	{
		if(tmp==EOF)
			return 0;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		r=(r<<3)+(r<<1)+tmp-'0';
		tmp=getchar();
	}
	return 1;
	
} 
long long P=1000000007;
int n;
long long ans; 
long long prdc[N];
bool vis[N][N];
long long c[N][N]; 
void pre()
{
	prdc[0]=1;
	for(int i=1;i<=n;++i)
		prdc[i]=prdc[i-1]*i mod;	
}
long long C(int fr,int chos)
{
	if(fr<0||chos<0||fr<chos)
		return 0;
	if(chos==0||chos==fr)
		return 1;
	if(!vis[fr][chos])
	{
		c[fr][chos]=(C(fr-1,chos-1)+C(fr-1,chos))mod;
		vis[fr][chos]=1;
	}
	return c[fr][chos];
}
int h[N],x[N*2],t[N*2],tot=1;
void add(int u,int v)
{
	++tot;
	x[tot]=h[u];
	h[u]=tot;
	t[tot]=v;
}
int rt;
int sz[N],mxson[N];
void getroot(int now,int fa)
{
	for(int j=h[now];j;j=x[j])
		if(nxt!=fa)
		{
			getroot(nxt,now);
			sz[now]+=sz[nxt];
			mxson[now]=max(mxson[now],sz[nxt]);
		}
	if(rt==-1)
		return;
	++sz[now];
	if(n-sz[now]==sz[now])
		rt=-1;
	mxson[now]=max(mxson[now],n-sz[now]);
	if(mxson[now]<mxson[rt])
		rt=now;
}
void getsize(int now,int fa)
{
	sz[now]=0;
	for(int j=h[now];j;j=x[j])
		if(nxt!=fa)
		{
			getsize(nxt,now);
			sz[now]+=sz[nxt];
		}
	++sz[now];
}
long long g[2][N];
int main()
{
	rd(n);
	pre();
	int u,v;
	for(int i=1;i<n;++i)
	{
		rd(u),rd(v);
		add(u,v);
		add(v,u);
	}
	mxson[0]=n+100;
	getroot(1,0);
	if(rt==-1)
	{
		ans=prdc[n/2]*prdc[n/2]mod;
		so("%lld\n",ans);
		return 0;
	}
	int now=0;
	g[now][0]=1;
	for(int j=h[rt];j;j=x[j])
	{
		now^=1;
		getsize(nxt,rt);
		memset(g[now],0,sizeof(g[now]));
		for(int i=0;i<n;++i)
		{
			for(int k=0;k<=min(i,sz[nxt]);++k)
				g[now][i]=(g[now][i]+g[now^1][i-k]*C(sz[nxt],k)mod *C(sz[nxt],k)mod *prdc[k]mod)mod;
		}
	}
	for(int k=0;k<n;++k) 
		if(k&1)
			ans=(ans-g[now][k]*prdc[n-k]mod+P)mod;
		else
			ans=(ans+g[now][k]*prdc[n-k]mod)mod;
	so("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 113536
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>
using namespace std;

int main(){
    int K;
    cin >> K;
    string S;
    cin >> S;
    if (K < S.size()){
        vector<char> ans(K);
        for (int i = 0; i < K; i++){
        cout << S.at(i);
        }
        cout << "..." << endl;
    }
    else{
        cout << S << endl;
    }
}

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

int main() {
  int k,s;
  ll ans = 0;
  cin >> k >> s;
  rep(x,k+1){
    rep(y,k+1){
      int z = s-x-y;
      if(z >= 0 && z <= k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int n, a;

  cin >> n >> a;

  cout << n * n - a << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,s;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	e=a*b;
	f=c*d;
	if(e>f){
		printf("%d\n",e);
	
	}
	else {
		printf("%d\n",f);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int32_t main()
{
    int n,t;
    cin>>n>>t;
    int ans=1000000;
    for(int i=1;i<=n;i++)
    {
        int tc,tt;
        cin>>tc>>tt;
        if(tt>t) continue;
        ans=min(ans,tc);
    }
    if(ans==1000000)
    {
        return 0*puts("TLE");
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;
string s[200010];
ll tw[50],fi[22],num[200010] = {},solve[20][20] = {};
vector<pair<int,int>> v;
int main(){
    int i,j,k,l,n; cin >> n;
    for(i=0;i<n;i++) cin >> s[i];
    tw[0] = 1,fi[0] = 1;
    for(i=1;i<=18;i++){
        tw[i] = tw[i - 1]*2;
        fi[i] = fi[i - 1]*5;
    }
    for(i=0;i<n;i++){
        int k = -1;
        for(j=0;j<s[i].size();j++){
            if(s[i][j]=='.') k = j;
        }
        if(k==-1) k = s[i].size() - 1;
        for(j=0;j<9;j++){
            if(k==s[i].size() - 1){
                s[i].push_back('0'); k++;
            }else{
                k++;
            }
        }
        for(j=0;j<s[i].size();j++){
            if(s[i][j]=='.') continue;
            num[i] *= 10;
            num[i] += s[i][j] - '0';
        }
        int a,b;
        for(j=18;j>=0;j--){
            if(num[i]%tw[j]==0){
                a = j; break;
            }
        }
        for(j=18;j>=0;j--){
            if(num[i]%fi[j]==0){
                b = j; break;
            }
        }
        solve[a][b]++;
        //cout << num[i] << endl;
    }
    ll ans = 0;
    for(i=0;i<=18;i++){
        for(j=0;j<=18;j++){
            if(i>=9 && j>=9){
                ans -= solve[i][j];
            }
            for(k=18 - i;k<=18;k++){
                for(l=18 - j;l<=18;l++){
                    ans += solve[i][j]*solve[k][l];
                }
            }
        }
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 11296
//void _(){
//    int n,m;
//    cin >> n >> m;
//    vi arr(n);
//    cin >> arr;
//    vvi events;
//    ll flat = 0, scale_sum = 0, scale_cnt = 0;
//    rep(i,1,n-1){
//        if(arr[i] < arr[i-1]){
//            events.pb({arr[i-1]+1,m+1,-(m-arr[i-1])});
//            events.pb({1,arr[i]+1,-(arr[i]+m-arr[i-1])});
//            events.pb({arr[i]+1,-arr[i]-1,arr[i]+m-arr[i-1]});
//        }
//        else{
//            events.pb({arr[i-1]+1,arr[i]+1,-(arr[i]-arr[i-1])});
//            events.pb({arr[i]+1,-arr[i]-1,arr[i]-arr[i-1]});
//        }
//        flat += events.back().back();
//    }
//    sort(all(events));
//    ll ans = INF;
//    int l = 0;
//    for(int i = 1; i <= m; ++i){
//        while(l < sz(events) && events[l][0] <= i){
//            if(events[l][1] > 0) ++scale_cnt;
//            else --scale_cnt;
//            scale_sum += events[l][1];
//            flat += events[l][2];
//            ++l;
//        }
//        ll cur = flat + scale_sum - scale_cnt*i;
//        ans = min(ans,cur);
//    }
//    print(ans);
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const ll INF = ll(2e18) + 666;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
void _(){
    int n,m;
    cin >> n >> m;
    vi arr(n);
    cin >> arr;
    vvi events;
    ll flat = 0, scale_sum = 0, scale_cnt = 0;
    rep(i,1,n-1){
        if(arr[i] < arr[i-1]){
            events.pb({arr[i-1]+1,m+1,-(m-arr[i-1])});
            events.pb({1,arr[i]+1,-(arr[i]+m-arr[i-1])});
            events.pb({arr[i]+1,-arr[i]-1,arr[i]+m-arr[i-1]});
        }
        else{
            events.pb({arr[i-1]+1,arr[i]+1,-(arr[i]-arr[i-1])});
            events.pb({arr[i]+1,-arr[i]-1,arr[i]-arr[i-1]});
        }
        flat += events.back().back();
    }
    sort(all(events));
    ll ans = INF;
    int l = 0;
    for(int i = 1; i <= m; ++i){
        while(l < sz(events) && events[l][0] <= i){
            if(events[l][1] > 0) ++scale_cnt;
            else --scale_cnt;
            scale_sum += events[l][1];
            flat += events[l][2];
            ++l;
        }
        ll cur = flat + scale_sum - scale_cnt*i;
        ans = min(ans,cur);
    }
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


Measured memory_bytes: 22828
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

const int P=200020;

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

  vector<int> back(P+1,0);
  vector<ll> dp(N+1,0);
  dp[1]=1;
  back[C[0]]=1;
  for(int i=1;i<N;i++){
    if(back[C[i]]==i) dp[i+1]=dp[i];
    else dp[i+1]=(dp[i]+dp[back[C[i]]])%MOD;
    back[C[i]]=i+1;
  }
  cout<<dp[N]<<endl;


  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<bool> notac(N, true);
    vector<int> w(N, 0);
    int wa = 0, ac = 0;
    rep(i, M) {
        int p;
        cin >> p;
        string s;
        cin >> s;
        p--;
        if (notac[p] && s == "WA")
            w[p]++;
        if (notac[p] && s == "AC") {
            ac++;
            wa += w[p];
            notac[p] = false;
        }
    }

    cout << ac << " " << wa << endl;
}

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

int main(void) {
	int X;
	cin >> X;

	int c500 = X / 500;
	int ans = c500 * 1000;
	int rest = X - (c500 * 500);
	int c005 = rest / 5;
	ans += c005 * 5;

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int N,K;
vector<int> A;

bool isOK(int m) {
    int sum=0;
    for (int i = 0; i < N; i++){
        sum+=ceil((double)A[i]/m-1);
    }
    if (sum<=K) return true;
    else return false;
}

int binary_search() {
    int ng = 0;
    int ok = *max_element(A.begin(),A.end())+1; 
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin>>N>>K;
    for (int i = 0; i < N; i++){
        int a;
        cin>>a;
        A.push_back(a);
    }
    cout<<binary_search()<<endl;
}

Measured memory_bytes: 4324
//
// Created by watemus on 09.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int n, k;
    cin >> n >> k;
    int mn = 0;
    int mx = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        mn += i - 1;
        mx += n - i + 1;
        if (i >= k) {
            ans += mx - mn + 1;
        }
    }
    cout << (ans + 1) % (int(1e9 + 7));
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
    int r,D,x;
	cin >> r >> D >> x;

	rep(i,0,10){
		x = r*x - D;
    	cout << x << endl;;
	}
}

Measured memory_bytes: 256