akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};

ll dp[20][20];

int field[210][210];

int main () {

    int h,w;cin>>h>>w;

    rep(i,10) {
        rep(j,10) {
            cin>>dp[i][j];
        }
    }

    rep(i,h) {
        rep(j,w) {
            cin>>field[i][j];
        }
    }

    rep(k,10) {
        rep(i,10) {
            rep(j,10) {
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }

    ll ans=0;

    rep(i,h) {
        rep(j,w) {
            if (field[i][j]!=-1) {
                ans+=dp[field[i][j]][1];
            }
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1],x;
int head, tail, n;

void enqueue(P x){
 
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
   x=Q[head];
   head=(head+1)%LEN;
   return x;
}

int min(int a,int b){return (a<b)?a:b;}





int main(){
  int elaps = 0, c,time=0;
  int i, q=0;
  P u,y;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else printf("%s %d\n",u.name,elaps);
  }
  return 0;
}




Measured memory_bytes: 11900
A,B=map(int,input().split())
S=input()
res=0
if S[0:A].isdecimal() is False:
	res=1
if S[A] !='-':
	res=1
if S[A+1:].isdecimal() is False:
	res=1
if res==1:
	print('No')
else:
	print('Yes')
	

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (200000)

int n, m;
vector<int>e[N];
int a[N];
int p[N];



int main(void){
	int k;
	int x, y;
	long long z;
	long long s, ans;
	queue<int>q;
	scanf("%d %d", &n, &m);
	f(i, N){
		a[i] = 0;
		p[i] = 0;
	}
	f(i, n+m-1){
		scanf("%d %d", &x, &y);
		x--;
		y--;
		e[x].push_back(y);
		a[y]++;
	}
	f(i, n)if (a[i] == 0)q.push(i);
	while (!q.empty()){
		x = q.front();
		q.pop();
		f(i, e[x].size()){
			a[e[x][i]]--;
			if (a[e[x][i]] == 0){
				p[e[x][i]] = x+1;
				q.push(e[x][i]);
			}
		}
	}

	f(i, n)printf("%d\n", p[i]);

	return 0;
}


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

template<class TI, class TF>
TI bin_search(TI l, TI u, TF f) {
	while(u - l > 1) {
		TI c = (l + u) / 2;
		// if (f(c)) u = c;
		if (!f(c)) u = c;
		else l = c;
	}
	assert(l + 1 == u);
	// return u;
	return l;
}

int main() {
	int n;
	long long k;
	cin >> n >> k;
	vector<long long> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<pair<long long, int>> s(n+1);
	for(int i = 0; i < n; i++) {
		s[i+1] = {(s[i].first + a[i])%k, i+1};
	}
	for(int i = 0; i <= n; i++) {
		long long t = (s[i].first - i)%k;
		if (t < 0) t += k;
		s[i].first = t;
	}
	sort(s.begin(), s.end());
	int i = 0;
	long long ans = 0;
	for(; i <= n;) {
		long long r = s[i].first;
		vector<int> is;
		for(; i <= n; i++) {
			if (s[i].first == r) is.push_back(s[i].second);
			else break;
		}
		for(int i = 0; i < is.size(); i++) {
			int j = bin_search<int>(i, is.size(), [&](int c) {
					return is[c] < is[i] + k;
					});
			ans += j - i;
		}
	}
	cout << ans << endl;
}



	


Measured memory_bytes: 6136
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,d;
    cin>>n>>d;
    int cnt=0;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)cnt++;
    }
    cout<<cnt<<endl;
}


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

int main(){
  int N;
  float sum=0,kei;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  for(int i=0;i<N;i++){
    float a;
    a = (1.0/vec.at(i));
    sum += a;
  }
  kei = 1.0 / sum;
  cout << kei << endl;
}
     


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

signed main(void) {
    int N, M;
    cin >> N >> M;
    pair<int, int> drink[N];
    for (int i = 0; i < N; i++) {
        cin >> drink[i].first >> drink[i].second;
    }

    sort(drink, drink+N);
    int amount = 0, count = 0;
    for (int i = 0; i < N; i++) {
        amount += drink[i].first * drink[i].second;
        count += drink[i].second;
        if (count >= M) {
            amount -= drink[i].first * (count - M);
            break;
        }
    }

    cout << amount << endl;
}

Measured memory_bytes: 1792
import math

n, k = map(int, input().split())
ary = [i for i in range(n + 1)]
# print(ary)

mod = 10 ** 9 + 7

ans = 0
min_v = sum(ary[0:(k - 1)])
max_v = sum(ary[(n + 1 - (k - 1)):])
# print(min_v, max_v)
for i in range(k, n + 2):
    min_v += ary[i - 1]
    max_v += ary[(n + 1 - i)]
    # print(min_v, max_v)
    ans = (ans + max_v - min_v + 1) % mod

print(ans)


Measured memory_bytes: 18428
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll H, W;
bool okb(ll h, ll w){
    return 2 <= h && h <= H-1 && 2 <= w && w <= W-1;
}

int main(){
    ll N; cin >> H >> W >> N;
    map<PL, ll> cnt;
    REP(i, N){
        ll a, b; cin >> a >> b;
        FOR(j, -1, 2) FOR(k, -1, 2){
            ll ch = a+j, cw = b+k;
            if(okb(ch, cw)){
                cnt[PL(ch, cw)]++;
            }
        }
    }
    vl ans(10, 0); ll sum = 0;
    FORMAP(it, cnt){
        ans[it->ss]++;
        sum++;
    }
    ans[0] = (H-2) * (W-2) - sum;
    REP(i, 10) cout << ans[i] << endstr;
    return 0;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MOD 1e9+7
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

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

    /* (1, 0) or (1, 1) の状態で相手に渡せれば勝ち */
    /* これは、二つの山の数値の差が0 or 1の状態で渡し続ければ達成できる */

    if(abs(x-y) > 1){
        cout << "Alice" << endl;
    } else {
        cout << "Brown" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char *argv[])
{
	string S, T;

	cin >> S;
    cin >> T;

	int a = S.size(), b = T.size();

	for (int i = a - b; i >= 0; i--) {
		bool unrestorable = false;
		for (int j = 0; j < b; j++) {
			if (S[i + j] != T[j] && S[i + j] != '?') {
                unrestorable = true;
                break;
            }
		}
		if (unrestorable) continue;

		for (int j = 0; j < b; j++) {
			S[i + j] = T[j];
		}

		for (int j = 0; j < a; j++) {
			if (S[j] == '?') S[j] = 'a';
		}

		cout << S << endl;
		return 0;
	}

	cout << "UNRESTORABLE" << endl;
	return 0;
}


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

const int MAX_N = 303;

bool is_checked[MAX_N][MAX_N];
ll A[MAX_N][MAX_N], warshall[MAX_N][MAX_N];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
            warshall[i][j] = A[i][j];
        }
    }
    // ワーシャルフロイドで実際の最短距離の表を作成
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                warshall[i][j] = min(warshall[i][j], warshall[i][k] + warshall[j][k]);
            }
        }
    }
    // 実際の表とワーシャルフロイドで求めた表が異なるかチェック
    for (int i = 0; i < N; i++ ) {
        for (int j = 0; j < N; j++) {
            if (A[i][j] != warshall[i][j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    // もう一度ワーシャルフロイド
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                if (i == k || j == k) continue;
                if (A[i][j] == A[i][k] + A[k][j]) {
                    is_checked[i][j] = true;
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (!is_checked[i][j]) {
                ans += A[i][j];
                is_checked[i][j] = is_checked[j][i] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a!=b){
    if(a>b) cout << 2*a-1 << endl;
    else cout << 2*b-1 << endl;
  }
  else cout << a+b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll a;
  string b;
  cin >> a>>b;
  ll bb = (b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
  ll ans = a*bb;
  cout<<ans/100<<endl;
}


Measured memory_bytes: 3652
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	/**/
	public static void main(String[] args) {  
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int X = I.nextInt();
		int T = I.nextInt();
		long itr = ceil(N,X);
		O.pln(itr*T);
	}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x, long y) {return Math.abs(x-y);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(max(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				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());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 25628
//============================================================================
// Name        : abc124a.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int coins = 0;
	if(a != b){
		coins = max(a, b) * 2 - 1;
	}
	else {
		coins = max(a, b) * 2;
	}


	cout << coins << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N;

    cin >> N;

    float v[N];
    for ( int i = 0; i < N; i ++ ) {
        cin >> v[i];
    }

    sort( v, v+N );

 //   for( int i = 0; i < N; i ++ ) {
 //       cout << v[i] << " ";
 //   }
 //   cout << endl;

    float total = 0;
    for ( int i = 0; i < N-1; i ++ ) {
        v[i+1] = (v[i] + v[i+1]) / 2.0;
    }

    cout << v[N-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>

#define ll long long

using namespace std;

int main(){
    ll n,nn,x;
    
    while(cin >> n && n){
        bool minus = n<0, carry = false;
        int res[15], dig[15];
        int tmp,cnt=0;

        memset(res, 0, sizeof(res));
        memset(dig, 0, sizeof(dig));

        if(minus) n *= -1;
        while(n > 0){
            tmp = n%10;
            dig[cnt] = tmp;
            n /= 10;
            cnt++;
        }
        for(int i=0;i<15;i++){
            if(carry){
                if(res[i] >= 1){
                    res[i]--;
                }else{
                    res[i+1]++;
                    res[i] += 9;
                }
                carry = false;
            }
            if(!dig[i]) continue;
            
            if((i%2==0 && !minus) || (i%2 == 1 && minus)){
                res[i] += dig[i];
            }else{
                res[i+1]++;
                res[i] += 10-dig[i];
            }
            if(res[i] >= 10){
                res[i] %= 10;
                carry = true;
            }else{
                carry = false;
            }
        }

        string ret = "";
        for(int i=0;i<15;i++) ret += (char)(res[i] + '0');
        reverse(ret.begin(),ret.end());
        istringstream iss(ret);
        ll ans;
        iss >> ans;
        cout << ans << endl;
    }
}

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

int main() {
  string S;
  cin >> S;
  if(S[0]=='S') cout << "Cloudy" << endl;
  if(S[0]=='C') cout << "Rainy" << endl;
  if(S[0]=='R') cout << "Sunny" << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
table = list(itertools.permutations(sorted(P), N))
a = -1
b = -1
for i in range(len(table)):
    index = i + 1
    target = list(table[i])
    if target == P:
        a = index
    if target == Q:
        b = index
    if a > 0 and b > 0:
        break
print(abs(a - b))


Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];
  sort(v.begin(), v.end());
  cout << v[v.size()/2] - v[v.size()/2-1];
}

Measured memory_bytes: 640
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var K = cin.ReadInt;
            var ans = 0;
            if (K % 2 == 0)
            {
                ans = K * K / 4;
            }
            else
            {
                ans = ((K - 1) / 2) * ((K - 1) / 2 + 1);
            }
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            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 { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= K) ++ ans;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>

typedef long long ll;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  double v[n];
  for(int i = 0; i < n; i++) {
    int v_i;
    cin >> v_i;
    v[i] = (double) v_i;
  }
  sort(v, v + n);
  double cur = v[0];
  for(int i = 1; i < n; i++) {
    cur = (cur + v[i]) / 2.0;
  }
  cout << setprecision(10) << cur << "\n";
  return 0;
}



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

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

int dfs(string s) {
  if (stoll(s) > n) return 0;
  mp.clear();
  for (auto c : s) mp[c]++;
  if (mp['7'] > 0 && mp['5'] > 0 && mp['3'] > 0) {
    ans++;
  }

  dfs(s + "3");
  dfs(s + "5");
  dfs(s + "7");

  return 0;
}

int main() {
  cin >> n;
  dfs("0");
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
class Problem
{
    static void Main()
    {
        //--------------------------------input--------------------------------//

        var v=Array.ConvertAll(Console.ReadLine().Split(),Convert.ToInt32);

        //--------------------------------solve--------------------------------//

        Array.Sort( v );
        if(v[0] == v[1] && v[1] == 5 && v[2] == 7)
            Console.WriteLine( "YES" );
        else
            Console.WriteLine( "NO" );

    }




}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int D;
int s[367][27];
int c[27];
int last[27];

int main()
{
    cin >> D;
    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }
    for (int i = 1; i <= D; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
            last[j] = 0;
        }
    }
    vector<int> t;
    ll score, maxi;
    int best_i;

    for (int day = 1; day <= D; day++)
    {
        maxi = LLONG_MIN;
        best_i = -1;
        //dayまでのコスト計算
        for (int item = 1; item <= 26; item++)
        {
            score = s[day][item];
            for (int k = 1; k <= 26; k++)
            {
                score -= c[k] * (day - (k == item ? day : last[k]));
            }
            //dayからD日までのコスト計算
            for (int j = day; j <= day + 26; j++)
            {
                for (int k = 1; k <= 26; k++)
                {
                    score -= c[k] * (j - (k == item ? j : last[k]));
                }
            }
            if (score > maxi)
            {
                maxi = score;
                best_i = item;
            }
        }
        t.push_back(best_i);
        last[best_i] = day;
    }

    for (int i = 0; i < t.size(); i++)
    {
        cout << t[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3696
import sys
from collections import defaultdict, deque

def main():
    input = sys.stdin.readline
    N, W = map(int, input().split())
    A = [tuple(map(int, input().split())) for _ in range(N)]

    d = defaultdict(lambda: 0)
    q = deque()
    for a in A:
        while len(q) > 0:
            w0, v0 = q.popleft()

            w1 = w0 + a[0]
            v1 = v0 + a[1]

            if w1 <= W:
                d[w1] = max(d[w1], v1)

            d[w0] = max(d[w0], v0)

        if a[0] <= W:
            q.append(a)

        for key in d.keys():
            q.append((key, d[key]))

    ans = 0
    for key in d.keys():
        ans = max(ans, d[key])

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3844
#include <stdio.h>

int main(void) {
	int N;
	int answer;
	int count;
	int i;
	int k[10000];
	while (1) {
		count = 0;
		answer = 0;
		scanf("%d", &N);
		if( N == 0) break;
		
		for (i = 0; i < N; i++) {
			scanf("%d", &k[i]);
			if( k[i] <= 1) {
				count++;
				if( k[i] == 1)
					answer++;
			}
		}
		answer += N - count + 1;
		if( N - count == 0)
			printf("NA\n");
		else
			printf("%d\n", answer);
	}
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main(){
	int x;
	string w[]={"thu","fri","sat","sun","mon","tue","wed"};
	scanf("%d",&x);
	x=x%7;
	printf("%s\n",w[x].c_str());
}


Measured memory_bytes: 3268
//I Guds namn
#include <cstdio>

using namespace std;

int main()
{
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if(A <= C and C <= B)
		printf("Yes");
	else
		printf("No");
	printf("\n");
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

ll sum = 0;
stack<bool> ST;
int counter = 0;
char NUM[11];

ll recST(stack<bool> S){
    int len = S.size();
    ll K = 1;
    ll num = NUM[len] - '0';
    REP1(i,len){
        if (S.top()) K *= 10;
        else K = 1;
        S.pop();
        num += (NUM[len-1-i]-'0')*K;
    }
    return num;
}

//D = const.
void rec(int d,int D,bool p){
    if(d)ST.push(p);
    if(d == D){
        sum += recST(ST);
        ST.pop();
        return;
    }
    rec(d+1,D,0);
    rec(d+1,D,1);
    if(d)ST.pop();
}

int main(){
    cin >> NUM;
    int len = strlen(NUM);
    rec(0,len-1,0);
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;

ll solve(void);
ll gcd(ll x, ll y);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

ld a, b;

ll solve(void)
{
	cin >> a >> b;

	// n * (a - 1) + 1 >= b
	// n * (a - 1) >= b - 1
	// n = ceil( (b-1)/(a-1) );
	ll ans = ll(ceill((b - 1) / (a - 1)));
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 384
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, m = MII()
    ab = [MII() for _ in range(n)]
    cd = [MII() for _ in range(m)]
    for a,b in ab:
        minidx = 0
        mind = 4*(10**8)
        for i,(c,d) in enumerate(cd):
            dist = abs(a-c)+abs(b-d)
            if dist < mind:
                mind = dist
                minidx = i+1
        print(minidx)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3508
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val words = mutableSetOf<String>()

    val blue = mutableMapOf<String, Int>()
    repeat(n) {
        val s = readLine()!!
        words.add(s)
        blue[s] = blue.getOrPut(s) { 0 } + 1
    }

    val m = readLine()!!.toInt()
    val red = mutableMapOf<String, Int>()
    repeat(m) {
        val s = readLine()!!
        words.add(s)
        red[s] = red.getOrPut(s) { 0 } + 1
    }

    words.map {
        blue.getOrElse(it) { 0 } - red.getOrElse(it) { 0 }
    }.max()!!.let { println(if (it >= 0) it else 0) }

}


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

int N, M;
long long A[1003], B[1003], C[1003];

long long solve(int a, int b, int c)
{
    vector<long long> X;
    
    for(int i=1; i<=N; i++)
    {
        long long ans = 0;
        
        if(a == 1)
            ans -= A[i];
        else
            ans += A[i];
        if(b == 1)
            ans -= B[i];
        else
            ans += B[i];
        if(c == 1)
            ans -= C[i];
        else
            ans += C[i];
        
        X.push_back(ans);
    }
    
    long long ans = 0;
    sort(X.begin(), X.end());
    
    for(int i=N-1, j=0; j<M; i--, j++)
        ans += X[i];
    
    return ans;
}

int main() {
    
    cin >> N >> M;
    
    for(int i=1; i<=N; i++)
        cin >> A[i] >> B[i] >> C[i];
    
    long long ans = 0;
    
    for(int i=0; i<8; i++)
        ans = max(ans, solve((i&(1<<0)) > 0, (i&(1<<1)) > 0, (i&(1<<2)) > 0));
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
score = 0

for i in range(1, N+1):
    sums = i//10000 + (i%10000)//1000 + (i%1000)//100 + (i%100)//10 + i%10
    if sums >= A and sums<= B:
        score += i

print(score)


Measured memory_bytes: 2940
use std::io::stdin;
use std::iter::Iterator;
use std::collections::VecDeque;

fn solve(cin: &mut ConsoleInputWrapper) {
    let n: usize = cin.input().parse().unwrap();
    let k: i32 = cin.input().parse().unwrap();
    let mut ans = 0;
    for i in 0..n {
        let h: i32 = cin.input().parse().unwrap();
        if h >= k { ans += 1; }
    }
    println!("{}", ans);
}

//Other Functions Here

fn main() {
    let mut cin = ConsoleInputWrapper::new();
    solve(&mut cin);
}

fn min(a: i32, b: i32) -> i32 {
    if a < b { a } else { b }
}

fn max(a: i32, b: i32) -> i32 {
    if a > b { a } else { b }
}

struct ConsoleInputWrapper {
    queue: VecDeque<String>
}

impl ConsoleInputWrapper {
    fn new() -> ConsoleInputWrapper {
        ConsoleInputWrapper {
            queue: VecDeque::new()
        }
    }
    fn input(&mut self) -> String {
        if self.queue.len() <= 0 {
            let mut s = String::new();
            stdin().read_line(&mut s).unwrap();
            let list: Vec<&str> = s.split_whitespace().collect();
            for string in list {
                self.queue.push_back(String::from(string));
            }
        }
        self.queue.pop_front().unwrap()
    }
}

Measured memory_bytes: 12280
#include<bits/stdc++.h>
using namespace std;
int n, k, ans;
int a[101];
int main(){
    cin >> n >> k;
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0;j < d; j++){
            int temp;
            cin >> temp;
            a[temp]++;
        }
    }
    for(int i = 1; i<=n; i++){
        if(!a[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const ll MAX_S = 1000000;
int D;

vector<ll> cvec(26, 0);
vector< vector<ll> > smap(365, vector<ll>(26, 0));
vector<int> lastvec(26, 0);

ll Scalc(int today, int no, ll now) {
    vector<int> plastvec = lastvec;
    // cout << "no " << no << endl;
    // その日のコンテストの満足度
    now += smap.at(today).at(no);
    // コンテストが行われた記録
    plastvec.at(no) = (today+1);
    /*for(int k = 0; k < 26; ++k) {
        cout << plastvec.at(k) << " ";
    }
    cout << endl;*/
    // 行われなかったコンテストへの不満
    for(int k = 0; k < 26; ++k) {
        now -= (cvec.at(k)*((today+1) - plastvec.at(k)));
    }
    return now;
}

int main() {
    cin >> D;
    for(int i = 0; i < 26; ++i) cin >> cvec.at(i);
    for(int i = 0; i < D; ++i) {
        for(int j = 0; j < 26; ++j) {
            cin >> smap.at(i).at(j);
        }
    }

    vector<int> tvec(D, 0);
    ll ans = 0;
    for(int i = 0; i < D; ++i) {
        // 毎日どれを選ぶか決める
        ll sum = 0;
        int tmax = 0;
        for(int j = 0; j < 26; ++j) {
            ll chsum = Scalc(i, j, ans);
            if(sum < chsum) {
                // その日の一番を採用
                sum = chsum;
                tmax = j;
            }
        }

        // tmaxを採用する
        lastvec.at(tmax) = (i+1);
        ans = Scalc(i, tmax, ans);
        tvec.at(i) = tmax+1;
        // cout << "ttt " << tmax+1 << endl;
    }
    
    for(int i = 0; i < D; ++i) {
        cout << tvec.at(i) << endl;
    }
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

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

    int n;
    cin >> n;
    set<string> st;
    rep(i, n) {
        string s;
        cin >> s;
        st.insert(s);
    }
    int m;
    cin >> m;
    bool locked = true;
    rep(i, m) {
        string s;
        cin >> s;
        if (st.count(s)) {
            cout << (locked ? "Opened by " : "Closed by ") << s << endl;
            locked ^= 1;
        } else {
            cout << "Unknown " << s << endl;
        }
    }
}

Measured memory_bytes: 3240
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    double d,t,s;
    cin>>d>>t>>s;
    if(s>=d/t)
    {
        cout<<"Yes"<<'\n';
    }
    else
    {
        cout<<"No"<<'\n';
    }
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A == 5 && B == 5 && C == 7){
    cout << "YES" << endl;
  }
  else if(A == 5 && B == 7 && C == 5){
    cout << "YES" << endl;
  }
  else if(A == 7 && B == 5 && C == 5){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Long[] a = new Long[n + 1];
        Long[] b = new Long[n];
        Arrays.setAll(a, i -> Long.parseLong(sc.next()));
        Arrays.setAll(b, i -> Long.parseLong(sc.next()));
        sc.close();

        // 主処理
        long sum = Arrays.stream(a).mapToLong(i -> i).sum();
        for (int i = 0; i < n; i++) {
            long remain = Math.max(0, b[i] - a[i]);
            a[i] = Math.max(0, a[i] - b[i]);
            a[i + 1] = Math.max(0, a[i + 1] - remain);
        }
        long sumAfter = Arrays.stream(a).mapToLong(i -> i).sum();
        long result = sum - sumAfter;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 67320
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	vector<pair<int, int>> a;
	string s, t;
	cin >> s >> t;
	reverse(all(s));
	if(s == t) puts("YES");
	else puts("NO");
	return 0;
}


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

int main() {
    string S;
    ll ans = 0;
    cin >> S;
    ll idxW = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'W') {
            ans += i - idxW;
            idxW++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int T;
long long A, B, C, D;

long long gcd(long long int m, long long int n)
{
	// ユークリッドの方法
	while (m != 0 && n != 0)
	{
		if (m > n) m %= n;
		else       n %= m;
	}
	return max(m, n);
}//gcd

bool is_endless() {
	if (A < B) {
		return false;
	}
	else {
		if (D < B) {
			return false;
		}
		else {
			if (C >= B - 1) {
				return true;
			}
			else {
				long long a = A % B;
				if (a > C) {
					return false;
				}
				else {
					if (D == B) {
						return true;
					}
					else {
						long long g = gcd(B, D);
						long long M = B - g + a % g;
						if (M > C) {
							return false;
						}
						else {
							return true;
						}
					}
				}
			}
		}
	}
}

void solve() {
	string ans;

	cin >> T;
	for (int i = 0; i < T; i++)
	{
		cin >> A >> B >> C >> D;
		if (is_endless()) {
			ans = "Yes";
		}
		else {
			ans = "No";
		}
		cout << ans << "\n";
	}

}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int n,T;
	cin>>n>>T;
	vpi vec(n);
	vi a(n+1),b(n+1);
	int rk=INT_MAX;
	rep(i,0,n) cin>>vec[i].f>>vec[i].se,rk=min(rk,vec[i].f);
	Sort(vec);
	rep(i,0,n) a[i+1]=vec[i].f,b[i+1]=vec[i].se;
	int dp[n+1][T];
	memset(dp,0,sizeof(dp));         
	for(int i=1;i<=n;i++){
		for(int j=1;j<=T-1;j++){
			dp[i][j]=max(dp[i-1][j],j-a[i]>=0?dp[i-1][j-a[i]]+b[i]:0);
		}
	}
	ll ans=0;
	for(int i=n;i>=1;i--){
		ans=max(ans,dp[i-1][T-1]+b[i]);
	}
	cout<<ans;
 
 
 
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}

ll modpow(ll a,ll n,ll mod){
  ll ret=1;
  while(n>0){
    if(n&1) ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}

ll f(int n){
  if(n==0) return 1;
  ll x=f(n/2)*f(n/2)%1000000007;
  if(n%2) x*=2;
  return x;
}

ll c(int n,int x){
  ll a=1,b=1;
  REP(i,x){
    a*=n-i;
    a%=1000000007;
  }
  REP(i,x){
    b*=i+1;
    b%=1000000007;
  }
  return a*modpow(b,1000000007-2,1000000007);
}

int main()
{
  int n,a,b;
  cin>>n>>a>>b;

  ll ans=f(n)-1-c(n,a)-c(n,b);
  cout<<((ans%1000000007>=0)? ans%1000000007:ans%1000000007+1000000007)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBalance solver = new BBalance();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBalance {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), a[] = new int[n + 1], min = Integer.MAX_VALUE;
            for (int i = 1; i <= n; i++) {
                a[i] = s.nextInt() + a[i - 1];
            }
            for (int i = 1; i < n; i++) {
                min = Math.min(min, Math.abs((a[i] << 1) - a[n]));
            }
            w.println(min);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22996