akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int  main () {

    int n;
    cin >> n;
    vector<int> sticks;
    for(int i = 0; i < n; i++){
        int stick;
        cin >> stick;
        sticks.push_back(stick);
    }

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

    int total = 0; //N iterations, overall O(N^2)

    for(int largest = sticks.size() - 1; largest >= 0; largest--){
        int largestLength = sticks[largest];

        //O(N)
        int left = 0;
        int right = largest - 1;
        while(left < right) {
            int cur = sticks[left] + sticks[right];
            if(cur <= largestLength) { 
                left++; //Increase smallest stick
            } else {
                total += right - left; 
                right --; //Decrease middle stick
            }
        }

    }

    cout << total << "\n";

    return 0;
}

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

typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	// freopen("input.in", "r", stdin);
	// freopen("input.out", "w", stdout);
	int n, y; cin >> n >> y;
	int a{}, b{}, c{};
	bool works = false;
	F0R(i, n + 1) {
		F0R(j, n + 1) {
			if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
				a = i;
				b = j;
				c = n - a - b;
				works = true;
				break;
			}
		}
	}
	if (a < 0 || b < 0 || c < 0) works = false;
	if (works) cout << a << " " << b << " " <<  c << nl;
	else cout << -1 << " " << -1 << " " << -1 << nl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int i,j;
long long int a,b,n,k=0;
int main(void){
    scanf("%lld %lld %lld",&n,&a,&b);
    k += a * ( n / ( a + b ) );
    if (( n % ( a + b ) ) == 0)
    {
        printf("%lld\n",k);
        return 0;
    } else if( a <= ( n % ( a + b ) ) )
    {
        k += a;
    } else
    {
        k += ( n % ( a + b ) );
    }
    printf("%lld\n",k);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/



string S;
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;

    int ans = 0;
    char pre = 'A';
    fore(c, S) {
        if (pre >= c) ans++;
        pre = c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3156
# ABC140B - Buffet
def main():
    N, *ABC = map(int, open(0).read().split())
    A, B, C = ABC[:N], ABC[N : N * 2], ABC[N * 2 :]
    ans = sum(B)
    for i, j in zip(A, A[1:]):
        if i + 1 == j:
            ans += C[i - 1]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d=2;
  cin >>a>>b>>c;
  if(a==b&&b==c)d=1;
  if(a!=b&&b!=c&&c!=a)d=3;
  cout << d<< endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new BufferedReader(new InputStreamReader(System.in)));
        long limit[] = new long[5];
        long N = 0;
        long time = 0;

        try {
            N = Long.parseLong(br.readLine());
        } catch (IOException e) {

        }
        for (int i=0; i<5; i++) {
            try {
                limit[i] = Long.parseLong(br.readLine());
            } catch (IOException e) {

            }
        }
        long min = limit[0];
        int min_index = 0;
        for (int i=1; i<5; i++) {
            if (min > limit[i]) {
                min = limit[i];
                min_index = i;
            }
        }

        time = N / min + boolToInteger((N % min)!=0) + 4;

        System.out.println(time);
    }

    private static int boolToInteger(boolean b) {
        if (b == true) {
            return 1;
        } else {
            return 0;
        }
    }
   
}

Measured memory_bytes: 21332
n, m = map(int, input().split())
res = [0]*m
p = [[] for _ in range(n)]
for i in range(m):
    pi, yi = map(int, input().split())
    p[pi - 1].append((yi, i))
for pi in range(n):
    p[pi].sort()
    for j in range(len(p[pi])):
        i = p[pi][j][1]
        res[i] = str(pi + 1).zfill(6) + str(j + 1).zfill(6)
print('\n'.join(res))

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

int main(){
  vector<int> ans(5);
  int a;
  for(int i=0;i<5;i++)cin >> ans.at(i);
  cin >> a;
  sort(ans.begin(),ans.end());
  if(abs(ans.at(0)-ans.at(4))>a)cout << ":(";
  else cout << "Yay!";
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;

int main(){
  ll i,j;
  ll n,x,d;
  cin>>n>>x>>d;
  if(d<0){
    x=-x;
    d=-d;
  }
  if(d==0){
    if(x==0) {
      cout<<1<<endl;
      return 0;
    }
    cout<<n+1<<endl;
    return 0;
  }
  else {
    map<ll,multiset<P> > v;
    for(j=0;j<=n;j++){
      ll r=(x*j)%d;
      if(r<0) r+=d;
      ll ad=(x*j-r)/d;
      ll left=ad+j*(j-1)/2;
      ll right=ad+j*(2*n-j-1)/2+1;
      v[r].insert(P(left,1));
      v[r].insert(P(right,-1));
    }

    ll cnt=0;

    for(auto mi=v.begin();mi!=v.end();++mi){
      i=mi->first;
      ll prev;
      ll c=0;
      for(auto it=v[i].begin();it!=v[i].end();++it){
        if(it==v[i].begin()){
          prev=(*it).fi;
          c+=(*it).se;
        }
        else {
          if(c>0) cnt+=(*it).fi-prev;
          prev=(*it).fi;
          c+=(*it).se;
        }
      }
    }
    //assert(x >= 0);
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 44032
#include<iostream>
using namespace std;
int main() {
	int  date, ans[222], an;
	an = 0;
	while (1) {
		cin >> date;
		if (date == -1) {
			goto a;
		}
		an = an + 1;
		ans[an] = 1150;
		date = date - 10;
		if (date <= 0) {
			goto b;
		}
		if (date > 10) {
			ans[an] = ans[an] + 1250;
			date = date - 10;
		}
		else {
			ans[an] = date * 125 + ans[an];
			goto b;
		}
		if (date > 10) {
			ans[an] = ans[an] + 1400;
			date = date - 10;
		}
		else {
			ans[an] = ans[an]+date * 140;
			goto b;
		}
		ans[an] = ans[an]+date * 160;
	b:;
	}
a:;
	for (int i = 1; i <= an; i++) {
		cout << 4280-ans[i] << endl;
	}
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){
	int N;
	cin>>N;
	
	int cnt = 0;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		if(a%2==1)cnt++;
	}
	
	if(cnt%2==0){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < M; i++) {
        cin >> B.at(i);
    }

    bool ans = false;
    for (int i = 0; i + M <= N; i++) {
        for (int j = 0; j + M <= N; j++) {
            bool keep = true;
            for (int k = 0; k < M; k++) {
                if (A.at(i + k).substr(j, M) != B.at(k)) {
                    keep = false;
                }
            }
            if (keep) {
                ans = true;
            }
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def init
  x = 1
  while x < $n
    x <<= 1
  end
  $n = x
  $arr = Array.new(2*x-1, 0)
end

def update(i, x)
  i += $n - 1
  $arr[i] += x
  while i > 0
    i = (i - 1) / 2
    $arr[i] = $arr[i*2+1] + $arr[i*2+2]
  end
end

def query(a,b,k,l,r)
  if r <= a || b <= l then return 0
  end
  if a <= l && r <= b then return $arr[k]
  else
    vl = query(a, b, k*2+1, l, (l+r) / 2)
    vr = query(a, b, k*2+2, (l+r) / 2, r)
    return vl + vr
  end
end

$n, q = gets.split.map(&:to_i)
init
q.times do
  cmd, x, y = gets.split.map(&:to_i)
  x -= 1
  if cmd == 0 then update(x, y)
  else 
    y -= 1
    puts query(x, y+1, 0, 0, $n)
  end
end

Measured memory_bytes: 10856
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define	N	1000000007
 
int main()
{
	long long n, m, k,cost=0,t=1;
	cin >> n >> m >> k;
	for (long long i = 0; i < n; i++) cost = (cost + (1 + i) * i / 2 * m % N * m % N) % N;
	for (long long i = 0; i < m; i++) cost = (cost + (1 + i) * i / 2 * n % N * n % N) % N;
	for (long long i = 2; i <= n * m - 2; i++) cost = cost * i % N;
	for (long long i = 2; i <= k - 2; i++) t = t * i % N;
	for (long long i = 2; i <= (n * m - k); i++) t = t * i % N;
	for (long long x = N - 2; x > 0; t = t * t % N, x >>= 1)
		if (x & 1) cost = cost * t % N;
	cout << cost << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define inf 1000000000000000
#define md 998244353
#define endl "\n"


int main()
{
    fastio
    
  
  int n,count=0;
  cin>>n;
  string s,a="",b="";
  cin>>s;
  
  if(n%2==1)
  cout<<"No\n";
  
  else
  {
  
  for(int i=0;i<n/2;i++)
  {
  	a+=s[i];
  	b+=s[i+n/2];
  	// cout<<s[i]<<" "<<s[i+n/2]<<endl;
  	  //if(s[i]==s[i+n/2])
  	  //count++;
  }
  //cout<<a<<" "<<b;
  if(a==b)
  cout<<"Yes\n";
  else
  cout<<"No\n";
  
  }
  return 0;  
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}







/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  COMinit();
  ll n;
  cin>>n;
  ll ans=0;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  map<ll,ll> mp;
  vector<ll> sum(n+1,0);
  sum[0]=0;
  rep(i,n) sum[i+1]=sum[i]+v[i];
  rep(i,n+1){
    mp[sum[i]]++;
  }
  for(auto c:mp) ans+=c.second*(c.second-1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 27776
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, M; std::cin >> N >> M;
  std::priority_queue<LL> A;
  for (int i = 0; i < N; ++i) {
    LL v; std::cin >> v; A.push(v);
  }

  for (int m = 0; m < M; ++m) {
    LL v = A.top()/2;
    A.pop();
    A.push(v);
  }

  LL sum = 0;
  while(!A.empty()) {
    sum += A.top();
    A.pop();
  }
  std::cout << sum << std::endl;
}


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

struct UnionFind {
    int n, num;
    vector<int> sz, par;
    UnionFind() {}
    UnionFind(int n_) : n(n_), num(n_), sz(n_, 1), par(n_, 0) { iota(par.begin(), par.end(), 0); }
    int find(int x) { return x==par[x]? x:(par[x]=find(par[x])); }
    bool same(int a, int b) { return find(a)==find(b); }
    void unite(int a, int b) {
        a = find(a);
        b = find(b);
        if(a == b) return;
        if(sz[a] < sz[b]) swap(a,b);
        sz[a] += sz[b];
        par[b] = a;
    }
    int size(int a) { return sz[find(a)]; }
};

const int MAX_N=100005;
ll n, m;
ll A[MAX_N][2], answer[MAX_N];

ll cal(ll x) { return x*(x-1)/2; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> n >> m;
    rep(i, m) cin >> A[i][0] >> A[i][1];
    ll in = cal(n);
    UnionFind uf(n+1);
    for(int i=m-1; i>=0; i--) {
        answer[i] = in;
        int a=A[i][0], b=A[i][1];
        if(uf.same(a,b)) continue;
        in -= uf.size(a)*uf.size(b);
        uf.unite(a, b);
    }
    rep(i, m) cout << answer[i] << endl;
    return 0;
}


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

int main() {
	int N; cin >> N;
	int h[100010], dp[100010];
	for(int i=0; i<N; ++i) cin >> h[i];
	dp[0]=0; dp[1]=abs(h[1]-h[0]);
	for(int i=2; i<N; ++i) dp[i]=min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);
	cout << dp[N-1] << endl;
	return 0;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int K = in.nextInt();
        	int S = in.nextInt();
        	int count = 0;
        	for(int x = 0; x <= K; x++) {
        		for(int y = 0; y <= K; y++) {
            		if (x+y > S) {
            			break;
            		}
            		if (S - (x + y) <= K) {
            			count++;
            		}
        		}
        	}
        	out.println(count);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 22996
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
count = 0
for i in range(1, n + 1, 2):
    if len(make_divisors(i)) == 8:
        count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007

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

  if(N-1 == M || N == M-1){
    ll ret = 1;
    rep(i,N){
      ret *= i+1;
      ret %= MOD;
    }
    rep(i,M){
      ret *= i+1;
      ret %= MOD;
    }
    cout << ret << endl;
  }
  else if(N == M){
    ll ret = 1;
    rep(i,N){
      ret *= i+1;
      ret %= MOD;
    }
    rep(i,M){
      ret *= i+1;
      ret %= MOD;
    }
    ret *= 2;
    ret %= MOD;
    cout << ret << endl;
  }else{
    cout << 0 << endl;
  }
  
  
  return 0;
}


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

int a[10000005]={0};

int main()
{
    long long n,i,j,ans=0;

    cin>>n;

    for(i=1;i<=n;i++){
        for(j=i;j<=n;j=j+i){
            a[j]++;
        }
    }
    for(i=1;i<=n;i++){
        ans=ans+i*a[i];
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 42692
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll ans = -1 ;
	ll pre = -1 ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		if(pre+1<a){
			cout << -1 << endl ;
			return 0 ;
		}
		if(pre>=a){
			ans += a ;
		}else{
			ans++ ;
		}
		pre = a ;
	}
	cout << ans << endl ;
}



Measured memory_bytes: 256
<?php
  
  $S = trim(fgets(STDIN));
  $Q = trim(fgets(STDIN));

  $a = [];
  $b = [];
  $change = false;

  for($i=1;$i<=$Q;$i++){
    $Qn = trim(fgets(STDIN));
    if($Qn[0]=="1"){
      $change = !$change; 
    }else{
      list($q, $f, $c) = explode(" ", $Qn);
      if((!$change && $f=="1") || ($change && $f=="2")){
        $a[] = $c;
      }else{
        $b[] = $c;
      }
    }
  }

  $bsize = count($b);
  $asize = count($a);
  if($change){
    for($i=$bsize-1;$i>=0;$i--){
      echo $b[$i];
    }
    echo strrev($S);
    for($i=0;$i<$asize;$i++){
      echo $a[$i];
    }
  }else{
    for($i=$asize-1;$i>=0;$i--){
      echo $a[$i];
    }
    echo $S;
    for($i=0;$i<$bsize;$i++){
      echo $b[$i];
    }
  }


Measured memory_bytes: 20980
#include<bits/stdc++.h>
 
using namespace std;
#define MAXN   1000001 

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n;
cin>>n;

map<string,int>mp;

for(int i=0;i<n;i++)
{
	string s;
	cin>>s;
	mp[s]++;
}

cout<<"AC"<<" x "<<mp["AC"]<<endl;
cout<<"WA"<<" x "<<mp["WA"]<<endl;
cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
cout<<"RE"<<" x "<<mp["RE"]<<endl;

}

 
 

 


Measured memory_bytes: 3664
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;

main(){
    int n=in();
    vec a,b;
    int sei=0;
    rep(i,n){
        b.pb(in());
        if(b[i]>=0)sei++;
    }
    if(sei<=1){
        sort(all(b),greater<int>());
        int fi=b[0],m=b[0];
        rep(i,n-1){
            m-=b[i+1];  
        }
        cout<<m<<endl;
        rep(i,n-1){
            cout<<fi<<" "<<b[i+1]<<endl;
            fi-=b[i+1];
        }
        return 0;
    }
    sort(all(b),greater<int>());
    if(n==2){
        cout<<b[0]-b[1]<<endl;
        cout<<b[0]<<" "<<b[1]<<endl;return 0;
    }
    vector<pii> p;
    int m=0;
    rep2(i,1,n-1){
        if(i==n-1){
            p.pb({b[0],b[n-1]});
            b[0]-=b[n-1];
            continue;
        }
        if(b[i]<0){
            p.pb({b[0],b[i]});
            b[0]-=b[i];
        }
        else{
            p.pb({b[n-1],b[i]});
            b[n-1]-=b[i];
        }
    }
    cout<<b[0]<<endl;
    for(auto e:p){
        cout<<e.first<<" "<<e.second<<endl;
    }
}



Measured memory_bytes: 3188
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
ll m, n;
int main()
{
	while (~scanf("%lld%lld", &m, &n))
	{
		if (m == 1 && n == 1)
			printf("1\n");
		else if (m == 1 || n == 1)
			printf("%lld\n", max(m, n) - 2);
		else if (m == 2 || n == 2)
			printf("0\n");
		else
			printf("%lld\n", (m - 2) * (n - 2));
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, i;
  scanf("%d", &a);
  scanf("%d", &b);
  if (a < b) {
    for ( i = 0; i < b; i++) {
      printf("%d", a);
    }
    printf("\n");
  } else {
    for ( i = 0; i < a; i++) {
      printf("%d", b);
    }
    printf("\n");
  }
  return 0;
}


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

using namespace std;

int main()
{
  int D;
  cin >> D;
  while(D--){
    int m, n;
    cin >> m >> n;
    int sqsum = m*m + n*n;
    int cnt = 0;
    for(int p = 0; p*p <= sqsum; p++){
      for(int q = 0; q*q <= sqsum; q++){
	if(p*p + q*q < 1) continue;
	if((m*p+n*q) % (p*p+q*q) == 0 &&
	   (m*q-n*p) % (p*p+q*q) == 0) cnt++;
      }
    }
    cout << (cnt*2 > 8 ? 'C' : 'P') << endl;
  }
  return 0;
}

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

using namespace std;
int main(void)
{
  int h, w;
  cin >> h >> w;
  
  vector<string> s;
  for(int i=0; i<h; i++){
      string tmp;
      cin >> tmp;
      s.push_back(tmp);
  }
  
  for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
          char c = s[i][j];
          if(c == '#'){
              if((i == 0 || s[i-1][j]!='#') && (i==h-1 || s[i+1][j]!='#') && (j==0 || s[i][j-1]!='#') && (j==w-1 || s[i][j+1]!='#')){
                 cout << "No" << endl;
                 return 0;
              }
               
          }
          
      }
  }
  cout << "Yes" << endl;

  return 0;
}
    


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  if (K > 1) {
    cout << N - K << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <limits>
#include <climits>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;

ll field[6][250][250];
ll obj[250][250];
ll sx,sy,gx,gy;
ll n;
ll lx,ly;
ll ox = 125,oy = 125;
priority_queue<vl> pq;
ll ans = (1ll << 50);
ll dx[7] = {0, 1, 1, 0, -1, -1, 0};
ll dy1[7] = {1, 0, -1, -1, -1, 0, 0};
ll dy2[7] = {1, 1, 0, -1, 0, 1, 0};

int main(){
  cin >> sx >> sy >> gx >> gy;
  cin >> n;
  for(ll i = 0;i < n;i++){
    ll x,y;
    cin >> x >> y;
    obj[ox+x][oy+y] = 1;
  }
  cin >> lx >> ly;
  for(ll i = 0;i < 250;i++){
    obj[ox+lx+1][i] = 1;
    obj[ox-lx-1][i] = 1;
  }
  for(ll i = 0;i < 250;i++){
    obj[i][oy+ly+1] = 1;
    obj[i][oy-ly-1] = 1;
  }
  // for(ll i = 0;i < 250;i++){
  //   for(ll j = 0;j < 250;j++){
  //     cerr << obj[i][j];
  //   }
  //   cerr << endl;
  // }
  // cerr << 1 << endl;
  pq.push(vl({-0, sx, sy, 0}));
  while(!pq.empty()){
    ll cost = pq.top()[0];
    ll x = pq.top()[1];
    ll y = pq.top()[2];
    ll t = pq.top()[3];
    pq.pop();
    if(field[t][ox+x][oy+y]) continue;
    field[t][ox+x][oy+y] = 1;
    // cerr << t << " " << x << " " << y << " " << -cost << endl;
    if(x == gx && y == gy){
      ans = -cost;
      break;
    }
    ll *dy;
    if((x+1000000)%2 == 0) dy = dy1;
    else dy = dy2;
    for(ll i = 0;i <= 6;i++){
      // if(abs(x*y*t)%6 == i)cerr << " " << x+dx[i] << " " << y+dy[i] << " " << (t+1)%6 << endl;
      if(field[(t+1)%6][ox+x+dx[i]][oy+y+dy[i]] == 0 && obj[ox+x+dx[i]][oy+y+dy[i]] == 0){
        if(abs(x*y*t)%6 == i){
          pq.push(vl({cost, x+dx[i], y+dy[i], (t+1)%6}));
        }else{
          pq.push(vl({cost-1, x+dx[i], y+dy[i], (t+1)%6}));
        }
      }
    }
  }
  cout << (ans == (1ll << 50) ? -1 : ans) << endl;

  return 0;
}



Measured memory_bytes: 7532
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  
while(1){
  
  int a,b; char op;
  
  scanf("%d %c %d", &a, &op, &b);
  
  if(op=='?'){ break; }
  
  if(op=='+'){
    printf("%d\n",a+b);
    }
  else if(op=='-'){
    printf("%d\n",a-b);
    }
  else if(op=='*'){
    printf("%d\n",a*b);
    }
  else if(op=='/'){
    printf("%d\n",a/b);
    }
  
  }

}

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

#define ll long long

using namespace std;

int n, k, sol;
int main() {
    cin >> n >> k;
    int t;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        if (t >= k)
            sol++;
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
//    _____ _     _                _           _     _ _     _     
//    \_   \ |_  (_)___  __      _| |__   __ _| |_  (_) |_  (_)___ 
//     / /\/ __| | / __| \ \ /\ / / '_ \ / _` | __| | | __| | / __|
//  /\/ /_ | |_  | \__ \  \ V  V /| | | | (_| | |_  | | |_  | \__ \
//  \____/  \__| |_|___/   \_/\_/ |_| |_|\__,_|\__| |_|\__| |_|___/
//                                                                 
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll div_floor(ll a, ll b) {
	// use when ret <= a/b, (a and b can be -ve)
	return a / b - (((a ^ b) < 0) and a % b);
}
ll div_ceil(ll a, ll b) { 
	// use when ret >= a/b, (a and b can be -ve)
	return a / b + (((a ^ b) >= 0) and a % b);
}
const int sz=1e6+9;
string s,t;
int a,b;
string u;
map<string,int> m;

int main(){
	cin>>s>>t>>a>>b>>u;
	m[s]=a;
	m[t]=b;
	m[u]--;
	cout<<m[s]<< " "<<m[t];
	return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int x, y;
    cin >> x >> y;

    int x_2 = -x, y_2 = -y;

    // x to y
    ll ans = (x <= y)? y - x : INF;

    // x_2 to y
    ans = min(ans, (x_2 <= y)? y - x_2 + (ll)1 : INF);

    // x to y_2
    ans = min(ans, (x < y_2)? y_2 - x + (ll)1 : INF);

    // x_2 to y_2
    ans = min(ans, (x_2 < y_2)? y_2 - x_2 + (ll)2 : INF);

    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
d = []
for i in range(m):
    d.append(int(input()))
for i in range(n):
    ans = 0
    for j in range(m):
        ans += l[i][j] * d[j]
    print(ans)


Measured memory_bytes: 6016
#include <iostream>

using namespace std;

int main()
{
  int n, cnt;

  cin >> n;
  cnt = 0;
  for (int i = 0; i < n; i++) {
    int p1;
    cin >> p1;
    if (p1 != i+1) {
      cnt++;
    }
  }

  if (cnt <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  long double A; cin >> A;
  long double B; cin >> B;
  LL C = A * B;
  cout << C << endl;
}


Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String s;
        int m, h;
        Scanner sc = new Scanner(System.in);
        while(true){
            s = sc.next();
            if(s.equals("-")) break;
            m = sc.nextInt();
            for(int i = 0; i < m; i ++){
                h = sc.nextInt();
                s = s.substring(h) + s.substring(0, h);
            }
            System.out.println(s);
        }

    }
}



Measured memory_bytes: 26556
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, t, a, ans = 1;
    double nearest = INF;
    cin >> n >> t >> a;

    REP(i, n)
    {
        int h;
        cin >> h;

        double current = t - 0.006 * h;

        if (abs(current - a) < nearest)
        {
            ans = i + 1;
            nearest = abs(current - a);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def TtoF(a):
  r = ''
  while a >= 1:
    r += str(a%4)
    a = a // 4
  return r[::-1]
n,a,b,c = map(int,input().split())
l = [int(input()) for i in range(n)]
m = float('INF')
for i in range(1,4**n):
  cur = TtoF(i)
  cur = '0'*(n-len(cur)) + cur
  abc = [[] for i in range(3)]
  for j in range(n):
    if cur[j] != '3':
      abc[int(cur[j])].append(l[j])
  if [] in abc:
    continue
  else:
    m = min(m,10*(len(abc[0])-1)+abs(sum(abc[0])-a)+10*(len(abc[1])-1)+abs(sum(abc[1])-b)+10*(len(abc[2])-1)+abs(sum(abc[2])-c))
print(m)

Measured memory_bytes: 3064
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int l, r, d, ans = 0;
  cin >> l >> r >> d;
  REP2(int, i, l, r+1) if (i % d == 0) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
const int MAX=2e5+10;
const int modn=1e9+7;
typedef long long ll ;
#define int ll
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
int n,x,t;
string a,b;
int p[MAX];
void solve(){
    cin>>n;
   for(int i=0;i<n;i++)
       cin>>p[i];
   ll maxn=p[0];
   ll ans=0;
   for(int i=1;i<n;i++) {
       maxn=max(maxn,p[i]);
       ans += maxn-p[i];
   }
   cout<<ans;
}
signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5200
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;
import java.util.Map;
import java.util.HashMap;

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

                if(a>b){
                        System.out.println(a-1);
                }else{
                        System.out.println(a);
                }
        }
}

Measured memory_bytes: 21844
S = input()
if (int(S[:2])>12 or int(S[:2])==0) and (int(S[2:])>12 or int(S[2:])==0):
    print('NA')
elif (int(S[:2])<=12 and int(S[:2])!=0) and (int(S[2:])>12 or int(S[2:])==0):
    print('MMYY')
elif (int(S[2:])<=12 and int(S[2:])!=0) and (int(S[:2])>12 or int(S[:2])==0):
    print('YYMM')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
int group[55][55];
int parent(int n){
	int i=n/55,j=n%55;
	if(group[i][j]==-1)	return -1;
	return group[i][j]=(group[i][j]==n?group[i][j]:parent(group[i][j]));
}
void merge(int s,int t){
	int si=s/55,sj=s%55;
	s=parent(group[si][sj]);
	int ti=t/55,tj=t%55;
	t=parent(group[ti][tj]);
	group[t/55][t%55]=s;
}
bool isInside(int i,int j,int w,int h){
	if(i<0||h<=i)	return false;
	if(j<0||w<=j)	return false;
	return true;
}
const int dx[]={1,0,-1};
const int dy[]={1,0,-1};
int main(){
	while(true){
		int w,h;	cin>>w>>h;
		if(w==0)	break;
		for(int i=0;i<h;i++)	for(int j=0;j<w;j++)	group[i][j]=-1;
		for(int i=0;i<h;i++)	for(int j=0;j<w;j++){
			int c;	cin>>c;
			if(c==1)	group[i][j]=55*i+j;
		}
		for(int i=0;i<h;i++)	for(int j=0;j<w;j++){
			if(group[i][j]>=0){
				for(int x=0;x<3;x++)	for(int y=0;y<3;y++){
					int ni=i+dy[y],nj=j+dx[x];
					if(!isInside(ni,nj,w,h))	continue;
					if(group[ni][nj]>=0)	merge(55*i+j,55*ni+nj);
				}
			}
		}
		set<int> ret;
		for(int i=0;i<h;i++)	for(int j=0;j<w;j++)	ret.insert(parent(group[i][j]));
		ret.erase(-1);
		cout<<ret.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 3004
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int N,T; scanf("%d%d", &N, &T);
  int ans=1001;
  for (int n=0;n<N;n++){
    int c,t; scanf("%d%d", &c, &t);
    if (t>T) continue;
    ans=min(ans,c);
  }
  if (ans==1001) printf("TLE\n");
  else           printf("%d\n", ans);
}

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

using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;


    for(int i=0;i<n;i++) {
        ll cnt = 1;
        while(true) {
            if(i == n-1) break;
            if(a[i] == a[i+1]) {
                i++;
                cnt++;
            } else
                break;
        }
        ans += cnt%2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)

using namespace std;
typedef long long LL;
const int N=4005,mod=1000000007;
int n,m,k;
LL flv[N],inv[N],ans;

LL getmi(LL a,LL x)
{
	LL rt=1;
	while(x)
	{
		if(x&1) rt=rt*a%mod;
		a=a*a%mod,x>>=1;
	}
	return rt;
}

LL C(int n,int m)
{
	return n<m?0:flv[n]*inv[m]%mod*inv[n-m]%mod;
}

LL solve(int n,int k)
{
	return (C(n+k,n)-C(n+k,n+1))%mod;
}

int main()
{
	scanf("%d%d",&n,&k),m=n+k;
	flv[0]=1;
	rep(i,1,m) flv[i]=flv[i-1]*i%mod;
	inv[m]=getmi(flv[m],mod-2);
	repd(i,m,1) inv[i-1]=inv[i]*i%mod;
	ans=solve(n,k-1)-solve(n,k-2);
	ans=ans*getmi(2,max(0,n-k-1))%mod;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main (String[] args){
  
   int N,reverse=0,remaind,tmp;
    
   int a,b,x;
  
   Scanner sc = new Scanner (System.in);
   a=sc.nextInt();
   b=sc.nextInt();
   
   x=a+b;
   if(x%2==1){
     x=x/2 + 1;
   }
   else{
     x=x/2;
   }
    
   System.out.println(x);
   
  }
}

Measured memory_bytes: 23124
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		
		System.out.println(isPalindromicStr(nextString())?"Yes":"No");

	}
	
	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 087
	// https://atcoder.jp/contests/abc087/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[][] map = new int[2][n];
		
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				map[i][j] = sc.nextInt();
			}
		}
		
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				if (i == 0 && j == 0) {
					// Do not thing
				} else if (i == 0 && j > 0) {
					map[i][j] += map[i][j-1];
				} else if (i > 0 && j == 0) {
					map[i][j] += map[i-1][j];
				} else {
					map[i][j] += Math.max(map[i-1][j], map[i][j-1]);
				}
			}
		}
		
		System.out.println(map[1][n-1]);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 22740
/*    
 *  eat_code    
 *  IIIT Allahabad
 */
#include <bits/stdc++.h>
//#include "pretty_print.h"
using namespace std;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define CONTAINS(a, x) (a.find(x) != a.end())
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define nl cout << endl
#define F first
#define S second

#define what_is(x) cout << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define CASET int ___T, case_n = 1; scanf("%d", &___T); while (___T-- > 0) 

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef vector<vi> vvi;

ll INF = 1E9;
ll M = 1E9 + 7;

inline ll power (ll a,ll p){
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}

int main() {
    boost;
    if(fopen("input.txt", "r")){
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    }
    int n;
    cin >> n;
    vll l(n + 1);
    l[0] = 2;
    l[1] = 1;
    for(int i = 2;i <= n;i++)
        l[i] = l[i - 1] + l[i - 2];
    cout << l[n] << "\n";

    return 0;
}
//  Train Insane or Remain the same
 

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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int A,B,C;






int main()
{

	cin >> A>>B>>C;
	int ans;
	if(A==B){
		if(B==C){
			ans = 1;
		} else {
			ans = 2;
		}
	} else if(B == C){
		ans = 2;
	} else if(A == C){
		ans = 2;
	} else {
		ans = 3;
	}

	cout << ans;



}


Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
fl=0
c-=b
a-=d
if(a<=0 and c>0):
    fl=1
elif(c<=0 and a>0):
    fl=2
while(a>0 and c>0):
    c-=b
    a-=d
    if(a-d<=0 and c-b>0):
        fl=1
        break
    elif(a-d>0 and c-b<=0):
        fl=2
        break
if(fl==1):
    print("No")
else:
    print("Yes")

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

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

    int A, B;
    cin >> A >> B;

    int num = 2;
    int sum = 0;
    while (num--) {
        if (A > B) {
            sum += A;
            A--;
        } else {
            sum += B;
            B--;
        }
    }

    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 256