akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int prev[ 200000 + 1 ] ,next[ 200000 + 1 ] ;
int main()
{
    int n ,m ,q ;
    int a , r ,p = 0 ;
    int i ,j ;
    scanf( "%d %d %d", &n , &m , &q ) ;
    for( i = 0 ; i < n ; i++ )
    {
        prev[ i ] = ( i - 1 + n ) % n ;
        next[ i ] = ( i + 1 ) % n ;
    }
    for( i = 0 ; i < m ; i++ )
    {
        scanf( "%d", &a ) ;
        for( j = 0 ; j < a ; j++ )
        {
            p = a % 2 == 0 ? next[ p ] : prev[ p ] ;
        }
        r = p ;
        next[ prev[ p ] ] = next[ p ] ;
        prev[ next[ p ] ] = prev[ p ] ;
        p = next[ p ] ;
        next[ r ] = -1 ;
        prev[ r ] = -1 ;
    }
    for( i = 0 ; i < q ; i++ )
    {
        scanf( "%d", &a ) ;
        if( prev[ a ] == -1 )
        {
            printf( "0\n" ) ;
        }
        else
        {
            printf( "1\n" ) ;
        }
    }
    return 0 ;
}

Measured memory_bytes: 2144
using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;

namespace PastQuestions
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new Input(Console.In));
        }

        public void Solve(Input input)
        {
            var s = input.ReadLine;
            var strs = new string[] { "dream", "dreamer", "erase", "eraser" };
            var regex = new Regex("^((dream(er)?)|(erase(r)?))*$");
            if (regex.IsMatch(s)) {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }
        }
    }

    public class Input
    {
        private TextReader Stream { get; }
        private char Separator { get; }
        private Queue<string> InputStream { get; }

        public Input(TextReader stream, char separator = ' ')
        {
            Stream = stream;
            Separator = separator;
            InputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (InputStream.Count != 0) return InputStream.Dequeue();
                string[] tmp = Stream.ReadLine().Split(Separator);
                for (int i = 0; i < tmp.Length; ++i)
                    InputStream.Enqueue(tmp[i]);
                return InputStream.Dequeue();
            }
        }

        public string ReadLine => Stream.ReadLine();
        public int ReadInt => int.Parse(Read);
        public long ReadLong => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
        public int[] ReadIntArray => Stream.ReadLine().Split(Separator).Select(i => int.Parse(i)).ToArray();
        public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
    }
}


Measured memory_bytes: 21080
#include <iostream>
#include <vector>
#include <map>
#include <string>


using namespace std;
int main(){
    long long N;
    long long ans = 0;
    cin >> N;
    if(N == 1){
        cout << 0 << endl;
        return 0;
    }
    ans += 1;
    for(long long i = 3; i <= N; ++i){
        ans += i - 1;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n,m;
    cin >> n >> m;
    multimap <ll, int> ab;
    rep(i,0,n) {
        ll a;
        int b;
        cin >> a >> b; 
        ab.insert(make_pair(a,b));
    }
    ll ans =0;
    for(auto i = ab.begin(); i!= ab.end(); i++) {
        if (i->second >= m) {
            ans += m * i->first;
            break;
        } else {
            ans += i->second * i->first;
            m -= i->second;
        }
    }
    cout << ans << endl;
}

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


int main() {
	int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    long long ans=0;

    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        q.push(a);
    }
	
    rep(i,m){
        int b=q.top()/2;
        q.pop();
        q.push(b);
    }

    for(int i=0;i<n;i++){
        ans+=q.top();
        q.pop();
    }

    cout<<ans<<endl;
    
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[k-1];
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef pair<int,int> pp;
typedef vector<int> vec;
typedef vector<vec> mat;

int N,K,L;
const int MAX_N = 200010;

struct disjoint{
    vec p,r;
    disjoint(int n):p(n+1),r(n+1){
        for(int i=1;i<=n;i++){
            p[i] = i;
            r[i] = 1;
        }
    }
    int find(int x){
        if(p[x]==x)return x;
        return p[x] = find(p[x]);
    }
    void merge(int x,int y){
        x = find(x);
        y = find(y);
        if(r[x] < r[y])swap(x,y);
        p[y] = x;
        r[x] += r[y];
    }
};

map<pp,int> cache;

bool findElement(int x, vec& a){
    auto it = lower_bound(a.begin(),a.end(),x);
    return (it!=a.end() && *it==x);
}

int inter(int id0, int id1, vec& z0, vec& z1){
    pp key = pp(id0,id1);
    if(cache.find(key)!=cache.end()){
        return cache[key];
    }

    int ret = 0;
    for(int i:z0){
        if(findElement(i,z1))ret++;
    }
    cache[key] = ret;
    return ret;
}

int solve(int id0, int id1, vec& z0, vec& z1){
    if(z0.size() < z1.size()){
        return inter(id0, id1, z0, z1);
    }
    return inter(id0, id1, z1, z0);
}

int main(){
    
    scanf("%d%d%d",&N,&K,&L);

    disjoint z0(N), z1(N);
    int x,y;
    for(int i=0;i<K;i++){
        scanf("%d%d",&x,&y);
        z0.merge(x,y);
    }
    for(int i=0;i<L;i++){
        scanf("%d%d",&x,&y);
        z1.merge(x,y);
    }

    mat grp0, grp1;
    grp0.resize(N+1, vec());
    grp1.resize(N+1, vec());
    for(int i=1;i<=N;i++){
        grp0[z0.find(i)].push_back(i);
        grp1[z1.find(i)].push_back(i);
    }
    for(int i=1;i<=N;i++){
        sort(grp0[i].begin(),grp0[i].end());
        sort(grp1[i].begin(),grp1[i].end());
    }

    for(int i=1;i<=N;i++){
        x = z0.find(i);
        y = z1.find(i);
        printf("%d ",solve(x,y,grp0[x],grp1[y]));
    }
    return 0;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

const int m = 2019;

int main(void){
    
    ll a,b,c,k;
    cin >> a >> b >> c >> k;

    int ans = 0;
    if(k >= a){
        ans += a;
        if(k-a > 0 && k-a >= b){
            if(k-a-b > 0 && k-a-b >= c){
                ans -= c;
            } else {
                ans -= k-a-b;
            }
        }

    } else {
        ans += k; 
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll x,ll y){
    ll r;
    while((r=x%y) !=0){
        x=y;
        y=r;
    }
    return y;
}

ll lcm(ll x, ll y){
    x /= gcd(x,y);
    y /=gcd(x,y);
    return (x*y);
}

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

signed main(){
    int x,y;
    cin >> x;
    y=x;
    while(!prime(y)){
        y+=1;
    }
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;


///
struct PriorityQueue(alias _fun, T) {
    import std.functional : binaryFun;
    import std.algorithm : swap;
    alias fun = binaryFun!_fun;

    ///
    this(T[] ts) {
        foreach (t; ts) enqueue(t);
    }

    ///
    PriorityQueue!(_fun, T) enqueue(T e) {
        if (this.tree.length == 0) this.tree.length = 1;
        if (this.tree.length == this.n) this.tree.length *= 2;
        this.tree[this.n] = e;
        auto i = this.n;
        this.n += 1;
        while (i) {
            auto j = (i-1)/2;
            if (fun(this.tree[i], this.tree[j])) {
                swap(this.tree[i], this.tree[j]);
                i = j;
            } else break;
        }
        return this;
    }

    alias insertFront = enqueue;
    alias insert = enqueue;

    ///
    T dequeue() {
        auto ret = this.tree[0];
        this.n -= 1;
        this.tree[0] = this.tree[this.n];
        this.tree = this.tree[0..$-1];
        size_t i;
        for (;;) {
            auto l = i*2+1;
            auto r = i*2+2;
            if (l >= this.n) break;
            size_t j;
            if (r >= this.n) {
                j = l;
            } else {
                j = fun(this.tree[r], this.tree[l]) ? r : l;
            }
            if (fun(this.tree[j], this.tree[i])) {
                swap(this.tree[i], this.tree[j]);
                i = j;
            } else break;
        }
        return ret;
    }

    ///
    @property
    T front() {
        return this.tree[0];
    }

    ///
    @property
    bool empty() {
        return this.n == 0;
    }

    ///
    void popFront() {
        this.dequeue();
    }

    alias removeFront = popFront;

    ///
    @property
    size_t length() {
        return this.n;
    }

private:
    size_t n;
    T[] tree;
}

///
PriorityQueue!(fun, T) priority_queue(alias fun, T)(T[] ts = []) {
    return PriorityQueue!(fun, T)(ts);
}

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto VS = readln.split.to!(long[]);

    long r = long.min;
    foreach (i; 0..K+1) {
        foreach (j; 0..K-i+1) {
            auto rev = K-i-j;
            long sum;
            auto Q = priority_queue!("a < b", long)();
            foreach (ii; 0..min(i, N)) {
                sum += VS[ii];
                Q.enqueue(VS[ii]);
            }
            j = max(i, N-j);
            foreach (jj; j..N) {
                sum += VS[jj];
                Q.enqueue(VS[jj]);
            }
            foreach (_; 0..rev) {
                if (Q.empty) break;
                auto top = Q.dequeue();
                if (top > 0) break;
                sum -= top;
            }
            r = max(r, sum);
        }
    }
    writeln(r);
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


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

Measured memory_bytes: 3628
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W, d = mapint()
As = [list(mapint()) for _ in range(H)]
Q = int(input())

from collections import defaultdict
from itertools import accumulate
from bisect import bisect_left
dic = defaultdict(list)
for h in range(H):
    for w in range(W):
        a = As[h][w]
        dic[a%d].append((a, h, w))

cost_dic = {}
for m in dic.keys():
    dic[m].sort()
    sa, sh, sw = dic[m][0]
    cost_dic[m] = [0]
    for a, h, w in dic[m][1:]:
        cost = abs(h-sh)+abs(w-sw)
        cost_dic[m].append(cost)
        sa, sh, sw = a, h, w
    cost_dic[m] = list(accumulate(cost_dic[m]))

for _ in range(Q):
    l, r = mapint()
    sidx = bisect_left(dic[l%d], (l, 0, 0))
    eidx = bisect_left(dic[l%d], (r, 0, 0))
    print(cost_dic[l%d][eidx]-cost_dic[l%d][sidx])

Measured memory_bytes: 116488
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

void add(ll &a, ll b){
  a += b;
  if(a>=MOD) a -= MOD;
}

VI col_pl[210000];

signed main(){
	int n; cin>>n;
  VI c(n);
  rep(i,210000) col_pl[i].clear();
  // rep(i,n){
  //   VI col; col_pl.PB(col);
  // }
  rep(i,n){
    cin >> c[i];
    col_pl[c[i]].PB(i);
  }

  ll dp[n+1]; CLR(dp); dp[0]=1;
  reps(i,n){
    add(dp[i],dp[i-1]);
    int color = c[i-1];
    int it = lower_bound(ALL(col_pl[color]), i-1) - col_pl[color].begin();
    if(it>0){
      int j = col_pl[color][it-1];
      if((i-1)-j>1) add(dp[i],dp[j+1]);
    }
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define nl			    "\n";
#define w(x)            int x; cin>>x; while(x--)
#define fr(i,n)         for (int i = 0; i < n; ++i)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n;
int a[100002][3];
int dp[100002][3];


int solve(int i,int j)
{
	//base
	if(i==n) return 0;
	//lookup
	if(dp[i][j]!=-1) return dp[i][j];
	//rec
	int rel;
	int op1=INT_MIN,op2=INT_MIN,op3=INT_MIN;
	if(j!=0) op1=a[i][0]+solve(i+1,0);
	if(j!=1) op2=a[i][1]+solve(i+1,1);
	if(j!=2) op3=a[i][2]+solve(i+1,2);

	rel=max(op1,max(op2,op3));

	return dp[i][j]=rel;

}

int32_t main()
{
	FIO;

	cin>>n;
	
	fr(i,n){
		fr(j,3){
			cin>>a[i][j];
		}
	}
	memset(dp,-1,sizeof dp);

int ans=max(a[0][0]+solve(1,0),max(a[0][1]+solve(1,1),a[0][2]+solve(1,2)));
cout<<ans;




}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<P> X(N);
  vector<ll> ans(N);
  for (ll i = 0; i < N; i++) {
    ll x;
    cin >> x;
    X[i].first = x;
    X[i].second = i;
  }
  sort(X.begin(),X.end());
  for (int i = 0; i < N; i++) {
    if (i < N / 2) {
      ans[X[i].second] = X[N/2].first;
    } else {
      ans[X[i].second] = X[N/2 - 1].first;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

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

int main(){
  int k;
  string s;
  cin >> k>> s;
  string ans = "";
  if(s.length()<=k){
    ans = s;
  }else{
    ans = s.substr(0, k) + "...";
  }
  cout << ans;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const ldb PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;
const int INF = 1e9+7;
bool ok(string &s ,int l ,int r)
{
while(s[l]==s[r]) l++,r--;
return l>=r; 
}/*
ll por(ll a,int b)
{
ll res=1,M=998244353;
while(b)
{
if(b&1)
res=(res*a)%M;
a=(a*a)%M;
b/=2;
}
return res;
}
void rev(vector<int>&arr,int l,int r)
{
    for(;l<r;l++,r--) swap(arr[l],arr[r]);
}
*/
int prime[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89,97,101,103};
int add(int a,int b) // integer range
{
long x=a+b;
if(x>=INF)
x-=INF;
return x;
}
/*
goto e;


e:
;
*/
void solve()
{
int a,b,c; cin>>a>>b>>c;
cout<<c<<' '<<a<<' '<<b;
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()

ll bitsize(ll a){
    ll res = 0;
    while(a/2 > 0){
        res ++;
        a /= 2;
    }
    return res;
}


int main() {
    ll N,K; scanf("%lld%lld",&N,&K);
    ll A[100010];
    rep(i,N) scanf("%lld",&A[i]);
    ll L[50] = {0};
    rep(i,50){
        rep(j,N){
            if (A[j] & (ll(1)<<i)) {
                L[i]++;
            }
        }
    }
    ll S[50][2];
    rep(i,50){
        S[i][0] = pow(2,i)*L[i];
        S[i][1] = pow(2,i)*(N-L[i]);
    }
    ll DP[50][2];
    DP[49][0] = 0;
    DP[49][1] = -1;
    for(ll i=48;i>=0;i--){
        if (K & (ll(1)<<i)){
            DP[i][0] = DP[i+1][0] + S[i][1];
            if (DP[i+1][1] != -1)
                DP[i][1] = max(DP[i+1][0]+S[i][0],max(DP[i+1][1]+S[i][0],DP[i+1][1]+S[i][1]));
            else DP[i][1] = DP[i+1][0] + S[i][0];
        }
        else{
            DP[i][0] = DP[i+1][0]+S[i][0];
            if (DP[i+1][1] != -1)
                DP[i][1] = max(DP[i+1][1]+S[i][0],DP[i+1][1]+S[i][1]);
            else DP[i][1] = -1;
        }
    }
    cout << max(DP[0][0],DP[0][1]) << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
from itertools import product

h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
#print(S)
  
di = [-1, 0, 1, 0]
dj = [0, 1, 0, -1]

def update(vs, i, j, x, q):
  if vs[i][j] != -1 or S[i][j] == '#':
    return
  vs[i][j] = x
  q.append((i,j))

mx = 0
for i, j in product(range(h), range(w)):
  if S[i][j] == '#':
    continue
  q = deque([])
  vs = [[-1 for i in range(w)] for j in range(h)]
  update(vs, i, j, 0, q)
  while len(q) > 0:
    #print(q)
    #print(vs)
    # x += 1
    current_q = q.popleft()
    qi, qj = current_q[0], current_q[1]
    for k in range(4):
      ni, nj = qi + di[k], qj + dj[k]
      if not(0 <= ni < h) or not(0 <= nj < w):
        continue
      update(vs, ni, nj, vs[qi][qj]+1, q)
  for i, j in product(range(h),range(w)):
    if vs[i][j] == -1:
      continue
    mx = max(mx, vs[i][j])
print(int(mx))

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

using namespace std;

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

    double ans,sum;

    vector<int> mem(n);
    for (int i = 0; i < n; i++)
    {
        cin >> mem.at(i);
    }
    sort(mem.begin(), mem.end());
    sum = mem.at(0) + mem.at(1);
    for (int i = 2; i < n; i++)
    {
        sum /= 2;
        sum += mem.at(i);
    }
    ans = sum / 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C, *PQR = map(int, open(0).read().split())

P = sorted(PQR[:A], reverse=True)
Q = sorted(PQR[A:A + B], reverse=True)
R = sorted(PQR[A + B:], reverse=True)

print(sum(sorted(P[:X] + Q[:Y] + R, reverse=True)[:X + Y]))

Measured memory_bytes: 36236
#include <bits/stdc++.h>
using namespace std;
#define MAX 1400

struct Rectangle{
    // indexの地点の高さ
    int height;
    // 始点のX
    int pos;
};

// buf = Tの一行の配列
// size = Tの一行のサイズ
int getLargestRectangle(int w,int buf[]){
    // stackとして長方形を保存
    stack<Rectangle> s;
    int maxV = 0;
    // 配列の最後を0にすることで、範囲外後に最大面積を計算するようにする
    buf[w] = 0;
    // stoperまで回す
    for(int i = 0;i <= w;++i){
        Rectangle rect;
        // 高さ代入
        rect.height = buf[i];
        // 横の位置は計算を始める時点の位置
        rect.pos = i;
        // stack空ならば追加
        if(s.empty()){
            s.push(rect);
        }
        else{
            // stackのトップにあるrectの高さより高い場合
            if(s.top().height < rect.height){
                s.push(rect);
            }
            // stackのトップにあるrectの高さよりも低い場合(保存してあった最大の高さが無効になるので、無効になる高さの面積を計算する必要がある)
            else if(s.top().height > rect.height){
                // 新しく積むrectの幅を出すために保存しておく。
                int targetX = i;
                // スタックに入っているrectが対象のrectの高さ以上の場合最大面積を計算する
                while(!s.empty() && s.top().height >= rect.height){
                    Rectangle pre = s.top();
                    s.pop();
                    // 面積を計算する
                    int area = pre.height * (i - pre.pos);
                    maxV = max(maxV,area);
                    // 始点Xを入れ替える(stackに積むrectの高さは取り出したrectの高さよりも低いので、取り出した地点が、長方形を計算する際のX座標になる)
                    targetX = pre.pos;
                }
                rect.pos = targetX;
                s.push(rect);
            }
        }
    }
    return maxV;
}

int H,W;
// タイル情報を2次元で保存0:綺麗なタイル,1:汚れたタイル
char tiles[MAX][MAX];
// 高さを格納する2次元配列
int T[MAX][MAX];

int getLargestRectangle(){
    // 各々の地点における高さを格納するプロセス
    for(int i = 0;i < H;++i){
        for(int j = 0;j < W;++j){
            // 汚れたタイル
            if(tiles[i][j] == '*'){
                T[i][j] = 0;
            }
            else{
                // 対象のindex地点の高さを格納する
                // 上の地点 + 1の高さになる
                T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1;    
            }
        }
    }
    
    // 最大面積保存用
    int maxV = 0;

    for(int i = 0;i < H;++i){
        maxV = max(maxV,getLargestRectangle(W,T[i]));
    }
    return maxV;
}

int main(){
    while(1){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        
        for(int i = 0;i < H;++i){
            for(int j = 0;j < W;++j){
                scanf(" %c",&tiles[i][j]);
            }
        }
        printf("%d\n",getLargestRectangle());
    }
}


Measured memory_bytes: 6600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int l = (n-1)/2;
		int r = n/2;
		char c = s.charAt(l);
		while(0 <= l) {
			if(s.charAt(l) == c && s.charAt(r) == c) {
				l--; r++;
			}else {
				break;
			}
		}
		System.out.println(r);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26696
#include <cstdio>
char s[100][100];
int c[100][100],a,b,ans,cnt;
int d[2][2]={1,0,0,1};
void bfs(int x,int y)
{
    if(c[x][y]==0) cnt++;
    c[x][y]=1;
    s[x][y]='*';
    if((x==a-1)&&(y==b-1)) {ans=1;return ;}
   for(int i=0;i<2;i++)
    {
        int dx=x+d[i][0];
        int dy=y+d[i][1];
        if(s[dx][dy]=='#'&&dx>=0&&dx<a&&dy>=0&&dy<=b)
        {
            //s[dx][dy]='*';
            bfs(dx,dy);
        }
    }
   c[x][y]=0;
}
int main()
{
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        int acnt=0;
        for(int i=0;i<10;i++)
            for(int j=0;j<10;j++) c[i][j]=0;
        for(int i=0;i<a;i++)
         {
             scanf("%s",s[i]);
             for(int j=0;j<b;j++)
                if(s[i][j]=='#') acnt++;
         }
         ans=0;cnt=0;bfs(0,0);
         if(ans==1&&acnt==a+b-1) printf("Possible\n");
         else printf("Impossible\n");

    }
    return 0;
}


Measured memory_bytes: 128
def main():
    c_lst = [list(map(int, input().split())) for _ in range(3)]
    c1 = c_lst[0][0] + c_lst[1][1] + c_lst[2][2]
    c2 = c_lst[1][0] + c_lst[2][1] + c_lst[0][2]
    c3 = c_lst[2][0] + c_lst[0][1] + c_lst[1][2]
    
    if c1 == c2 and c2 == c3:
        print('Yes')
    else:
        print('No')
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
function main(input) {
	const args = input.split('\n');
	const A=parseInt(args[0],10);
	 B=parseInt(args[1],10);
	 C=parseInt(args[2],10);
	 X=parseInt(args[3],10);

	var count = 0;

    for (var a = 0; a <= A; ++a) {
        for (var b = 0; b <= B; ++b) {
            for (var c = 0; c <= C; ++c) {
                var sum = (a * 500) + (b * 100) + (c * 50);
                if (sum === X) ++count;
            }
        }
    }
    console.log(count);
}
   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32460
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	string a;
	cin >> a;
	if (a == "SUN") cout << 7;
	if (a == "MON") cout << 6;
	if (a == "TUE") cout << 5;
	if (a == "WED") cout << 4;
	if (a == "THU") cout << 3;
	if (a == "FRI") cout << 2;
	if (a == "SAT") cout << 1;
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, R;
  cin >> N >> R;
  int ans = R;
  if (N < 10)ans += 100 * (10 - N);
  cout << ans << endl;
}


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

void solve() {
	ll n; cin >> n;
	ll ans = 0;
	vector<ll> v;
	for (ll i = 1; i * (i + 1) / 2 <= ll(1e12); i++)v.push_back(i * (i + 1) / 2);
	int cnt = 0;
	while (n % 2 == 0) {cnt++; n /= 2;}
	if (cnt > 0)ans += int(upper_bound(v.begin(), v.end(), cnt) - v.begin());
	if (n == 1) {cout << ans << endl; return ;}
	for (ll i = 3; i * i <= n; i += 2) {
		cnt = 0;
		while (n % i == 0) {cnt++; n /= i;}
		if (cnt > 0)ans += int(upper_bound(v.begin(), v.end(), cnt) - v.begin());
	}
	if (n != 1)ans++;
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();



}

Measured memory_bytes: 19732
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int dp[440][440];
bool flag[440][440];
int main(){
  rep(i,0,440)fill(dp[i],dp[i]+440,BIG_NUM);
  int n,ma,mb;
  cin >> n >> ma >> mb;

  dp[0][0] = 0;
  rep(i,0,n){
    rep(i,0,440)fill(flag[i],flag[i]+440,false);
    int a,b,c;
    cin >> a >> b >> c;
    rep(j,0,401){
      rep(k,0,401){
        if(flag[j][k])continue;
        if(dp[j+a][k+b] > dp[j][k] + c){
          dp[j+a][k+b] = dp[j][k] + c;
          flag[j+a][k+b] = true;
        }
      }
    }
  }
  int count = 1;
  int res = BIG_NUM;
  while(count*ma < 401 and count*mb < 401){
    res = min(res,dp[ma*count][mb*count]);
    count++;
  }
  if(res == BIG_NUM){
    cout << -1 << endl;
    return 0;
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int MAX = 100099, INF = INT_MAX / 3;
int N, M, Q, vv[MAX], dd[MAX], cc[MAX], ans[MAX];
bool vis[MAX][11];
vi G[MAX];

void dfs(int u, int d, int c) {
    if (vis[u][d])return;
    vis[u][d] = true;
    if (!ans[u])ans[u] = c;
    if (d > 0)each(v, G[u]) {
        dfs(v, d - 1, c);
    }
}

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

    cin >> N >> M;

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cin >> Q;
    rep(i, Q) {
        cin >> vv[i] >> dd[i] >> cc[i];
    }
    for (int i = Q - 1; i >= 0; --i) {
        dfs(vv[i], dd[i], cc[i]);
    }

    for (int i = 1; i <= N; ++i)cout << ans[i] << endl;
}


Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <tuple>
#include <cmath>
#define rep(i, n) for(i = 0; i < (n); i++)
#define int long long
using namespace std;

int n;
int s[1 << 18];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, (1 << n)) cin >> s[i];
	sort(s, s + (1 << n));
	
	vector<int> vec;
	vec.push_back(s[(1 << n) - 1]);
	
	rep(i, n) {
		multiset<int> dict;
		multiset<int>::iterator it;
		
		rep(j, (1 << n)) dict.insert(s[j]);
		rep(j, (1 << i)) {
			it = dict.find(vec[j]);
			dict.erase(it);
		}
		rep(j, (1 << i)) {
			it = dict.lower_bound(vec[j]);
			if (it == dict.begin()) { cout << "No" << endl; return 0; }
			it--;
			vec.push_back(*it);
			dict.erase(it);
		}
		sort(vec.begin(), vec.end());
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 16800
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE s(n); rep(i, n)cin >> s[i];
	int sum = 0;
	rep(i, n)sum += s[i];
	if (sum % 10 == 0) {
		sort(ALL(s));
		rep(i, n) {
			if ((sum - s[i]) % 10 != 0) {
				cout << sum - s[i] << endl; return 0;
			}
		}
	}
	else {
		cout << sum << endl; return 0;
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
#include <map>

/*
\cap_{u,v} \cup_{i\in (u,v) path} E_i

g(N) = |{E | {u,v\in M | \cup_{i\in (u,v) path} E_i} = N}|
G(N) = |{E | {u,v\in M | \cup_{i\in (u,v) path} E_i} \subseteq N}|
     = |{E | {u,v\in M-N | \cap_{i\in (u,v) path} !E_i}}|
*/

int n, m;
std::vector<int> E[50];
int D[50][50];

long long int M[20];
long long int A[1<<20];
std::map<std::pair<int, int>, int> edges;

long long int dfs(int u, int v, int p){
  if(u == v) return 0;
  for(int x: E[u]){
    if(x == p) continue;
    long long int b = dfs(x, v, u);
    if(b != -1) return (1LL << edges[{u, x}]) | b;
  }
  return -1;
}

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n-1; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    E[a-1].push_back(b-1);
    E[b-1].push_back(a-1);
    edges[{a-1,b-1}] = i;
    edges[{b-1,a-1}] = i;
  }
  scanf("%d", &m);
  for(int i = 0; i < m; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    M[i] = dfs(a-1, b-1, -1);   
  }
  for(int i = 0; i < (1<<m); i++){
    A[i] = A[i&(i-1)] | M[__builtin_ctzll(i)];
  }
  for(int i = 0; i < (1<<m); i++){
    A[i] = 1LL << (n-1-__builtin_popcountll(A[i]));
  }
  long long int ans = 0;
  for(int i = 0; i < (1<<m); i++){
    ans += (1-2*__builtin_parity(i))*A[i];
  }

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


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;

ll yakusu(ll x, ll y, ll z){
  ll s = (x + z - 1) / z;
  ll t = y / z;
  ll u = t - s + 1;
  return u;
}

int main(){
  ll a, b; cin >> a >> b;
  ll c, d; cin >> c >> d;

  ll lc = (c * d) / __gcd(c, d);
  ll ans = yakusu(a, b, c) + yakusu(a, b, d) - yakusu(a, b, lc);
  cout << b - a + 1 - ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    map<ll, ll> vcnt, mcnt;
    rep(i, n) {
        vcnt[x[i]]++;
        mcnt[x[i] % m]++;
    }
    ll ans = mcnt[0] / 2;
    mcnt[0] = 0;
    reps(i, 1, m) {
        ll j = m - i;
        if (i == j) {
            ans += mcnt[i] / 2;
            mcnt[i] = 0;
        }
        else {
            ll tmp = min(mcnt[i], mcnt[j]);
            ans += tmp;
            mcnt[i] -= tmp;
            mcnt[j] -= tmp;
        }
    }
    for(auto &x : vcnt) {
        ll v = x.first % m;
        ll s = min(x.second / 2, mcnt[v] / 2);
        ans += s;
        mcnt[v] -= s * 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16184
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
  int N; cin >> N;
    map<string,int> mp;
    REP(i,N) {
        string s; cin >> s;
        mp[s] ++;
    }
    int cnt = 0;
    for(auto p:mp) {
        cnt = max(cnt, p.se);
    }
    vector<string> res;
    for(auto p:mp) {
        if(p.se==cnt) res.push_back(p.fi);
    }
    sort(all(res));
    for(string s:res) cout << s << endl;
    return 0;
}

Measured memory_bytes: 26868
import sys
input = sys.stdin.readline


def main():
    n, a, b = map(int, input().split())
    v = list(map(int, input().split()))
    
    dp = [[0, 0] for _ in range(n+1)]
    dp[0][1] = 1
    for i in range(n):
        for j in range(n-1, -1, -1):
            if dp[j][1]:
                if dp[j+1][0] < dp[j][0]+v[i]:
                    dp[j+1][0] = dp[j][0]+v[i]
                    dp[j+1][1] = dp[j][1]
                elif dp[j+1][0] == dp[j][0]+v[i]:
                    dp[j+1][1] += dp[j][1]
    
    index, value, count = a, dp[a][0], dp[a][1]
    for i in range(a+1, b+1):
        if value*i == index*dp[i][0]:
            count += dp[i][1]
        elif value*i < index*dp[i][0]:
            value = dp[i][0]
            index = i
            count = dp[i][1]
                
    print(value/index)
    print(count)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 66436
n, m = gets.split.map(&:to_i)
prefs = n.times.map{Array.new()}
city_by_year = {}
city_by_index = []
m.times do |i|
  p, y = gets.split.map(&:to_i)
  city_by_year[y] = [p]
  city_by_index << y
  prefs[p - 1] << y
end


prefs.each_with_index do |cities, i|
  cities.sort.each_with_index do |year, j|
    city_by_year[year] << j
  end
end
city_by_index.each do |y|
  printf("%06d%06d\n", city_by_year[y][0], city_by_year[y][1] + 1)
end


Measured memory_bytes: 35452
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>num(N,0);
  for(int i=0;i<N;i++){
    cin >> num[i];
  }
  
  vector<int>count(100002,0);
  for(int i=0;i<N;i++){
    if(num[i] == 0){
      count[0]++;
      count[1]++;
    }
    else{
      count[num[i] - 1]++;
      count[num[i]]++;
      count[num[i] + 1]++;
    }
  }
  
  int ans = 0;
  for(int i=0;i<100002;i++){
    if(ans < count[i])
      ans = count[i];
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N,T;
	cin>>N>>T;
	int c,t;
	int ans=9999;
	rep(i,N){
		cin>>c>>t;
		if(t<=T)ans=min(ans,c);
	}
	if(ans==9999) cout<<"TLE";
	else cout<<ans;
}

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

using namespace std;

const int Nmax = 102;
int n, a[3][Nmax], dp[3][Nmax];
int32_t main() {
   //ifstream cin("a.in");
   cin >> n;
   for(int i = 1; i <= 2; ++i)
    for(int j = 1; j <= n; ++j) cin >> a[i][j];
   dp[1][1] = a[1][1];
   for(int i = 1; i <= 2; ++i) {
      for(int j = 1; j <= n; ++j) {
         dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
      }
   }
   cout << dp[2][n];
}



Measured memory_bytes: 764
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N = 1e5 + 5; 
int dp[N]; 

void solve(int test) {
	int n,k ; cin >> n >> k ;
	int a[n+1]; rep(i,1,n+1) cin >> a[i] ;

	// dp[i] = 0 , second player wins, dp[i] = 1, first player wins

	for(int i = 0 ; i <= k ; ++i ) {
		for(int j = 1 ; j <= n ; ++j) {
			if(i - a[j] >= 0) {
				dp[i] = max(dp[i], 1 ^ dp[i-a[j]]) ;
			}
		}
	}

	if(dp[k]) cout << "First"; 
	else cout << "Second" ;
}

int32_t main() {
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif   

    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 4404
#include<cstdio>
#include<vector>
#include<stack>
using ll=long long;
using graph=std::vector<std::vector<int>>;
ll x[200000]={};
void dfs(const graph &g,std::vector<bool> &is_visited,int u){
	is_visited[u]=true;
	for(const auto &v:g[u]){
		if(!is_visited[v]){
			x[v]+=x[u];
			dfs(g,is_visited,v);
		}
	}
}
void dfs(const graph &g){
	std::vector<bool> is_visited(g.size(),false);
	dfs(g,is_visited,false);
}
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	graph g(n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		g[a-1].push_back(b-1);
		g[b-1].push_back(a-1);
	}
	for(int i=0;i<q;i++){
		int p,xi;
		scanf("%d%d",&p,&xi);
		x[p-1]+=xi;
	}
	dfs(g);
	for(int i=0;i<n;i++)printf("%lld ",x[i]);
	return 0;
}

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

int f(int a,int b) {
  int a_keta=1,b_keta=1;
  while (a/10!=0) {
    a_keta++;
    a/=10;
  }
  while (b/10!=0) {
    b_keta++;
    b/=10;
  }
  if (a_keta < b_keta) return b_keta;
  else return a_keta;
}

pair<int64_t,int64_t> yakusuu(int64_t n) {
  pair<int64_t,int64_t> ret;
  double start;
  start=sqrt(n);

  for (int64_t i=(int64_t)start+1;true;i--) {
    if (n%i==0) {
      ret=make_pair(i,n/i);
      break;
    }
  }
  return ret;
}

int main() {
  int64_t n;
  cin >> n;
  pair<int64_t,int64_t> r=yakusuu(n);
  cout << f(r.first , r.second) <<endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int N;
std::vector<vector<int> > G;

int postcount = 0;
int nowpoint = 0;
std::vector<int> in;
std::vector<int> mid;

void postorder(int i) {
    if (G[i][0] != -1) postorder(G[i][0]);
    if (G[i][1] != -1) postorder(G[i][1]);
    cout << i + 1;
    postcount++;
    if (postcount != N) {
        cout << " ";
    }
}


int dfs(int l, int r) {
    if (l == r) {
        return -1;
    }
    //cout << "l : " << l << ", r : " << r << endl;
    int now = in[nowpoint++];

    int j = 0;
    for (int i = l; i < r; i++) {
        if (now == mid[i]) {
            j = i;
            break;
        }
    }
    //cout << " j : " << j << endl;
    G[now][0] = dfs(l, j);
    G[now][1] = dfs(j + 1, r);
    return now;
}

int main() {

    cin >> N;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        temp--;
        in.push_back(temp);
    }

    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        temp--;
        mid.push_back(temp);
        G.push_back(vector<int>(2));
    }

    postorder(dfs(0, N));
    cout << endl;

    return 0;
}

Measured memory_bytes: 1224
s = list(input())
t = [a for a in "abcdefghijklmnopqrstuvwxyz"]
if "".join(s) == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    if len(s) < 26:
        for i in t:
            if i not in s:
                s += i
                break
        print("".join(s))
    else:
        i = 25
        p = s[i]
        while s[i - 1] > s[i] and i > 0:
            i -= 1
        q = ""
        for k in sorted(set(t) - set(s[:i])):
            if k > s[i - 1]:
                q = k
                break
        print("".join(s[:i - 1]) + q)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x;
	cin >> x;

	if (x >= 30) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3656
# https://atcoder.jp/contests/abc132/tasks/abc132_c
# C - Divide the Problems

n = int(input().split()[0])
d_list = list(map(int, input().split()))

sorted_d_list = sorted(d_list)

if sorted_d_list[int(n/2)-1] == sorted_d_list[int(n/2)]:
    ans = 0
else:
    abc_max = sorted_d_list[int(n/2)-1]
    arc_min = sorted_d_list[int(n/2)]
    k_min = abc_max + 1
    k_max = arc_min

    ans = k_max - k_min + 1

print(ans)


Measured memory_bytes: 14396
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int N = Integer.parseInt(sc.next());
        int[] d = new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(d);
        out.println(d[d.length/2] - d[(d.length/2)-1]);
        
        out.flush();
    }
}

Measured memory_bytes: 49148