akhauriyash/Code-Regression huggingface dataset:
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li mpp[256];

void solve(){
  string s;cin>>s;
  li i,n=s.length();
  rep(i,0,n) mpp[s[i]]++;
  rep(i,97,97+26){
    if(mpp[i]==0){
      cout<<(char)(i);
      return ;
    }
  }
  cout<<"None";
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

inline ll mod(ll a, ll m=MOD){return (a%m+m)%m;}
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inv(ll n, ll m=MOD){
    ll a = n, b = m, x = 1, y = 0;
    while(b){
        ll t = a/b;
        a -= t*b;
        swap(a, b);
        x -= t*y;
        swap(x, y);
    }
    return mod(a, m); 
}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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 T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){ /* cin.tie(0); ios::sync_with_stdio(0); */ cout<<fixed<<setprecision(15); } };

int main(){

    ll n, m;
    scanf("%lld%lld", &n, &m);  

    vector<ll> a(n);
    rep(i, n) scanf("%lld", &a[i]);

    ll l = 1;
    int lsb = __builtin_ctz(a[0]);
    rep(i, n){
        l = lcm(l, a[i]/2);
        if(__builtin_ctz(a[i]) != lsb or l > m){
            ppp(0);
            return 0;
        }
    }
    ppp((m/l-1)/2+1);

    return 0;
}


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


int main(){
    int mod=1e9+7;
    string s;
    cin>>s;
    ll dp[210000][4];
    
    dp[0][0]=1;
    rep(i,s.size()){
        if(s[i]=='A')
            dp[i+1][1]+=dp[i][0];
        
        if(s[i]=='B')
            dp[i+1][2]+=dp[i][1];
        
        if(s[i]=='C')
            dp[i+1][3]+=dp[i][2];
        
        if(s[i]=='?'){
            dp[i+1][1]+=dp[i][0];
            dp[i+1][2]+=dp[i][1];
            dp[i+1][3]+=dp[i][2];
            rep(j,4)dp[i+1][j]+=3*dp[i][j];
        }
        else rep(j,4)dp[i+1][j]+=dp[i][j];
        dp[i+1][0]%=mod;
        dp[i+1][1]%=mod;
        dp[i+1][2]%=mod;
        dp[i+1][3]%=mod;
    }
    cout<<dp[s.size()][3]<<endl;
    
    return 0;
}


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

#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define lim 100010
#define mod 1e9 + 7
#define INF 1e9
#define REP(i, n) for (int i = 0; i < n; i++)

ll GCD(int x, int y) { return x % y == 0 ? y : GCD(y, x % y); }

int N;

bool is_same_str(int* tmp, int* mozi) {
  for (int i = 0; i < N; i++) {
    if (tmp[i] != mozi[i]) return false;
  }
  return true;
}

int main() {
  scanf("%d", &N);
  int P[N], Q[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &P[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &Q[i]);
  }
  int a = 0, b = 0;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    v[i] = i + 1;
  }

  int k = 0;

  do {
    k++;
    int tmp[N];
    int j = 0;
    for (int i : v) {
      tmp[j++] = i;
    }

    if (is_same_str(tmp, P)) {
      a = k;
    }
    if (is_same_str(tmp, Q)) {
      b = k;
    }

  } while (next_permutation(v.begin(), v.end()));
  printf("%d\n", abs(b - a));

  return 0;
}

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

const int N = 1e5 + 5;

int n, q;
string s;
int l[N], r[N], f[N], par[N];

int anc(int u) { return par[u] == u ? u : par[u] = anc(par[u]); }
void join(int u,int v) {
	u = anc(u), v = anc(v);
	if (u == v) return;
	par[v] = u; f[u] += f[v];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s >> q; n = s.size(); s = '~' + s;
	for (int i = 1; i <= q; ++i) {
		cin >> l[i] >> r[i];
		if (r[i] < n + 1 - r[i]) continue;
		else if (l[i] > n + 1 - l[i]) {
			l[i] = n + 1 - l[i];
			r[i] = n + 1 - r[i];
			swap(l[i], r[i]);
		}
		else {
			r[i] = n + 1 - r[i];
			if (l[i] <= r[i]) r[i]--;
			else l[i]--, swap(l[i], r[i]);
		}
	}
	
	for (int i = 1; i <= n / 2; ++i) f[i] = s[n + 1 - i] - s[i];
	for (int i = n / 2 + 1; i >= 1; --i) f[i] -= f[i - 1], par[i] = i;
	for (int i = 1; i <= q; ++i) join(l[i], r[i] + 1);
	for (int i = 1; i <= n / 2; ++i) if (anc(i) == i) {
		if (f[i] % 26) return cout << "NO" << '\n',0;
	}
	cout << "YES" << '\n';
}

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

using namespace std;

int main()
{
    int L, A, B, C, D;

    cin >> L >> A >> B >> C >> D;
    cout << L - max(ceil((double)A / C), ceil((double)B / D)) << endl;

    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

/*ll fun2(ll x, ll y)
{
    return (3*x*x)+(y*y)+(2*x*y);
}*/

ll fun(ll x,ll y,ll z)
{
    return (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
}




int main()
{
    faster

    int n;


    map<ll,ll> m;




    for(ll i=1; i<=100; i++)
    {
        for(ll j=1; j<=100; j++)
        {

            for(ll k=1; k<=100; k++)
            {
                //cout<<i<<" ** "<<j<<" ** "<<k<<" - "<<fun(i,j,k)<<endl;

                ll x=fun(i,j,k);

                m[x]++;

                /*if(i==j && j==k)
                    m[x]=m[x]+1;
                else if(i==j || j==k || i==k)
                    m[x]=m[x]+3;
                else
                    m[x]=m[x]+6;*/
            }



        }

    }


    /*for(ll i=1; i<=1000; i++)
    {
        for(ll j=1; j<=1000; j++)
        {
            //cout<<i<<" ** "<<j<<" - "<<fun(i,j)<<endl;

            ll x=fun2(i,j);

            if(i==j)
                m[x]=1;
            else
                m[x]=3;
        }

    }*/




    cin>>n;

    for(ll i=1; i<=n; i++)
    {
        cout<<m[i]<<endl;
    }




    return 0;
}


Measured memory_bytes: 6076
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
ctr = Counter(A)
maxa = max(A)
mina = min(A)

def ok():
    if mina != (maxa+1)//2:
        return False
    if maxa%2:
        if ctr[mina] != 2: return False
    else:
        if ctr[mina] != 1: return False
    for n in range(mina+1, maxa+1):
        if ctr[n] < 2:
            return False
    return True

print('Possible' if ok() else 'Impossible')

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        boolean isDecremented = false;
        for (int i = 0; i < n; i++) {
            int hi = sc.nextInt();
            if (max < hi) {
                max = hi;
                isDecremented = false;
            } else if ((hi < max - 1) || ((hi == max - 1) && isDecremented)) {
                System.out.println("No");
                return;
            } else if (hi == max - 1) {
                max -= 1;
                isDecremented = true;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 48556
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
	int n,l;cin >> n >> l;
	multiset<string> se;
	rep(i,n) {
		string s;cin >> s;
		se.insert(s);
	}
	string ans = "";
	for(string s:se){
		ans += s;
	}
	cout << ans << endl;
}
 
 

Measured memory_bytes: 3604
#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() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  rep(i, m) {
    cin >> s[i] >> c[i];
    --s[i];
  }

  vector<int> d(n, -1);
  rep(i, m) {
    if (d[s[i]] != -1 && d[s[i]] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    d[s[i]] = c[i];
  }

  if (n == 1 && d[0] <= 0) {
    cout << 0 << endl;
    return 0;
  }

  if (d[0] == 0) {
    cout << -1 << endl;
    return 0;
  }

  rep(i, n) {
    if (d[i] != -1) cout << d[i];
    else if (i == 0) cout << 1;
    else cout << 0;
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	map<ll,ll> mp;
	vl vec(n);
	rep(i,0,n){
		ll a; cin>>a;
		mp[a]++;
		vec[i]=a;
	}
	ll total=0;
	for(auto c:mp){
		ll k=c.second;
		total+= (k*(k-1))/2;
	}
	vl ans(n);
	rep(i,0,n){
		ll k=vec[i];
		ll m=mp[k];
		ll cnt=total;
		ans[i]=(cnt-(m-1));
	}
	rep(i,0,n) cout<<ans[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 12672
#include <stdio.h>
#include <stdlib.h>
#define max_size (int)(1e5 + 1)

int main(){
	int i, ans = 0;
	char *S = (char *)malloc(sizeof(char) * max_size);
	scanf("%s", S);
	for(i = 1; S[i] != '\0'; i++){
		if(S[i] != S[i - 1]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum = sum + (a[i]-1);
	}
	cout << sum << endl;
	getchar();
	getchar();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    double highest = -1e9;
    double lowest = 1e9;
    double h;
    while(cin >> h) {
        highest = max(highest, h);
        lowest = min(lowest, h);
    }
    printf("%.3f\n", highest- lowest);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    double a;
    double ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> a;
        ans += 1 / a;
    }
    ans = 1 / ans;

    cout << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++) cin >> a[i];

  int ans = 0;
  for(int i = 1; i < N; i++){
    if(a[i] == a[i - 1]){
      a[i] = -1;
      ans++;
    }
  }

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {

            String str = Console.ReadLine();
            double r = double.Parse(str);
            double x,y;
            x = 2.0 * Math.PI * r;
            y = Math.PI * r * r;

            Console.WriteLine(y.ToString("f6") + " " + x.ToString("f6"));
        }
    }
}

Measured memory_bytes: 5740
#include<bits/stdc++.h>
using namespace std;
#define N 400 + 5
#define K 5
#define base 1000
#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, ans, C[N][K];
unordered_map <int, int> M;
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Hash(int a, int b, int c, int d){
    int ans = 0;
    ans = ans * base + a, ans = ans * base + b, ans = ans * base + c, ans = ans * base + d;
    return ans;
}
void update(int val, int x){
    int a, b, c, d;
    d = val % base, val /= base;
    c = val % base, val /= base;
    b = val % base, val /= base;
    a = val % base, val /= base;
    M[Hash(a, b, c, d)] += x;
    M[Hash(b, c, d, a)] += x;
    M[Hash(c, d, a, b)] += x;
    M[Hash(d, a, b, c)] += x;
}
signed main(){
    n = read();
    rep(i, 1, n){
        C[i][0] = read(), C[i][1] = read(), C[i][2] = read(), C[i][3] = read();
        update(Hash(C[i][0], C[i][1], C[i][2], C[i][3]), 1);
    }
    rep(i, 1, n){
        update(Hash(C[i][0], C[i][1], C[i][2], C[i][3]), -1);
        rep(j, i + 1, n){
            update(Hash(C[j][0], C[j][1], C[j][2], C[j][3]), -1);
            rep(k, 0, 3){
                int AA = Hash(C[i][0], C[i][3], C[j][k], C[j][(3 + k) % 4]); if(!M[AA]) continue;
                int BB = Hash(C[i][3], C[i][2], C[j][(1 + k) % 4], C[j][k]); if(!M[BB]) continue;
                int CC = Hash(C[i][2], C[i][1], C[j][(2 + k) % 4], C[j][(1 + k) % 4]); if(!M[CC]) continue;
                int DD = Hash(C[i][1], C[i][0], C[j][(3 + k) % 4], C[j][(2 + k) % 4]); if(!M[DD]) continue;
                int a, b, c, d;
                a = M[AA], update(AA, -1);
                b = M[BB], update(BB, -1);
                c = M[CC], update(CC, -1);
                d = M[DD], update(DD, -1);
                if(a > 0 && b > 0 && c > 0 && d > 0) ans += a * b * c * d;
                update(AA, 1), update(BB, 1), update(CC, 1), update(DD, 1);
            }
            update(Hash(C[j][0], C[j][1], C[j][2], C[j][3]), 1);
        }
        update(Hash(C[i][0], C[i][1], C[i][2], C[i][3]), 1);
    }
    printf("%lld", ans / 3);
    return 0;
}

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

constexpr long long MOD = 1000000007;

vector<long long> F, RF, R;

void init() {
	F.resize(2001), RF.resize(2001), R.resize(2001);
	F[0] = F[1] = RF[0] = RF[1] = R[0] = R[1] = 1;
	for (int i = 2; i <= 2000; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		R[i] = MOD - (R[MOD % i] * (MOD / i)) % MOD;
		RF[i] = (RF[i - 1] * R[i]) % MOD;
	}
}

long long Comb(long long X, long long Y) {
	if (Y < 0 || X < Y) return 0;
	return (F[X] * ((RF[X - Y] * RF[Y]) % MOD)) % MOD;
}

int main() {
	init();
	long long A, B;
	cin >> A >> B;
	vector<vector<long long> > DP(A + 1, vector<long long>(B + 1, 0));
	for (int i = 0; i <= A; i++) {
		for (int j = 1; j <= B; j++) {
			if (i + j >= B) DP[i][j] = (Comb(B - 1, j - 1) * (i + j - B + 1)) % MOD;
		}
	}
	long long ANS = DP[A][B];
	for (int i = B - 1; i >= 0; i--) {
		long long NOW = 0;
		for (int j = A; j >= 0; j--) {
			NOW += Comb(B - i - 1, A - j);
			NOW %= MOD;
			ANS += DP[j][i] * NOW;
			ANS %= MOD;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#include<set>
using namespace std;
int main(){
	string s;
	getline(cin,s);
	int sum=0;
	string s1="";
	string s2="";
	for(int i=0;i<s.length();i++){
		s1+=s[i];
		if(s1==s2){
			continue;
		}
		else{
			s2=s1;
			s1="";
			sum++;
		}
	}
	printf("%d",sum);
    return 0;
}

Measured memory_bytes: 640
(defun solve (s)
  (let (a)
    (loop for x across s
          do (case x
                (#\0 (setf a (cons #\0 a)))
                (#\1 (setf a (cons #\1 a)))
                (t (setf a (cdr a)))))
    (reverse a)))

(format t "~{~A~}" (solve (read-line)))

Measured memory_bytes: 12644
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Segment_Tree{
	private:
	int n;
	vl date;
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vl(2*n-1,INF);
	}
	void Update(int k,ll x){
		k+=n-1;
		date[k]=x;
		while(k>0){
			k=(k-1)/2;
			date[k]=min(date[k*2+1],date[k*2+2]);
		}
	}
	ll Query(int a,int b){
		a+=n-1;b+=n-1;
		ll m=INF;
		while(a<b){
			if(a%2==0) m=min(m,date[a++]);
			if(b%2==0) m=min(m,date[--b]);
			a/=2;b/=2;
		}
		return m;
	}
	ll Open(int k){return date[k+n-1];}
};

int n,m;
vvp a;

int main(){
	cin>>n>>m;
	a=vvp(n);
	for(int i=0;i<m;i++){
		int l,r,w;
		cin>>l>>r>>w;
		a[r-1].push_back({l-1,w});
	}
	Segment_Tree st(n);
	st.Update(0,0);
	for(int i=1;i<n;i++){
		ll m=INF;
		for(auto p:a[i]){
			int l=p.first,w=p.second;
			ll t=st.Query(l,i);
			m=min(m,t+w);
		}
		st.Update(i,m);
	}
	ll res=st.Open(n-1);
	cout<<(res==INF?-1:res)<<endl;
} 

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

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

    sort(ALL(name));
    name.erase(unique(name.begin(), name.end()), name.end());

    cout << name.size() << endl;
    return 0;
}

Measured memory_bytes: 9532
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());


		int c = a*b;

		if(c%2==0) System.out.println("Even");
		else System.out.println("Odd");

	}
}

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

constexpr int lim = 1e6+1;
vector<vector<int>> pr(lim), id(lim);
vector<bool> is_pr(lim, true);

void all_fac() {
  is_pr.at(0) = 0;
  is_pr.at(1) = 0;
  for (int i = 2; i < lim; i++) {
    if (is_pr.at(i)) {
      pr.at(i).push_back(i);
      id.at(i).push_back(1);
      for (int j = 2 * i; j < lim; j += i) {
        is_pr.at(j) = false;
        int cnt = 0;
        int nw = j;
        while (nw % i == 0) {
          nw /= i;
          cnt++;
        }
        pr.at(j).push_back(i);
        id.at(j).push_back(cnt);
      }
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  all_fac();
  
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  vector<int> cnt(1e6+1);
  for (int i = 0; i < N; i++) {
    for (auto p : pr.at(A.at(i))) {
      if (cnt.at(p)) goto NG;
      cnt.at(p)++;
    }
  }
  return cout << "pairwise coprime" << "\n", 0;
  NG:;
  
  int G = 0;
  for (int i = 0; i < N; i++) G = gcd(G, A.at(i));
  if (G == 1) cout << "setwise coprime" << "\n";
  else cout << "not coprime" << "\n";
}


Measured memory_bytes: 121996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int e;
  while(cin>>e&&e){
    int i,j,a,y,m=1000000000;
    for(i=1;i*i*i<=e;++i);
    a=i-1;
    for(i=0;i<=a;++i){
      int b=e;
      b=b-i*i*i;
      for(j=1;j*j<=b;++j);
      y=(j-1);
      b=b-y*y;
      m=min(m,b+y+i);
    }
    cout<<m<<endl;
  }
  return 0;
}



Measured memory_bytes: 3056
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <iostream>
#include <utility>
#include <sstream>
#include <cstring>
#include <bitset>
#include <climits>
 
using namespace std;
#define  AS(arr)  (sizeof(arr)/sizeof(arr[0]))
#define ALL(c) (c).begin(),(c).end() 
#define SIZE(a) int((a).size())
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef long long LL;
int x[100001];
int y[100001];
int b[100001];
int n[100001];
#define RED 1
#define WHITE 2

int main(void){
    int N,M;
    cin >> N >> M;
	b[0] = RED;
	n[0] = 1;
    for(int i=1;i<N;i++)
    {
        b[i] = WHITE;
        n[i] = 1;
    }
    REP(i, M)
    {
        int f, t;
        cin >> f >> t;
        f--;
        t--;
        n[f]--;
        n[t]++;
        b[t] = b[f] | b[t];
        if(n[f] == 0)
        {
            b[f] = 0;
        }
    }
    int ret = 0;
    REP(i, N)
    {
        if(b[i] & RED)
        {
            ret++;
        }
    }
    
    cout << ret << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
using namespace std;
typedef complex<double> C;
int n;
C s[100], e[100];

#define EPS (1e-10)
#define EQ(a,b) (abs(a-b) < EPS)
#define EQV(a,b) (EQ(a.real(), b.real()) && EQ(a.imag(), b.imag()))

double cross(C a, C b) {
  return a.real() * b.imag() - a.imag() * b.real();
}

C intersection(C a1, C a2, C b1, C b2) {
  C b = b2 - b1;
  
  double d1 = cross(b, a1 - b1);
  double d2 = cross(b, a2 - b1);
  double t = d1 / (d1 + d2);
  return a1 + (a2 - a1) * t;
}

void solve() {
  for(int i=0;i<n;i++)
    cin>>s[i].real()>>s[i].imag()>>e[i].real()>>e[i].imag();
  
  int res = 1;
  for (int i = 0; i < n; i += 1) {
    int count = 0;
    vector<C> iss;
    for (int j = 0; j < i; j += 1) {
      C iv = e[i] - s[i], jv = e[j] - s[j];
      // ツ陳シツ静シツつェツ古ーツ債キツつオツづつ「ツづゥツつゥ
      if (abs(cross(iv, jv)) < EPS) continue;
      // ツ陳シツ静シツづ個古ーツ点
      //C is = intersection(s[i], e[i], s[j], e[j]);
      C is = s[i] + iv * cross(jv, s[j]-s[i]) / cross(jv, iv);
      // ツ古ーツ点ツつェツ氾債暗債外
      if (abs(is.real()) > 100.0 - EPS) continue;
      if (abs(is.imag()) > 100.0 - EPS) continue;
      // ツ古ーツ点ツつェツ堕カツ催敖つキツづゥツつゥ
      bool flag = false;
      for (int z = 0; z < iss.size(); z += 1) {
        if (EQV(iss[z], is)) {
          flag = true; break;
        }
      }
      if (flag) continue;
      
      iss.push_back(is);
      count++;
    }
    res += count + 1;
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 968
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int md=1000000007,MX=200011;
typedef long long LL;
int h,w,a,b;
int fac[MX],inv[MX],facinv[MX];
#define C(x,y) ((LL)fac[x]*facinv[y]%md*facinv[(x)-(y)]%md)

int main(){
	scanf("%d%d%d%d",&h,&w,&a,&b);
	fac[0]=facinv[0]=1;
	for(int i=1;i<=h+w;i++)fac[i]=(LL)fac[i-1]*i%md;
	inv[1]=1;
	for(int i=2;i<=h+w;i++)inv[i]=(LL)(md-md/i)*inv[md%i]%md;
	for(int i=1;i<=h+w;i++)facinv[i]=(LL)facinv[i-1]*inv[i]%md;
	int ans=0;
	for(int i=h-a,j=w-b;i&&j;i--,j--)ans=((LL)ans+(LL)C(i-1+w-j,i-1)*C(h-i+j-1,j-1))%md;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int result = 1;
		for(int i = 1; i <= N; i *= 2) {
			result = i;
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 27036
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
#define rep(i,x) for(int i=ls[x];i;i=nx[i])
using namespace std;
const int N=420,M=1e5+10;
int to[M],nx[M],ls[N],vl[M],num=0;
int rd[N],cd[N];
bool cz[N],vis[N];;
void link(int u,int v){
	cz[u]=cz[v]=1;
	to[++num]=v,nx[num]=ls[u],ls[u]=num;
}
void dfs(int x){
	if(vis[x]) return;
	vis[x]=1;
	rep(i,x) dfs(to[i]);
}
int main()
{
	int n,h;
	scanf("%d %d",&n,&h);
	fo(i,1,n){
		int a,b,c,d,u,v;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		u=c?c:a+h,v=d?d+h:b;
		link(u,v),cd[u]++,rd[v]++;
	}
	bool tf=false;
	fo(i,1,h) if(cz[i]){
		if(rd[i]<cd[i]) return printf("NO"),0;
		tf|=rd[i]>cd[i];
	}
	if(!tf) return printf("NO"),0;
	tf=false;
	fo(i,h+1,h<<1) if(cz[i]){
		if(rd[i]>cd[i]) return printf("NO"),0;
		tf|=rd[i]<cd[i];
	}
	if(!tf) return printf("NO"),0;
	fo(i,h+1,h<<1) if(cz[i] && rd[i]<cd[i]) dfs(i);
	fo(i,1,h) if(cz[i] && !vis[i]) return printf("NO"),0;
	printf("YES");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

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

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n ;cin >> n;
    string s; cin >> s;
    string ans = "No";
    if(n % 2 == 0){
        //cout << s.substr(s.length()/2,s.length());
        if(s.substr(0,s.length()/2) == s.substr(s.length()/2,s.length())) ans = "Yes";
    }
    cout << ans;
}


Measured memory_bytes: 3608
N, X = map(int, input().split())
S = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7
dp = [[0 for _ in range(X+1)] for _ in range(N+1)]
dp[1] = [i % S[0] for i in range(X+1)]
S = [None] + S

for i in range(2, N+1):
    for j in range(X+1):
        dp[i][j] = (dp[i-1][j]*(i-1) + dp[i-1][j%S[i]]) % mod


print(dp[-1][-1])

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

int main(){
  int n;
  map<int, bool> mp;
  int ans = 0;

  cin >> n;
  vector<int> a(n);
  rep(i, n)cin >> a[i];
  sort(a.begin(), a.end()); 

  rep(i, n){
    
    //約数があるか判定
    set<int> yaku;
    bool flag = true;
    for(int j = 1; j*j<=a[i];j++){
      if(a[i]%j==0){
        // cout << "(" << j << ")";
        // cout << "(" << a[i]/j << ")";
        if(mp[j]==true||mp[a[i]/j]==true){
          flag = false;
          break;
        }
      }
    }
    //次の数も同じ数ならNG
    if(i<n-1){
      if(a[i]==a[i+1])flag = false;
    }
    // cout << "[" << a[i] << "," << flag << "]";  
    if(flag == true)ans++;

    mp[a[i]]=true;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 32748
from bisect import bisect_left
from collections import deque

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for _ in range(m):
	bc.append(list(map(int,input().split())))

a.sort()
bc = sorted(bc, key=lambda x:x[1])

l = [0 for _ in range(n+1)]
for i in range(1,n+1):
	l[i] = a[i-1]
for i in range(n):
	l[i+1] += l[i]
#print(a,sum(a))
#print(bc)
#print(l)
ans = l[-1]
num = 0
loop = 0

while True:
	if len(bc) == 0:
		break
	tmp = bc.pop()
	b = tmp[0]
	c = tmp[1]
	index = bisect_left(a,c) - num
	if index <= 0:
		break
	if b >= index:
		ans -= l[index+num] - l[num]
		ans += index * c
		num += index
		loop = index
	else:
		ans -= l[b+num] - l[num]
		ans += b * c
		num += b
		loop = b

print(ans)


Measured memory_bytes: 37964
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


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

	string s;
	cin >> s;

	sort(allof(s));

	bool ok = true;

	if (s[0] != s[1]) ok = false;
	if (s[2] != s[3]) ok = false;
	if (s[0] == s[3]) ok = false;

	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
totalodd=0
totaleven=0
ansodd=0
anseven=0
for i in range(len(arr)):
    if i%2==0:      # 
        if totalodd+arr[i]>0:
            totalodd+=arr[i]
        else:
            ansodd+=1-(totalodd+arr[i])
            totalodd=1
        if totaleven+arr[i]<0:
            totaleven+=arr[i]
        else:
            anseven+=(totaleven+arr[i])+1
            totaleven=-1
    else:
        if totalodd+arr[i]<0:
            totalodd+=arr[i]
        else:
            ansodd+=(totalodd+arr[i])+1
            totalodd=-1
        if totaleven+arr[i]>0:
            totaleven+=arr[i]
        else:
            anseven+=1-(totaleven+arr[i])
            totaleven=1

print(min(ansodd,anseven))


Measured memory_bytes: 14468
<?php

fscanf(STDIN, "%d", $n);

$weight = trim(fgets(STDIN));
$warray = explode(" ",$weight);

$zet = 100000000;
$mode = 0;
for($i = 1; $i<($n); $i++){
    $one = 0;
    for($j = 0; $j < $i; $j++){
       $one += $warray[$j];
    }
    $two = 0;
    for($k = $i; $k < $n; $k++){
        $two += $warray[$k];
    }
    $abs = abs($one - $two);
    if($zet > $abs){
        $zet = $abs;
    }elseif($zet < $abs){
        $mode = 2;
        if($mode == 2){
            echo $zet;
            exit;
        }
    }




}
echo $zet;

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n;
	ll ans = 1;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ans= (ans*i)%1000000007;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
#define INF 1e9
#define fs first
#define sc second
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

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

int main(){
    ll h,w,n,ans = 0;
    cin >> h >> w >> n;
    char cells[h][w];
    bool is_visited[h][w];
    ll x[n+1],y[n+1],cnt = 0,d[h][w];
    queue<pair<int,int> >que;
    pair<int,int>p;
    
    rep(i,0,h){
        rep(j,0,w){
            cin >> cells[i][j];
            if(cells[i][j] == 'S'){
                y[0] = i;
                x[0] = j;
            }
            else if(cells[i][j] >= '0' && cells[i][j] <= '9'){
                y[cells[i][j]-'0'] = i;
                x[cells[i][j]-'0'] = j;
            }
        }
    }
    
    rep(i,0,n){
        rep(j,0,h){
            rep(k,0,w){
                is_visited[j][k] = false;
                d[j][k] = INF;
            }
        }
        
        
        d[y[i]][x[i]] = 0;
        p.fs = y[i];
        p.sc = x[i];
        que.push(p);
        
        while(!que.empty()){
            p = que.front();
            que.pop();
            //cout << p.fs << " " << p.sc << endl;
            if(p.fs == y[i+1] && p.sc == x[i+1]){
                ans += d[y[i+1]][x[i+1]];
              	//cout << i << endl;
            }
            
            rep(j,0,4){
              	//cout << p.fs+dy[j] << " " << p.sc+dx[j] << " " << y[i+1] << " " << x[i+1] << endl;
                if(p.fs+dy[j] >= 0 && p.fs+dy[j] <= h-1 && p.sc+dx[j] >= 0 && p.sc+dx[j] <= w-1){
                    if(cells[p.fs+dy[j]][p.sc+dx[j]] == '.' || cells[p.fs+dy[j]][p.sc+dx[j]] == 'S' ||(cells[p.fs+dy[j]][p.sc+dx[j]] >= '0' &&  cells[p.fs+dy[j]][p.sc+dx[j]] <= '9')){
                        if(!is_visited[p.fs+dy[j]][p.sc+dx[j]]){
                            d[p.fs+dy[j]][p.sc+dx[j]] = min(d[p.fs][p.sc]+1,d[p.fs+dy[j]][p.sc+dx[j]]);
                            is_visited[p.fs+dy[j]][p.sc+dx[j]] = true;
                            p.fs += dy[j];
                            p.sc += dx[j];
                            que.push(p);
                            p.fs -= dy[j];
                            p.sc -= dx[j];
                          	//cout << p.fs+dy[j] << " " << p.sc+dx[j] << " " <<  d[p.fs+dy[j]][p.sc+dx[j]] << endl;
                        }
                        
                    }
                }
            }
            
        }
        //cout << d[y[i+1]][x[i+1]] << endl;
    }
  
  	cout << ans << endl;
  
    return 0;
}


Measured memory_bytes: 12904
//============================================================================
// Name        : HelloWorld.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
typedef long long ll;
using namespace std;
int A,P;
int main() {
	cin>>A>>P;
	cout<<(A*3+P)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
money = list(map(int, input().split()))
if money[0] * 2 < money[1]:
    money[0] *= 4
    del money[1]
else:
    money[1] *= 2
    del money[0]
if money[0] < money[1]:
    del money[1]
else:
    del money[0]
if money[0] * 2 < money[1]:
    money[1] = money[0] * 2
N = int(input())
print(N // 2 * money[1] + N % 2 * money[0])


Measured memory_bytes: 3064
#coding: utf-8

H, W = map(int, input().split(' '))

H += 2
W += 2

S = ['0'*W] * H

for i in range(1, H-1):
    S[i] = str(input())

for n in range(1, H-1):
    S[n] = '0' + S[n] + '0'

for n in range(1, H-1):
    for m in range(1, W-1):
        if(S[n][m] == '.'):
            counter = 0
            for s in range(n-1, n+2):
                for t in range(m-1, m+2):
                    if(S[s][t] == '#'):
                        counter += 1
            print(counter,end='')
        if(S[n][m] == '#'):
            print('#',end='')
    print()

Measured memory_bytes: 3444
x,k,d = map(int,input().split())

dif = abs(x)//d
if dif > k:
    print(abs(x)-k*d)
else:
    res = k-dif
    if res%2 == 0:
        print(abs(x)-dif*d)
    else:
        print(abs(abs(x)-(dif+1)*d))

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
int a[6666];
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		printf("node %d: key = %d, ",i,a[i]);
		if(i!=1)printf("parent key = %d, ",a[i/2]);
		if(i*2<=n)printf("left key = %d, ",a[i*2]);
		if(i*2+1<=n)printf("right key = %d, ",a[i*2+1]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3216
n = int(input())
a = [int(x) for x in input().split(' ')]

b = [0 for x in a]

x = 1
for i in range(n + 1):
    x -= a[i]
    if x < 0:
        print(-1)
        exit(0)
    b[i] = x
    x *= 2

res = 0
x = 0
for i in range(n, -1, -1):
    if (x + 1) // 2 > b[i]:
        print(-1)
        exit(0)
    x = min(x, b[i]) + a[i]
    res += x

print(res)


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	int c[100],t[100];
	int N,T;
	cin >> N >> T;
	int mn = 1e9;
	for (int i = 0; i < N; ++i) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			if (c[i] < mn) {
				mn = c[i];
			}
		}
	}

	if (mn == (int)1e9) {
		cout << "TLE\n";
	} else {
		cout << mn << '\n';
	}
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

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

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ret = 0;
  int n = 0;
  for( int i=0; i<S.size(); i++ ){
    ret++;
    if( S[i] == 'S' ) n++;
    else if( S[i] == 'T' && n > 0 ){
      n--;
      ret -= 2;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int MOD = 1000000007;

long long modPow(long long a, long long p){
    if(p == 0) return 1;
    auto res = modPow(a, p/2);
    res = (res*res)%MOD;
    if(p%2) res = (res*a)%MOD;
    return res;
}

class UnionFind {
public:
    explicit UnionFind(int N) : root(N, -1), size(N, 1) {}
    int getRoot(int u){ return root[u] == -1 ? u : root[u] = getRoot(root[u]); }
    int getSize(int u){ return size[getRoot(u)]; }
    int same(int a, int b){
        return getRoot(a) == getRoot(b);
    }
    int merge(int a, int b){
        int u = getRoot(a);
        int v = getRoot(b);
        if(u != v){
            root[u] = v;
            size[v] += size[u];
        }
    }
private:
    vector<int> root;
    vector<int> size;
};

int main(){
    int N, M;
    while(cin >> N >> M){
        long long X; cin >> X;
        vector<pair<long long, pair<int, int>>> edges(M);
        for(auto& p : edges){ 
            cin >> p.second.first >> p.second.second >> p.first;
            --p.second.first;
            --p.second.second;
        }
        sort(edges.begin(), edges.end());
        UnionFind uf(N);
        vector<vector<pair<int, long long>>> g(N);
        vector<pair<int, pair<int, int>>> outer;
        long long S = 0;
        for(auto& e : edges){
            if(uf.same(e.second.first, e.second.second)){
                outer.push_back(e);
            } else {
                S += e.first;
                uf.merge(e.second.first, e.second.second);
                g[e.second.first].emplace_back(e.second.second, e.first);
                g[e.second.second].emplace_back(e.second.first, e.first);
            }
        }
        vector<vector<long long>> maxEdge(N, vector<long long>(N, 0));
        for(int i=0;i<N;i++){
            queue<int> qu; qu.push(i);
            while(!qu.empty()){
                int p = qu.front(); qu.pop();
                for(auto& next : g[p]){
                    int np = next.first;
                    if(np == i || maxEdge[i][np]) continue;
                    maxEdge[i][np] = max(maxEdge[i][p], next.second);
                    qu.push(np);
                }
            }
        }
        long long D = X - S;
        int same = 0, upper = 0;
        for(auto& e : outer){
            long long dif = e.first - maxEdge[e.second.first][e.second.second];
            if(dif > D) ++upper;
            if(dif == D) ++same;
        }
        long long res = 0;
        if(D == 0){
            res += (modPow(2, N-1) + MOD - 2) * modPow(2, M-(N-1));
            res %= MOD;
        }
        if(D >= 0) {
            res += 2 * (modPow(2, same) + MOD - 1) * modPow(2, upper); 
            res %= MOD;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 8320
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) throws IOException {

        ArrayList<Integer> x_list = new ArrayList<>();
        ArrayList<Integer> y_list = new ArrayList<>();

        int x;
        int y;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        do {
            String[] line = br.readLine().split(" ");
            x = Integer.parseInt(line[0]);
            y = Integer.parseInt(line[1]);

            if (x == 0 && y == 0) {
                break;
            }

            x_list.add(x);
            y_list.add(y);

        } while (x != 0 || y != 0);

        for (int n = 0; n < x_list.size(); n++) {
            for (int a = 0; a < x_list.get(n); a++) {

                for (int b = 0; b < y_list.get(n); b++) {
                    if(0 < a && a < x_list.get(n)-1 && 0 < b && b < y_list.get(n)-1) System.out.printf(".");
                    else System.out.printf("#");
                }

                System.out.println();
            }

            System.out.println();
        }

    }

}

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

int main(){
    int s;
    cin >> s;
    vector<int> v;
    v.push_back(s);

    bool flag = false;
    for(int i = 0; i < 1000000 - 1 ; i++)
    {
        if(v[i] % 2 == 0){
            v.push_back(v[i] / 2);
        }else{
            v.push_back(v[i] * 3 + 1);
        }
        //cout << v[i] <<endl;

        if(i != 0){
            for(int j = 0; j < v.size() - 2; j++)
            {
                /* code */
                if(v[i] == v[j] && i != 0){
                    flag = true;
                    //cout << "vi:" << v[i] << "vj" << v[j] <<endl;
                    cout  << i + 1 << endl;
                    return 0;
                }
            }
        }
        
        
    }




        
        

    
    

}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> stu(n), chk(m);

  rep(i, n) cin >> stu[i].first >> stu[i].second;
  rep(i, m) cin >> chk[i].first >> chk[i].second;

  for (int i = 0; i < n; ++i) {
    ll mindist = INF, ans = 0;
    for (int j = 0; j < m; ++j) {
      ll dist =
          abs(stu[i].first - chk[j].first) + abs(stu[i].second - chk[j].second);
      if (dist < mindist) {
        ans = j + 1;
        mindist = dist;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

bool isPrime(int val);
int countPrime(vector<int>& array);

int main()
{
    int size;
    vector<int> array;
    cin >> size;
    for (int i = 0; i < size; i++) {
        int tmp;
        cin >> tmp;
        array.push_back(tmp);
    }
    cout << countPrime(array) << endl;
    return 0;
}

int countPrime(vector<int>& array)
{
    int num = 0;
    for (int i = 0; i < array.size(); i++) {
        if (isPrime(array[i])) {
            num++;
        }
    }
    return num;
}

bool isPrime(int val)
{
    if (val <= 1) {
        return false;
    }
    for (int i = 2; i * i <= val; i++) {
        if (val % i == 0) {
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 1320
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	vector <int> b(n);
	vector <int> c(n-1);
	for (int i =0; i < n ; i++) cin >> a[i];
	for (int i =0; i < n ; i++) cin >> b[i];
	for (int i =0; i < n-1 ; i++) cin >> c[i];
	int sum =0;
	for (int i =0; i < n ; i++) {
		sum += b[a[i]-1];
		if (i >0) {
			if ((a[i] -1) == a[i-1]) {
				sum += c[a[i-1]-1];
			}
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256