akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M;
  cin >> N >> M;
  vector<pair<long long int,int>> AB(N);
  for (int i = 0; i < N; i++) {
    cin>>AB[i].first>>AB[i].second;
  }
  sort(AB.begin(),AB.end());
  int number_of_drink=0;
  int a=0;
  long long int ans=0;
  while(number_of_drink<M){
    ans+=AB[a].first*AB[a].second;
    number_of_drink+=AB[a].second;
    a++;
  }
  a--;
  int add = number_of_drink - M;
  ans=ans-add*AB[a].first;
  cout<<ans<<endl;

}


Measured memory_bytes: 1792
n = int(input())
a_lst = [0]*n
a_lst[0] = int(input())
a_lst[1] = int(input())
if a_lst[0] >= a_lst[1]:
    max = 0
    sec_max = 1
else:
    max = 1
    sec_max = 0

for i in range(2, n):
    a_lst[i] = int(input())
    if a_lst[i] > a_lst[max]:
        max = i
    elif a_lst[i] > a_lst[sec_max]:
            sec_max = i

for i in range(n):
    if i == max:
        print(a_lst[sec_max])
    else:
        print(a_lst[max])

Measured memory_bytes: 12508
#include<stdio.h>
#include<string.h>
int main(){
  char s[101];
  int i,cnt=0,cnt2=0;
  scanf("%s",s);
  int len=strlen(s);
  for(i=0; i<len; i=i+2){
    if(s[i]=='L'){
      cnt++;
    }
  }
  for(i=1; i<len; i=i+2){
    if(s[i]=='R'){
      cnt2++;
    }
  }
  if(cnt!=0 || cnt2!=0){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	bool check = false;
	check = (abs(a - c) <= d);
	check = check || (abs(a - b) <= d && abs(b - c) <= d);
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long sum(long long n)
{
    return n*(n+1)/2;
}
int main()
{
    int n;
    scanf("%d",&n);
    long long ans;
    ans=sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15;
    printf("%lld\n",ans);
}

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

int main(){
    int s, w;
    cin >> s >> w;
    if(s <= w){
    cout << "unsafe" << endl;
    }else
    {
        cout << "safe" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main{
  static char[][] pic;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    pic = new char[H][W];
    for(int i=0; i<H; i++){
      String str = sc.next();
      for(int j = 0; j<W; j++){
        pic[i][j] = str.charAt(j);
      }
    }
    for(int i=0; i<2*H; i++){
      for(int j=0; j<W; j++){
        int k = i/2;
        System.out.print(pic[k][j]);
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 26896
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        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++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2688
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys

n,k = map(int, sys.stdin.readline().rstrip().split())
hn = list(map(int, sys.stdin.readline().rstrip().split()))
dp = [-1] * n

dp[0] = 0
for i in range(1,n):
  for j in range(1,min(k+1,i+1)):
    ret = dp[i-j]+abs(hn[i-j]-hn[i])
    if (dp[i] > ret) or (dp[i] < 0):
      dp[i] = ret
print(dp[n-1])



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

int main()
{
  string str;
  int n, res = 0;

  cin >> n >> str;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    for (int j = 1; j < s.size(); j++){
      for (int k = 0; k < s.size(); k++){
        int ct = 0, d = 0;
        for (int m = k; m < s.size(); m += j){
          if (str[d] == s[m]){
            ct++;
            d++;
          }
          else {
            ct = d = 0;
          }
          if (ct == str.size()){
            res++;
            goto next;
          }
        }
      }
    }
next:;
  }
  cout << res << '\n';
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	//using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		string n ;
		cin>>n;
		for(int i=0;i<3;++i)
		{
			if(n[i]=='7')
			{
				cout<<"Yes";
				return 0 ;
			}

		}
		cout<<"No";
		return 0;
	}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<int MOD> struct modnum {
    int v;
    modnum() : v(0) {}
    modnum(ll _v) : v(_v % MOD) { if (v < 0) v += MOD; }
    explicit operator int() const { return v; }
    friend ostream& operator << (ostream& o, const modnum& n) { return o << n.v; }
    friend istream& operator << (istream& i, modnum& n) { ll v; i >> v; n = modnum(v); return i; }

    friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
    friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

    modnum& operator += (const modnum& o) { v += o.v; if (v >= MOD) v -= MOD; return *this; }
    modnum& operator -= (const modnum& o) { v -= o.v; if (v < 0) v += MOD; return *this; }
    modnum& operator *= (const modnum& o) { v = int(ll(v) * ll(o.v) % MOD); return *this; }
    modnum operator - () { modnum res; if (v) res.v = MOD - v; return res; }
    friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
    friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
    friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }

    modnum pow(int e) const {
        if (e == 0) return 1;
        if (e & 1) return *this * this->pow(e-1);
        return (*this * *this).pow(e/2);
    }

    modnum inv() const {
        int g = MOD, x = 0, y = 1;
        for (int r = v; r != 0; ) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }

        assert(g == 1);
        assert(y == MOD || y == -MOD);
        return x < 0 ? x + MOD : x;
    }
    modnum& operator /= (const modnum& o) { return (*this) *= o.inv(); }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= modnum(b); }
};
using mn = modnum<1000000007>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    string str;

    cin >> N >> str;

    vi ct(26);
    for (char c : str) {
        ct[c - 'a']++;
    }

    mn ans = 1;
    for (int v : ct)
        ans *= v + 1;
    cout << ans - 1 << endl;

    return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int main()
{
   int n,T,c,t;
    int ctemp=999999;
   scanf("%d %d",&n,&T);
   for(int i=0;i<n;i++){
    scanf("%d %d",&c,&t);
    if(c<ctemp&&t<=T){
            ctemp=c;
        }
    }
   if(ctemp==999999){
   printf("TLE");
   }
   else printf("%d",ctemp);
    return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  long int N;
  cin >> N;
  for(int n=1; n<3501; n++){
    for(int h=1; h<3501; h++){
      long int num = N * h * n;
      long int den = 4*h*n - N*(n+h);
      if (den > 0 && num % den == 0){
        cout << n <<" "<< h <<" " << num / den << endl;
        exit(0);
      }
    }
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 150010
#define LL long long 
#define INF 0x3f3f3f3f

int a,b,c,d;

int main(){
	//freopen("test.in","r",stdin);
	
	cin>>a>>b>>c>>d;
	int x=c-a,y=d-b;
	
	cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
	
	

	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<string>A(N);
  set<string>S;
  rep(i,N){
    cin>>A[i];
    S.insert(A[i]);
  }
  cout<<S.size()<<endl;
}

Measured memory_bytes: 25068
//BISMILLAHIR RAHMANIR RAHIM
//RABBI ZIDNI ILMA
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define endl "\n"
#define inf (1LL<<61)
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(0);cout<< fixed<< setprecision(10);
#define DEBUG(x) cout<<"["<<#x<<": "<<x<<"]\n"
#define DEBUG2(x, y) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]\n"
#define DEBUG3(x, y, z) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]\n"
#define DEBUG4(x, y, z, k) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]"<<"  ["<<#k<<": "<<k<<"]\n"

const ll N = 1e5 + 9;

int main()
{
    fastio
    ll n;
    cin>> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>> a[i];
    ll ans = 0;
    for(int i=1; i<n; i++){
        if(a[i-1] > a[i]){
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }

    }
    cout<< ans;
}



Measured memory_bytes: 4836
from collections import defaultdict, deque

V, E = map(int, input().split())

graph = defaultdict(dict)
for _ in range(E):
  a, b = map(int, input().split())
  graph[a][b] = True
  graph[b][a] = True

components = []				# list of components
visited = set()

for i in range(1, V+1):
  if i in visited:
    continue
  
  # do bfs starting from i
  current_component = set()
  queue = deque([i])
  visited.add(i)

  while queue:
    x = queue.popleft()
    
    current_component.add(x)
    
    for nbr in graph[x]:
      if nbr not in visited:
        queue.append(nbr)
        visited.add(nbr)
  
  components.append(current_component)

print(max(map(len, components)))

Measured memory_bytes: 127280
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    int res;
    if(n % 2 == 0)res = n/2;
    else res = (n+1)/2;

    if(res >= k)cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

int main(){
  int A,B,M;
  cin >>A >>B >>M;
  vector<int> a(A), b(B);
  rep(i,A) cin >>a[i];
  rep(i,B) cin >>b[i];
  vector<vector<int>> c(M, vector<int>(3));
  rep(i,M){
    rep(j,3){
      cin >>c[i][j];
    }
  }
  int amin=1e8, bmin=1e8;
  rep(i,A){
    amin = min(amin, a[i]);
  }
  rep(i,B){
    bmin = min(bmin, b[i]);
  }
  int curMin = amin + bmin;
  rep(i,M){
    curMin = min(curMin, a[c[i][0]-1]+b[c[i][1]-1]-c[i][2]);
  }
  cout << curMin << endl;
  return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
  ull X;
  cin >> X;
  ull ans = 0, yokin = 100;
  while (yokin < X) {
      yokin += yokin * 0.01;
      ans++; 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <vector>
#include <string>

using namespace std;


class Node {
 public:
  Node *prev;
  Node *next;
  int value;
  Node(int value) {
    this->value = value;
    prev = NULL;
    next = NULL;
  }
};

class LinkedList {
  Node *first;
  Node *last;
  int count;
 public:
  void insert(int x);
  void find_delete(int x);
  void deleteFirst();
  void deleteLast();
  void show();
  LinkedList();
};

LinkedList::LinkedList() {
  first = NULL;
  last = NULL;
  count = 0;
}

void LinkedList::insert(int x) {
  Node *node = new Node(x);
  if (count == 0) {
    last = node;
    first = node;
  } else {
    first->prev = node;
    node->next = first;
    node->prev = NULL;
    first = node;
  }
  count++;
}

void LinkedList::find_delete(int x) {
  Node *ptr = first;
  while (ptr != NULL) {
    if (ptr->value == x) {
      Node *prev = ptr->prev;
      Node *next = ptr->next;
      if (prev != NULL) {
        prev->next = next;
      }
      if (next != NULL) {
        next->prev = prev;
      }
      if (ptr == first) {
        first = next;
      }
      if (ptr == last) {
        last = prev;
      }
      delete ptr;
      count--;
      break;
    }
    ptr = ptr->next;
  }
}

void LinkedList::deleteFirst() {
  Node *tmp = first;
  first = tmp->next;
  if (first != NULL) {
    first->prev = NULL;
  }
  delete tmp;
  count--;
}

void LinkedList::deleteLast() {
  Node *tmp = last;
  last = tmp->prev;
  if (last != NULL) {
    last->next = NULL;
  }
  delete tmp;
  count--;
}

void LinkedList::show() {
  Node *ptr = first;
  while (ptr != last) {
    cout << ptr->value << " ";
    ptr = ptr->next;
  }
  cout << ptr->value << endl;
}

int main() {
  int N;
  scanf("%d", &N);
  char operation[20];
  int key;
  LinkedList list;
  for (int i = 0; i < N; ++i) {
    scanf("%s%d", operation, &key);
    if (operation[0] == 'i') {
      list.insert(key);
    } else if (operation[6] == 'F') {
      list.deleteFirst();
    } else if (operation[6] == 'L') {
      list.deleteLast();
    } else {
      list.find_delete(key);
    }
  }
  list.show();
}

Measured memory_bytes: 32360
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll MaxCD(ll a, ll b) {
  if (a < b)
    swap(a, b);
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
int main(void){
	ll i,n,x,sum;
	cin>>n>>x;
	ll xs[n];
	for(i=0;i<n;i++){cin>>xs[i];xs[i]=abs(x-xs[i]);}
	sum=xs[0];
	for(i=1;i<n;i++)sum=MaxCD(sum,xs[i]);
	cout<<sum<<endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
int P[3][3];
bool ans = false;
using namespace std;
int find(int N ,int B[], int tag) {
    for (int i= 0;i<N;i++){
        if(tag == B[i]) return 1;
    }
    
    return 0;
}
int main() {
       int Bn = 0;
       for (int i= 0;i<3;i++){
           for (int j= 0;j<3;j++){
             cin>>P[i][j];
           }
       }
       cin>>Bn;
       int B[Bn];
        for (int i= 0;i<Bn;i++){
            int tmp;
            cin>>tmp;
            B[i] = tmp;
       }
    for (int i= 0;i<3;i++){
        for (int j= 0;j<3;j++){
                if (find(Bn,B,P[i][0])+find(Bn,B,P[i][1])+find(Bn,B,P[i][2]) == 3)
                    ans = true;
                if (find(Bn,B,P[0][j])+find(Bn,B,P[1][j])+find(Bn,B,P[2][j]) == 3)
                    ans = true;
        }
    }
    if (find(Bn,B,P[0][0])+find(Bn,B,P[1][1])+find(Bn,B,P[2][2]) == 3)
        ans = true;
    if (find(Bn,B,P[2][0])+find(Bn,B,P[1][1])+find(Bn,B,P[0][2]) == 3)
        ans = true;
    if (ans) {
        cout<<"Yes"<<endl;
    }else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
const long long inf = (long long)1e6;

map<long long,int> mp;
map<int,int> l;
int n,a[100007],b[100007];
vector<int> v[100007];
int vis[100007];

int c = 0;
void solve(int r){

    l.clear();
    int x = v[r].size();
    vis[r] = 1;
    if(x>c) c = x;
    for(int i = 0;i < x;i++){
        if(mp[v[r][i]*inf+r]) l[mp[v[r][i]*inf+r]] = 1;
    }
    int cnt = 1;
    for(int i = 0;i < x;i++){
        if(!vis[v[r][i]]){
            while(l[cnt]) cnt++;
            mp[v[r][i]*inf+r] = cnt;
            mp[r*inf+v[r][i]] = cnt;
            cnt++;
        }
    }
    for(int i = 0;i < x;i++){
        if(!vis[v[r][i]]) solve(v[r][i]);
    }
}

int main(){

    cin >> n;
    for(int i = 0;i < n-1;i++){
        cin >> a[i] >> b[i];
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    solve(1);
    cout << c << endl;
    for(int i = 0;i < n-1;i++){
        cout << mp[a[i]*inf+b[i]] << endl;
    }
}


Measured memory_bytes: 19840
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    long double A, B, H, M;
    cin >> A >> B >> H >> M;

    double rad_a = (H + M / 60) / 12 * 2 * M_PI;
    double rad_b = M / 60 * 2 * M_PI;

    double ans = sqrt(A * A + B * B - 2 * A * B * cos(abs(rad_a - rad_b)));

    print(ans);
    
}


Measured memory_bytes: 4252
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
	var C = 1e+9 +7;
	var C2 = 1e+5;
	var X = parseInt(input[0][0], 10);
	var Y = parseInt(input[0][1], 10);
	var ans = 0;
	var n = (X + Y) / 3;
	var r = (4*X - 2*Y) / 6;
	var r2 = (4*Y - 2*X) / 6
	if (r >= 0 && r2 >= 0 && Number.isInteger(r)){
		var tmp = nCr_amari(n, r, 1, C, C2);
		ans = tmp[0];
	}
	console.log(ans);
}

function kakeruR(a, b, C, C2){
    var tmpQ, tmpR, ans;
    tmpQ = (b / C2 | 0);
    tmpR = b - (tmpQ * C2);
    ans = (a * tmpQ % C) * C2 % C + (a * tmpR);
    ans %= C;
    return ans;
}


function nCr_amari(n, k, MAX, MOD, C2) { //return [nCk, n+1Ck+1, ..., n+maxCk+max]
    // 前処理
    var v_ans = [ ];
    var fac, finv, inv;
    fac = [1,1];
    finv = [1,1];
    inv = [0,1];
    for (var i = 2; i < MAX + n; i++){
        fac.push(fac[i - 1] * i % MOD);
        inv.push(MOD - kakeruR(inv[MOD%i], (MOD / i | 0), MOD, C2) % MOD);
        finv.push(kakeruR(finv[i - 1],inv[i] ,MOD,C2));
    }
    //二項係数計算
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    for (var i = 0; i < MAX; i++){
    v_ans.push(kakeruR(kakeruR(fac[n + i] , finv[k + i],MOD,C2), finv[n - k],MOD,C2));
    }
    return v_ans;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;
    vector<long long>h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }

    sort(h.begin(), h.end());
    long long res = 1LL << 60;
    for(int i = 0; i+k-1 < n; i++) {
        res = min(res, h[i+k-1] - h[i]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int N, X;
  int mm = 1000;
  int sum = 0;
  cin >> N >> X;

  for (int i = 0; i < N; i++) {
    int M;
    cin >> M;
    mm = min(mm, M);
    sum += M;
  }

  printf("%d", N + (X - sum) / mm);
}


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


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> swc(n+1,vector<ll>(m+1,0));


    FOR(i,1,m+1){
      ll k;
      cin>>k;
      FOR(j,0,k){
        ll in;
        cin>>in;
        swc[in][i] = 1;
      }
    }

    vector<ll> p(m+1);
    FOR(i,1,m+1)cin>>p[i];

    ll ans = 0;
    FOR(i,0,1<<n){
      vector<ll> lmp(m+1);
      FOR(j,1,n+1){
        if(i & (1<<(j-1)) ){
          FOR(l,1,m+1){
            lmp[l] += swc[j][l];
          }
        }
      }

      ll flag = 1;
      FOR(j,1,m+1){
        if(lmp[j]%2 != p[j])flag=0;
      }
      ans += flag;
    }
    cout<<ans<<endl;

}


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

int main()
{
	string S;
	cin >> S;

	long len = S.length();
	if (S[len - 1] == 's')
	{
		cout << S << "es" << endl;
	}
	else
	{
		cout << S << "s" << endl;
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    string ans;
    ans = a+b+c > 21 ? "bust" : "win";
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n; cin>>n;
        set<int> s;
        rep(i,n)
        {
                int d; cin>>d;
                s.insert(d);
        }
        cout<<s.size()<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    vector<bool> dp(k+1);
    for(int stones =0 ;stones<=k; stones++){
        for(int i=0; i<n;i++){
            if(stones-arr[i]>=0 && !dp[stones-arr[i]])
                dp[stones] = true;
        }
    }
    puts(dp[k] ? "First": "Second");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(ll a,ll b,ll ar,ll br){
  return ar+(br-ar+b)%b*modinv(a,b)%b*a;
}
ll garner2(ll a,ll b,ll ar,ll br){
  ll ret=(ar+(br-ar)*moddiv(1,a,b)%b*a)%(a*b)-1;
  return (ret+a*b)%(a*b);
}

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}





int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (gcd(val0,val1)==1){
        ll ans0=garner2(val0,val1,1,0);
        ll ans1=garner2(val0,val1,0,1);
        if (ans0>1)
          ans=min(ans,ans0);
        if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }


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

Measured memory_bytes: 7060
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	vector<int> a(5);
	int max = 0;
	int kazu = 0;
	rep(i,5){
		cin >> a[i];
		int amari;
		if(a[i]%10 == 0) amari = 0;
		else amari = 10-(a[i]%10);
		if(amari >= max){
			max = amari;
			kazu = i;
		}
	}
	int ans = 0;
	rep(i,5){
		if(i == kazu) continue;
		else{
			if(a[i]%10 == 0) ans+=a[i];
			else ans+= ((a[i]/10)*10 + 10);
		}
	}
	cout << ans+a[kazu] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;

VVL mulmat(VVL A, VVL B){
    int n = A.size();
    VVL C(n, VL(n));
    REP(i,n) REP(j,n) REP(k,n) (C[i][j] += A[i][k] * B[k][j]) %= mod;
    return C;
}

VVL powmat(VVL A, ll x){
    int n = A.size();
    VVL B(n, VL(n));
    REP(i,n) B[i][i] = 1;
    while (x) {
        if (x & 1) B = mulmat(B, A);
        A = mulmat(A, A);
        x >>= 1;
    }
    return B;
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    VVL A(n, VL(n));
    REP(i,n) REP(j,n) A[i][j] = in();

    A = powmat(A, k);
    ll ans = 0;
    REP(i,n) REP(j,n) ans = (ans + A[i][j]) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
ant = []
for i in range(5):
    ant.append(int(input()))

k = int(input())
per = True
for i in range(len(ant)):
    for j in range(i, len(ant)):
        if abs(ant[i] - ant[j]) > k:
            per = False
            break

if per == True:
    print('Yay!')
else:
    print(':(')



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> grid(H, vector<char>(W));
  for (int i=0; i<H; ++i) {
    for (int j=0; j<W; ++j) {
      cin >> grid[i][j];
    }
  }
  bool flg = false;
  for (int i=0; i<H; ++i) {
    if (flg) {
      break;
    }
    for (int j=0; j<W; ++j) {
      if (grid[i][j] == '#') {
        int search = 0;
        for (int k=-1; k<=1; k+=2) {
          if (i + k == -1 || i + k == H) {
            ++search;
            continue;
          }
          if (grid[i+k][j] == '#') {
            break;
          } else {
            ++search;
          }
        }
        for (int l=-1; l<=1; l+=2) {
          if (j + l == -1 || j + l == W) {
            ++search;
            continue;
          }
          if (grid[i][j+l] == '#') {
            break;
          } else {
            ++search;
          }
        }
        if (search == 4) {
          flg = true;
          break;
        }
      }
    }
  }
  if (!flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
while True:
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    E = [list(map(int, input().split())) for i in range(n)]
    ans=0
    for x in range(n-2):
        for y in range(m-2):
            for w in range(3,n-x+1):
                
                for h in range(3,m-y+1):
                    N=0
                    A=E[x][y]
                    B=0
                    for i in range(w):
                        for j in range(h):
                            if i==0 or j==0 or j==h-1 or i==w-1:
                                A=min(A,E[x+i][y+j])
                            else:
                                B=max(B,E[x+i][y+j])

                    if A>B:
                        for i in range(w):
                            for j in range(h):
                                if i!=0 and j!=0 and j!=h-1 and i!=w-1:
                                    N=N+A-E[x+i][y+j]
                                    
                    ans=max(ans,N)

    print(ans)


Measured memory_bytes: 5624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        m: i32,
    }
    if n - m == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
A=input()
A,B=input().split()
A=int(A)
B=int(B)
P=input().split()
c=[0]*3
for i in P:
        i=int (i)
        if i <= A:
                c[0]+=1
        elif i <= B:
                c[1]+=1
        else :
                c[2]+=1
c.sort()
print(c[0])

Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
int c = -1;
        if(A < 10 && B < 10) c = A*B; 
    
System.out.print(c);

    }
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}


int main() 
{
	int a,b,c;
	cin>>a>>b>>c;
	int sum=0;
	if(a>c or b>c)
	{
		cout<<b+c;
		return 0;
	}
	else
	{
		sum+=a+1;
		c-=a;
		c--;
		if(b>=c)
		{
			sum+=b+c;
			cout<<sum;
		}
		else
		{
			sum+=b+b;
			cout<<sum;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char judge(int a, int b, int c) {
	if (a == 100 || b == 100 || c == 100) return 'A';
	if ((a + b) / 2.0 >= 90) return 'A';

	int p = a + b + c;
	double aver = p / 3.0;

	if (aver >= 80) return 'A';
	if (aver >= 70) return 'B';
	if (aver >= 50 && (a >= 80 || b >= 80)) return 'B';

	return 'C';
}

int main() {
	int n;

	while (cin >> n, n) {
		for (int i = 0; i < n; ++i) {
			int a, b, c; cin >> a >> b >> c;
			cout << judge(a, b, c) << endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int n;
int A;
int Ans=1000;

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

	cin >> n;

	for (int i = 1; i <= n; i++) {

		int Count = 0;
		cin >> A;

		while (A%2==0&&Count<Ans){
			A = A >> 1;
			Count++;
		}

		if (Count<Ans){
			Ans = Count;
		}

		if (Count == 0) {
			break;
		}
	}

	cout << Ans << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;
    int ans = 0;
    int count = 357;
    while(count <= n){
        int or357 = count;
        bool a = 0,b = 0,c = 0;
        while(or357 > 0){
            if(or357 % 10 == 3){
                a = 1;
            }else if(or357 % 10 == 5){
                b = 1;
            }else if(or357 % 10 == 7){
                c = 1;
            }else{
                a = 0;
                break;
            }

            or357 /= 10;
        }
        if(a && b && c){
            ans ++;
        }

        if(count % 10 == 3) count += 2;
        else if(count % 10 == 5) count += 2;
        else if(count % 10 == 7) count += 16;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    int N, mint = 10000, maxt = 0;
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    rep(i, N){
        mint = min(mint, a[i]);
        maxt = max(maxt, a[i]);
    }
    cout << maxt - mint << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
S = []
for i in range(n):
  t = [int(i) for i in input().split()]
  S.append(t)
C = []
for i in range(m):
  t = [int(i) for i in input().split()]
  C.append(t)

for i in range(n):
  now = abs(S[i][0] - C[0][0]) + abs(S[i][1] - C[0][1])
  argnow = 0
  for j in range(1,m):
    noww = abs(S[i][0] - C[j][0]) + abs(S[i][1] - C[j][1])
    if noww < now:
      now = noww
      argnow = j
  print(argnow+1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define  int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

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

int32_t main()
{
    IOS;
    int a1,a2,a3;
    cin>>a1>>a2>>a3;
    if((a1+a2+a3)>=22)
    {
        cout<<"bust";
    }
    else
        cout<<"win";
    cout<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    string T; cin >> T;
    for (int i = 0; i < T.size(); i++) {
        if (T.at(i) == '?') {
            T.at(i) = 'D';
        }
    }
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define PI (ld)acos(-1)
#define endl '\n'
#define dbg(x) cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ld eps=(ld)1e-9;
const ll inf=1e18;
const ll mod=(ll)1e9+7;


void solve(){
	int n,W;
	cin>>n>>W;
	vector<int>w(n+1),v(n+1);
	for (int i = 1; i <=n; ++i)
	{
		cin>>w[i]>>v[i];
	}
	vector<vector<ll>>d(n+1,vector<ll>(100001,inf));
	d[0][0]=0;
	for (int i = 1; i <=n; ++i)
	{
		for (int j = 0; j <=100000 ; ++j)
		{
			if(j>=v[i])
			{
				d[i][j]=min(d[i-1][j],w[i]+d[i-1][j-v[i]]);
			}
			else d[i][j]=d[i-1][j];
		}
	}
	int ans=0;
	for (int i = 0; i < 100001; ++i)
	{
		if(W>=d[n][i])
		ans=max(ans,i);
	}
	cout<<ans;

}

int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << 1LL*a*b/__gcd(a,b) << '\n';
}

Measured memory_bytes: 256
// setprecision example

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void het()
{
    FAST
    FO
    FI
//    #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//        freopen("output.txt","w",stdout);
//    #endif
}
int main()
{
    het();
       int t;
    cin>>t;
    double f =6.28318530717958623200;

    cout << std::setprecision(26) << f*t << '\n';
    return 0;
}

Measured memory_bytes: 3800
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
int g[205][205];
int n,m,k;
int dist[205][205];
set<int>wa[205];
void dij(int x){
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;
	for(int i=1;i<=n;i++)dist[x][i]=1e9;
	dist[x][x]=0;
	q.push({0,x});
	while(!q.empty()){
		auto p = q.top();
		q.pop();
		int u = p.second , cst = p.first;
		for(auto i : wa[u]){
			int v = i;
			int w = g[u][v];
			if(cst + w < dist[x][v]){
				dist[x][v] = cst+w;
				q.push({dist[x][v],v});
			}

		}
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	scanf("%d %d %d",&n,&m,&k);

 	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)g[i][j]=1e9;
 	for(int i=1;i<=n;i++)g[i][i]=0;

 	std::vector<int> a(k);

 	for(auto &x:a)scanf("%d",&x);

 	for(int i=0;i<m;i++){
 		int a,b,c;
 		scanf("%d %d %d",&a,&b,&c);
 		g[a][b]=min(c,g[a][b]);
 		g[b][a]=min(c,g[b][a]);
 		wa[a].insert(b);
 		wa[b].insert(a);
 	}

 	for(int i=1;i<=n;i++)dij(i);

 	sort(all(a));
 	int ans = 1e9;
 	do{	
 		int curr = 0;
 		for(int i=1;i<sz(a);i++){
 			curr+=dist[a[i-1]][a[i]];
 		}
 		ans = min(ans,curr);
 	}while(next_permutation(all(a)));
 	printf("%d\n",ans );
}		


Measured memory_bytes: 2432
def solve():
  ans = ''
  S = input()
  T = input()
  n,m = len(S),len(T)
  dp = [[0]*(m+1) for _ in range(n+1)]
  for i in range(1,n+1):
    for j in range(1,m+1):
      if S[i-1]==T[j-1]:
        dp[i][j] = dp[i-1][j-1]+1
      else:
        dp[i][j] = max(dp[i-1][j],dp[i][j-1])
  i,j = n,m
  while i>0 and j>0:
    M = max([dp[i-1][j-1],dp[i][j-1],dp[i-1][j]])
    if dp[i-1][j-1]==M and M<dp[i][j]:
      ans = S[i-1]+ans
      i -= 1
      j -= 1
    elif dp[i-1][j]>=dp[i][j-1]:
      i -= 1
    else:
      j -= 1
  return ans
print(solve())

Measured memory_bytes: 144524
var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  main(input);
});

function main(input) {
  var stack = [];
  input = input.split('\n');
  input.forEach(function(number) {
    if (number === '0') {
      console.log(stack.pop());
    } else {
      stack.push(number);
    }
  });
}

Measured memory_bytes: 15560
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N]  ;
bool visited[N]={};
int main()
{

 int n,t,ans=-1;
 cin>>n>>t;
 vector<pair<int , int> >vp;
for(int i=0 ; i<n ; i++) {

     int a,b;
     cin>>a>>b;
     vp.pb(make_pair(a,b));
 }
      sort(vp.begin() , vp.end());
  for(int i=0 ; i<n ; i++)
  {
      if(vp[i].second<=t){
        cout<<vp[i].first;
        go;}
  }

        cout<<"TLE";

 go;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll h,w;
  cin>>h>>w;
  vector<vector<char> >a(h,vector<char>(w));
  rep(i,h){
    rep(j,w)cin>>a[i][j];
  }
  rep(i,h+2){
    rep(j,w+2){
      if(i==0)cout<<'#';
      else if(i==h+1)cout<<'#';
      else if(j==0)cout<<'#';
      else if(j==w+1)cout<<'#';
      else cout<<a[i-1][j-1];
    }
    cout<<endl;
  }
}
  

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include <cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define fastIO_ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
bool palindrome(string t)
{
    string k= "";
    for (int i=(int)t.size()-1; i>= 0; i--)
        k += t[i];
   // cout<<k<<endl;
    return k==t;
}

int main()
{
    fastIO_
    string s;
    cin>>s;
    int l = s.size();
    string d = "";
    for (int i=0; i<l /2; i++)
        d += s[i];
    string k  = "";
    for (int i=(l+2)/2; i< l; i++)
        k += s[i];
    if (palindrome(s) and palindrome(d) and palindrome(k))
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

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


int main(){
  int x,y;
  cin >> x >> y;
  rep(i,x){
      if(2*i + 4*(x-i) == y){
        puts("Yes");
        return 0;
      }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 3616