akhauriyash/Code-Regression huggingface dataset:
#import <stdio.h>
#import <stdlib.h>
#import <limits.h>
typedef long long INT;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

int compare_int(const void *a, const void *b) {
    return (int)(*(INT*)a - *(INT*)b);
}

int main() {
    INT N, K;
    scanf("%lld %lld", &N, &K);
    INT P[100005] = {0};
    INT Q[100005] = {0};

    INT x;
    INT p = 0;
    INT q = 0;
    while (scanf("%lld", &x) != EOF) {
        if(x>0) {
            P[p] = x;
            p++;
        } else if (x==0) {
            K--;
            N--;
        } else if (x<0) {
            Q[q] = -x;
            q++;
        }
    }
    
    qsort(Q, q, sizeof(INT), compare_int);
    
    INT min = LLONG_MAX;
    
    if (N==0) {
        min = 0;
    } else {
        if (p>=K) {
            min = P[K-1];
        }
        if (q>=K) {
            min = MIN(min,Q[K-1]);
        }
        for (INT i=MAX(1,K-q);i<=MIN(p,K-1);i++) {
            min = MIN(min, 2*P[i-1] + Q[K-i-1]);
        }
        for (INT i=MAX(1,K-p);i<=MIN(q,K-1);i++) {
            min = MIN(min, P[K-i-1] + 2*Q[i-1]);
        }
    }
    printf("%lld",min);

    return 0;

}


Measured memory_bytes: 9168
#include <iostream>
using i64 = long long;

int main() {
    int x, y;
    std::cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        if (i * 2 + (x - i) * 4 == y) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> v;
  for (int i = 0; i < N; ++i) {
    int A, B;
    cin >> A >> B;
    v.push_back(make_pair(B, A));
  }
  sort(v.begin(), v.end());
  int64_t now = 0;
  for (int i = 0; i < N; ++i) {
    pair<int, int> p = v[i];
    int A = p.second;
    int B = p.first;
    now += A;
    if (now > B) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 2420
N,M,K=map(int,input().strip().split())
A=list(map(int,input().strip().split()))
B=list(map(int,input().strip().split()))

a=[0]
b=[0]
for n in range(N):
    a.append(a[n]+A[n])
for m in range(M):
    b.append(b[m]+B[m])

num=0
bmax=M+1
for n in range(N+1):
    if a[n]>K:
        break
    for m in reversed(range(bmax)):
        if b[m]<=K-a[n]:
            num=max(num,n+m)
            bmax=m+1
            break
print(num)

Measured memory_bytes: 47548
n = int(input())
a = []
b = []
for i in range(n):
    a1,b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
a.sort()
b.sort()
if n%2 == 1:
    print(b[(n+1)//2-1]-a[(n+1)//2-1]+1)
else:
	print(b[n//2-1]-a[n//2-1]+b[n//2]-a[n//2]+1)

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

ll findFor(ll a)
{
	char c[51];
	ll x = 1;
	a++;
	// cout << a << endl;
	fr(i,1,50)
	{
		x = x*2;

		ll num = a/x;
		ll y = x/2;
		num = num*y;

		ll num2 = a%x;
		ll xx = a%x;
		num2 = a%y;
		ll z = xx/y;

		if(z==0)
			num2 = 0;

		ll num3 = num + num2;

		if(num3%2==0)
		{
			c[i] = '0';
		}
		else
		{
			c[i] = '1';
		}

		// cout << c[i] << " ";
	}

	ll ans = 0;

	frr(i,50,1)
	{
		ans = ans*2 + (c[i]-'0');
	}

	return ans;
}

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

    ll a,b;
    cin >> a >> b;

    ll ans1 = findFor(b);
    ll ans2 = findFor(a-1);

    ll ans = ans1^ans2;

    cout << ans << endl;
}


Measured memory_bytes: 256
import math
n = int(input())
a = list(map(int,input().split()))
l = [0]
r = [0]
for i in range(n-1):
    #左から見ていく
    l.append(math.gcd(l[i],a[i]))
    #右から見ていく
    r.append(math.gcd(r[i],a[-1-i]))
r = r[::-1]
ans = 0
for i in range(n):
    ans = max(ans,math.gcd(l[i],r[i]))
print(ans)

Measured memory_bytes: 90868
def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    if V > W:
        dis = abs(A-B)
        time = (dis+V-W-1)//(V-W) 
        if time <= T:
            print("YES") 
        else:
            print("NO")    
    else:
        print("NO")
if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

struct UnionFind{
	vector<int> p;
	UnionFind(int n){
		p.resize(n, -1);
	}

	int find(int x){
		if(p[x] == -1)return x;
		else return p[x] = find(p[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y)return;
		p[x] = y;
	}
};

struct Edge{
	int from, to, cost;
	Edge(int from, int to, int cost) : from(from), to(to), cost(cost){}

	bool operator<(const Edge& e) const {
		return cost < e.cost;
	}
};

struct Graph{
	int n;
	vector<Edge> es;

	Graph(int n) : n(n){}

	ll kruskal(){
		sort(es.begin(), es.end()); 

		UnionFind uf(n);
		ll min_cost = 0;
		for(auto e : es){
			if(uf.find(e.from) == uf.find(e.to))continue;
			min_cost += e.cost;
			uf.unite(e.from, e.to);
		}
		return min_cost;
	}

	void addEdge(int a, int b, int c){
		es.push_back(Edge(a, b, c));
	}
};

int main(){
  int n, m;
  cin >> n >> m;
  Graph g(n);
  for(int i = 0; i < m; ++i){
  	int s, t, w;
  	cin >> s >> t >> w;
  	g.addEdge(s, t, w);
  }

  cout << g.kruskal() << endl;
  return 0;
}



Measured memory_bytes: 4544
count = range(1000001) 
for i in xrange(2, 500001):
    for n in xrange(i*2, 1000001, i):
        count[n] -= (count[i] - 1) 
 
count[1] = 2
for i in xrange(2, 1000001):
    count[i] += count[i-1]

t = int(raw_input())
for i in xrange(t):
    n = int(raw_input())
    print count[n] - n + 1

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

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

	if (a > b) { cout << "0" << endl; return 0; }
	if (n == 1 && a != b) { cout << "0" << endl; return 0; }
	else { cout << (n - 2)*(b - a) + 1 << endl; }
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
    int n;
    char c[200000];
    cin>>n;
    cin>>c;
    int rs=0,ws=0;
    rep(i,n)
    {
      if(c[i]=='R')rs++;
      else ws++;
    }
    int diff =0;
    for(int i=0;i<rs;i++)
    {
      if(c[i]!='R')diff++;
    }
    
    for(int i=rs;i<n;i++)
    {
      if(c[i]!='W')diff++;
    }
    cout<<diff/2<<endl;
    
    return 0;
}

Measured memory_bytes: 3776
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(x: usize, aa: Vec<usize>) -> usize {
    let mut aa = aa;

    aa.sort();

    let mut cnt = 0;
    let mut total = 0;

    for a in aa {
        total += a;
        if total <= x {
            cnt += 1;
        } else {
            break;
        }
    }

    if total < x {cnt-1} else {cnt}
}

fn main() {
    let (_n, x) = parse_line!(usize, usize);
    let aa = parse_vec!(usize);

    println!("{}", solve(x, aa));
}

#[test]
fn solve_test() {
    assert_eq!(solve(70, vec![20,30,10]), 2);
    assert_eq!(solve(10, vec![20,30,10]), 1);
    assert_eq!(solve(1111, vec![1,10,100,1000]), 4);
    assert_eq!(solve(10, vec![20,20]), 0);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+10;
long long n,a[maxn];
long long ans=0;
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
		scanf("%lld",a+i);
	for(long long i=1;i<=n-1;i++)
	{
		ans+=a[i]/2LL;
		a[i]%=2LL;
		if(a[i]&&a[i+1])
		{
			a[i]=0;
			--a[i+1];
			++ans; 
		}
	}
	ans+=a[n]/2LL;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a, b;

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

	int mx = INT_MIN;

	mx = max(mx, a + b);
	mx = max(mx, a * b);
	mx = max(mx, a - b);

	cout << mx << endl;

	return 0;
}


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

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

int main()
{
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

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

    ll ans = 0;
    rep(i, n)
    {

        if (x < a[i])
        {
            break;
        }

        if (x >= a[i])
        {
            x -= a[i];
            ans++;
        }

        if (i == n - 1 && x > 0)
        {
            ans--;
        }
    }

    cout << ans << endl;
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,K,border;
  cin >> N >> K >> border;
  vector<long long> b(N,0);
  froop1(0,K){
    b.at(i) = border;
  }
  froop1(0,N){
	if(b.at(i) == 0){
      if(border < 1000000000LL){
      b.at(i) = border + 1;
      }else{
		b.at(i) = 1;
    }
    }
  }
  froop1(0,N){
	cout << b.at(i);
    if(i != N - 1){
      cout << " ";
    }else{
      cout << endl;
    }
  }

return 0;
}

Measured memory_bytes: 4016
#include<iostream>
using namespace std;
int main()
{
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;
	if ((A1 && A2 && A3) >= 1 && (A1 && A2 && A3) <= 13)
	{
		if ((A1 + A2 + A3) >= 22)
			cout << "bust\n";
		else
			cout << "win\n";
	}
	else;

	return 0;
}

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

int main()
{
	int x;
	int y;
	cin>>x>>y;
	if(y%x==0)
	{
		cout<<x+y<<endl;
		return 0;
	}
	else
	{
		cout<<y-x<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << endl;
    return 0;
}

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

#define ll long long

using namespace std;

int main() {
  int N; cin >> N;
  ll sum = 0;
  for(int i = 1; i <= N; i++) {
    if (i%3 != 0 && i%5 != 0) {
      sum += (ll)i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll A[N], B[N];
    rep(i, N){
        cin >> A[i];
        B[i] = A[i]-i;
    }
    sort(B, B+N);
    ll b = B[N/2];
    ll ans = 0;
    rep(i, N){
        ans += abs(A[i]-(b+i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

int serach(int* a,int b,int c){
  
  int i=0;
  
  a[b]=c;
  
  while(a[i]!=c){
    i++;
  }
  
  if (i==b){
    return 0;
  }
  return 1;
    
}
int main(){
  
  int a[10001],b,c,i,j,s=0;

  scanf("%d",&b);
  for(i=0;i<b;i++){
    
  scanf("%d",&a[i]);

  }
  
  scanf("%d",&j);
  
  for(i=0;i<j;i++){
    
    scanf("%d",&c);
    
    if(serach(a,b,c))s++;
  }

  printf("%d\n",s);

  return 0;
}



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

int main(){
    long long int n,m;
    cin >> n >> m;
    if(n>=2 && m>=2) cout << (n-2)*(m-2) << endl;
    else if(n==1 && m==1) cout << 1 << endl;
    else cout << n+m-3 << endl;
}

Measured memory_bytes: 3676
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  if(a[0]!=0){
    printf("-1\n");
    return;
  }
  for(i=1;i<n;i++){
    if(a[i-1]<a[i]-1){
      printf("-1\n");
      return;
    }
  }
  int64 ans=0;
  i=n-1;
  while(i>=0){
    int j=i-1;
    while(j>=0 && a[j]+1==a[j+1]) j--;
    ans+=a[i];
    i=j;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

string f(ll n) {
	stringstream ss; ss << n;
	string res; ss >> res;
	return res;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll a, b;
	while (cin >> a >> b) {
		ll c = a + b;
		cout << f(c).size() << endl;
	}
}

Measured memory_bytes: 3120
//Crested Ibis vs Monster

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll, ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int h,n;cin>>h>>n;
    vector<P>s(n);
    rep(i,0,n){
        int a,b;cin>>a>>b;
        s[i]=mp(a,b);
    }
    vector<int>dp(h+1,inf);//体力をN減らすときの最小の体力
    dp[0] = 0;
    rep(i,1,h+1){
        int c;//来る前
        rep(j,0,n){
            c = i - s[j].first;
            if(c<0)c=0;
            dp[i]=min(dp[i],dp[c]+s[j].second);
        }
    }
    cout<<dp[h]<<nnn;
    return 0;
}

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

public class Main {

    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int a = n / k;
        int[] arr = new int[k];
        Arrays.fill(arr, a);
        int c = n % k;
        for (int i = 0; i < c; i++) {
            arr[i]++;
        }
        Arrays.sort(arr);
        out.println(Math.abs(arr[arr.length - 1] - arr[0]));
    }


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

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

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

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


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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }


}


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

ll mod = 1000000007;
ll ans = 1<<29;

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

    if(c>=a&& c<=b) cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b;
    
    scanf("%d %d", &a, &b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, d;
  cin >> m >> d;
  
  int cnt = 0;
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= d; ++j) {
      int a = j % 10;
      int b = j / 10;
      if (a < 2 || b < 2) continue;
      if (a * b == i) {
        ++cnt;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
/*
    Created by Rahul Goel.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*******************************************************************************/
using namespace std;
using namespace __gnu_pbds;
template < typename T >
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*******************************************************************************/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
ll mod_sum() { return 0LL; }
template < typename T, typename... Args >
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%MOD + MOD)%MOD; }
/*******************************************************************************/
ll mod_prod() { return 1LL; }
template< typename T, typename... Args >
T mod_prod(T a, Args... args) { return (a * mod_prod(args...))%MOD; }
/*******************************************************************************/
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
/*******************************************************************************/
//.-.. . -. -.- .- .. ... .-.. --- ...- .
/*
    Code begins after this.
*/

ll solve() {
    ll h, w, m;
    cin >> h >> w >> m;
    vi hh(h + 5), ww(w + 5);

    map <pii,ll> mp;

    for (ll i = 0; i < m; i++) {
        ll x, y;
        cin >> x >> y;
        hh[x]++;
        ww[y]++;
        mp[make_pair(x, y)]++;
    }

    ll ans = 0;

    ll fixh = max_element(all(hh)) - hh.begin();
    ll fixhval = *max_element(all(hh));
    for (ll i = 1; i <= w; i++) {
        ans = max(ans, fixhval + ww[i] - mp[make_pair(fixh, i)]);
    }

    ll fixw = max_element(all(ww)) - ww.begin();
    ll fixwval = *max_element(all(ww));
    for (ll i = 1; i <= h; i++) {
        ans = max(ans, fixwval + hh[i] - mp[make_pair(i, fixw)]);
    }

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

signed main() {
    fastio;

    ll t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 64164
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long now = 100;
        int y = 0;
        while(x > now){
            now = (long)Math.floor((double)now * 1.01);
            y++;
        }
        System.out.println(y);
    }
}

Measured memory_bytes: 27108
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string str;
	cin >> str;
	str[3] = '8';

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,K,ans;
    cin>>N>>K;
    ans = N/K;
    ans = ans*ans*ans;
    if(!(K%2)){
        ll m = (N+K/2)/K;
        ans += m*m*m;
    }
    put(ans);
}

Measured memory_bytes: 256
//In the name of GOD
//SMani24
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1e5 + 10;

int n;
bool dp1[N], dp0[N], mark[N];
vector <int> adj[N];

void dfs(int v) {
	mark[v] = true;
	bool b = false;
	int c = 0, cl = 0;
	for (auto u : adj[v]) {
		if (!mark[u]) {
			dfs(u);
			cl++;
			if (dp0[u])
				c++;
			if (dp1[u])
				b = true;
		}
	}
	if (c == cl)
		dp1[v] = true;
	if (c + 1 == cl && b)
		dp0[v] = true;
}

void read_input() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[--u].push_back(--v);
		adj[v].push_back(u);
	}
}
void solve() {
	dfs(0);
}
void write_output() {
	if (dp0[0])
		cout << "Second";
	else
		cout << "First";
}

int32_t main() {
	ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	read_input(), solve(), write_output();
	return 0;
}


Measured memory_bytes: 9992
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):number|number[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  t.o('ABC'+t.s())
}
main()

Measured memory_bytes: 7372
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let s: Vec<char> = iter.next().unwrap().chars().collect();
    
    let mut min = 1u64 << 60;
    for j in 0..2 {
        let mut cnt = 0u64;
        for i in 0..s.len() {
            match ((i+j)%2, s[i]) {
                (0, '0') | (1, '1') => (),
                _ => cnt += 1,
            }
        }
        min = std::cmp::min(min, cnt);
    }

    println!("{}", min);
}

Measured memory_bytes: 4352
#include <iostream>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cstdio>
#include <bitset>
using namespace std;


int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++)
	{
		if (i % 2 == 0) cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.*;

public class Main {

    static final int N = 10000;

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String str=br.readLine();
        int left=0;
        int right=str.length()-1;
        while(str.charAt(left)!='A'){ left++; }
        while(str.charAt(right)!='Z'){ right--; }
        System.out.println(right-left+1);
    }
    
}


Measured memory_bytes: 11684
n=int(input())
a=[int(j)for j in input().split()]
ans=0
s=sum(a)
p=1
b=True
for i,j in enumerate(a):
    if p<j:
        print(-1)
        exit()
    ans+=p
    p-=j
    s-=j
    if i==n:
        continue
    if p<s and b:
        if p*2<s:
            p*=2
        else:
            p=s
    if p==s:
        b=False

print(ans)

    




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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), k = sc.nextInt(), s = sc.nextInt();
		int put = s == 1 ? 2 : 1;
		int ones = 0;
		for (int i = 1; i <= n; i++) {
			if (i <= k) {
				out.print(s);
			} else {
				if (ones == s - 1) {
					out.print(s + 1);
					ones = 0;
				} else {
					out.print(put);
					if (put == 1)
						ones++;
				}

			}
			out.print(" ");
		}

		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 28508
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    set<int>s;
    int n,m;
    cin>>n>>m;
    s.insert(1);
    vector<int>num_of_balls(n+1,1);
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        if(s.count(a))
        {
            s.insert(b);
            num_of_balls[b]++;
            num_of_balls[a]--;
            if(num_of_balls[a]==0)
                s.erase(a);
        }
        else{
            num_of_balls[a]--;
            num_of_balls[b]++;
        }
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 8704
#include<stdio.h>
#include<iostream>
#include<bitset>
#include<vector>

int main(void) {
	int N;
	std::cin >> N;
	std::string S;
	std::cin >> S;

	int x = 0;
	std::vector<int> list;
	for (int i = 0; i < (int)S.length(); i++) {
		x += (S[i] == 'I') ? 1 : -1;
		list.push_back(x);
	}

	int max = 0;
	for (int i = 0; i < (int)list.size(); i++) {
		if (list[i] > max) max = list[i]; {
		}
	}

	std::cout << max << std::endl;

	system("pause");
}

Measured memory_bytes: 504
import math
n = int(input())
s = list(map(int,input().split()))
t = list(map(int,input().split()))
L=[]
for i in range(n):
   L.append(abs(s[i]-t[i]))
d1 = sum(L)
d2 = math.sqrt(sum(map(lambda x: x**2,L)))
d3 =math.pow(sum(map(lambda x: x**3,L)),(1.0/3.0))
dinf=max(L)
print('{:.5f}\n{:.5f}\n{:.5f}\n{:.5f}'.format(d1,d2,d3,dinf))


Measured memory_bytes: 5704
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			boolean fl = false;
			int count = 0;
			for(int i = 0;i < n;i++){
				int s = scan.nextInt();
				fl = false;
				for(int j = 1;j <= s/4;j++){
					if((s-j)%(2*j+1) == 0){
						fl = true;
						break;
					}
				}
				if(!fl){
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 60724
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll x;
  cin >> x;
  int ans = 1;
  for (int i = 1; i <= x; i++) {
    if (i * (i + 1) / 2 >= x) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H,W=map(int,input().split())
    ans=[]
    f2=False
    for i in range(H):
        f=False
        a=list(map(int,input().split()))
        for j,x in enumerate(a):
            if j==W-1 and i!=H-1 and (x+f+f2)%2:
                ans.append((i+1,j+1,i+2,j+1))
                f=True
            elif j!=W-1 and (x+f)%2:
                ans.append((i+1,j+1,i+1,j+2))
                f=True
            else:
                f=False
        if f:
            f2=True
        else:
            f2=False
    print(len(ans))
    for z in ans:
        print(*z)

if __name__ == '__main__':
    main()


Measured memory_bytes: 75940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String tag = br.readLine();
        int count = Integer.parseInt(br.readLine());
        for(int k=0;k<count;k++){
            String[] order = br.readLine().split(" ");
            if(order[0].equals("print")){
                StringBuilder sb = new StringBuilder();
                int a=Integer.parseInt(order[1]);
                int b=Integer.parseInt(order[2]);
                for(int i=a;i<=b;i++)
                    sb.append(String.valueOf(tag.charAt(i)));
                System.out.println(sb.toString());
            }else if(order[0].equals("reverse")){
                StringBuilder sb = new StringBuilder();
                int a=Integer.parseInt(order[1]);
                int b=Integer.parseInt(order[2]);
                for(int i=0;i<a;i++)
                    sb.append(tag.charAt(i));
                for(int i=b;i>=a;i--)
                    sb.append(String.valueOf(tag.charAt(i)));//reverse
                for(int i=b+1;i<tag.length();i++)
                    sb.append(String.valueOf(tag.charAt(i)));
                tag = sb.toString();
            }else if(order[0].equals("replace")){
                StringBuilder sb = new StringBuilder();
                int a=Integer.parseInt(order[1]);
                int b=Integer.parseInt(order[2]);
                String rep = order[3];
                for(int i=0;i<a;i++)
                    sb.append(String.valueOf(tag.charAt(i)));
                sb.append(rep);//replace文を挿入
                for(int i=b+1;i<tag.length();i++)
                    sb.append(String.valueOf(tag.charAt(i)));
                tag = sb.toString();
            }else{}
        }
    }
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	ll d,t,s;
	cin >> d >> t >> s;
	cout << (t*s>=d?"Yes\n":"No\n");
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

void input_vector(int &x);
void show(int x);

//#define DEBUG
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for_each(V.begin(), V.end(), input_vector);
    for_each(C.begin(), C.end(), input_vector);

    int X = 0;
    int Y = 0;
    int ans = 0;
    vector<int> diff(N);
    for(int i = 0; i < N; i++){
        diff.at(i) = V.at(i) - C.at(i);
    }
    //for_each(diff.begin(), diff.end(), show);
    //cout << endl;
    for(int i = 0; i < N; i++){
        if(diff.at(i) >= 0){
            ans += diff.at(i);
        }
    }
    
    cout << ans << endl;
}

void input_vector(int &x){
    cin >> x;
}
void show(int x){
    cout << x << " ";
}

Measured memory_bytes: 256
S = str(input())
T = str(input())
ans = 1000
for i in range(len(S) - len(T) + 1):
    c = 0
    for j in range(len(T)):
        if S[i] != T[j]:
            c += 1
        i += 1
    ans = min(ans, c)
print(ans)

Measured memory_bytes: 9072
#include<iostream>
#include<cmath>
#include<set>

using namespace std;

int main(){

	long long Q,N,M;
	long long max;
	int cnt;
	set<long long> inf;

	cin>>Q;

	while(Q--){

		cin>>N;

		if(!inf.empty()) inf.clear();

		cnt=0;
		while(N/10!=0){
			M=0;
			max=-1;
			for(int i=0;N!=0;i++){
				M+=N%10*pow(10.0,i);
				N/=10;
				if(M*N>max) max=N*M;
			}
			if(inf.find(max)!=inf.end()){
				cnt=-1;
				break;
			}
			inf.insert(max);
			N=max;
			cnt++;
		}

		cout<<cnt<<endl;

	}
}

Measured memory_bytes: 1204
from bisect import bisect
a,b,q=map(int,input().split())
INF=float("inf")
s=[-INF]+[int(input()) for _ in range(a)]+[INF]
t=[-INF]+[int(input()) for _ in range(b)]+[INF]
xx=[int(input()) for _ in range(q)]
for x in xx:
	si=bisect(s,x)
	ti=bisect(t,x)
	sf,sb=x-s[si-1],s[si]-x
	tf,tb=x-t[ti-1],t[ti]-x
	print(min(2*sf+tb,sf+tb*2,2*sb+tf,sb+tf*2,max(sf,tf),max(sb,tb)))

Measured memory_bytes: 16144
import sys
sys.setrecursionlimit(300000)
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, K = MI()
A = LMI()

# P[i] := i番目より後ろにA[i]より小さい数がいくつあるか
# U[i] := A全体でA[i]より小さい数がいくつあるか
P = [0] * N
U = [0] * N
d = defaultdict(int)
for i, a in enumerate(reversed(A)):
    i = N - 1 - i
    cnt = 0
    for j in range(a):
        cnt += d[j]
    P[i] = cnt
    d[a] += 1
for i, a in enumerate(A):
    cnt = 0
    for j in range(a):
        cnt += d[j]
    U[i] = cnt

ans = 0
for i in range(N):
    v = K * P[i] + U[i] * (K * (K - 1) // 2)
    ans += v
    ans %= MOD
print(ans)

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<ll> node;
    ll par;
};
Vertex T[200005];
Vertex V[200005];
bool U[200005];
ll P[200005];
ll A[200005];

int main()
{
    ll N, Q;
    cin >> N >> Q;
    REP(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        T[a].node.push_back(b);
        T[b].node.push_back(a);
    }

    {
        memset(U, 0, sizeof(U));
        queue<ll> q;
        q.push(0);
        while (!q.empty())
        {
            ll t = q.front();
            q.pop();
            U[t] = true;
            REP(i, T[t].node.size())
            {
                ll n = T[t].node[i];
                if (U[n])
                    continue;
                V[n].par = t;
                V[t].node.push_back(n);
                q.push(n);
            }
        }
    }

    REP(i, Q)
    {
        ll p, x;
        cin >> p >> x;
        P[--p] += x;
    }

    {
        queue<pll> q;
        q.push(pll(0, 0));
        while (!q.empty())
        {
            pll t = q.front();
            q.pop();
            ll s = t.second + P[t.first];
            A[t.first] = s;
            REP(i, V[t.first].node.size())
            {
                ll n = V[t.first].node[i];
                q.push(pll(n, s));
            }
        }
    }
    REP(i, N)
    {
        cout << A[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 30592
a, b, q = gets.strip.split.map(&:to_i)
s = a.times.map { gets.strip.to_i }
t = b.times.map { gets.strip.to_i }
x = q.times.map { gets.strip.to_i }

 
rs = s.reverse
rt = t.reverse

x.each do |xx|
  right_s = s.bsearch {|e| e>=xx }
  right_s = right_s-xx if right_s
 
  left_s = rs.bsearch {|e| e<= xx}
  left_s = xx - left_s if left_s
 
  right_t = t.bsearch {|e| e>=xx }
  right_t = right_t - xx if right_t
 
  left_t = rt.bsearch {|e| e<=xx }
  left_t = xx - left_t if left_t

  candidates = []
  candidates.push( [right_s, right_t].max ) if right_s && right_t
  candidates.push( [left_s, left_t].max ) if left_s && left_t
  candidates.push( [left_s*2 + right_t, left_s + right_t*2].min ) if left_s && right_t
  candidates.push( [left_t *2+ right_s, left_t + right_s*2].min ) if left_t && right_s

  result = candidates.min
#p"---"
#  p [xx, left_s,right_s, left_t, right_t]
#  p candidates
  p result
end


Measured memory_bytes: 9336
/******************************************************/
/******************************************************/
/**                                                  **/
/**            BISMILLAHIR RAHMANIR RAHIM            **/
/**         REAZ AHAMMED CHOWDHURY - reaziii         **/
/**  Department of Computer Science and Engineering  **/
/*         INSTITUTE OF SCIENCE AND TECHNOLOGY       **/
/**                                                  **/
/******************************************************/
/******************************************************/
#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,vector<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define ff           first
#define ss           second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num, int pos);
ll setbitt(ll num, ll pos);
ll resetbitt(ll num, int pos);
void abcd() {
#ifndef ONLINE_JUDGE
	input;
	output;
#endif
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#endif
}

void read(int *aa, int sz) {fri(sz) scanf("%d", (aa + i));}
void read(ll *aa, int sz) {fri(sz) scanf("%lld", (aa + i));}
void read(ll *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%lld", (aa + i));}
void read(int *aa, int s, int e) {for (int i = s; i < s + e; i++)scanf("%d", (aa + i));}
const ll mod =       1e9 + 7;
const ll N =     1e6 + 10;

//.................___Start from here___.................//
//.................._____________________................//


int arr[N];
int w[N];
int v[N];
int n, W;



int solve() {
	cin >> n >> W;
	vector<ll> dp(1e8, infi);
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	dp[0] = 0;
	for (int i = n; i >= 1; i--) {
		for (int j = 1e7 + 10; j >= 0; j--) {

			if (j >= v[i]) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}

	int res = 0;
	for (int i = 0; i < N; i++) if (W >= dp[i]) res = i;
	cout << res << endl;






	return 0;
}
int main() {
	abcd();
	int cs = 1;
	int cn = 1;
	//cin>>cs;
	while (cs--) {
		solve();

	}
}


bool checkbitt(ll num, int pos) {return (num >> pos) & 1;}
ll setbitt(ll num, ll pos) {return (1 << pos) | num;}
ll resetbitt(ll num, int pos) {if (!checkbitt(num, pos)) return num; else return (1 << pos)^num;}




Measured memory_bytes: 784328
#include <iostream>
using namespace std;
int main()
{
	int temp; int sum=0;
	for(int i=0;i<4;i++)
	{
		cin >> temp;
		sum+=temp;
	}
	int min,sec;
	min=sum/60; sec=sum%60;
	cout << min << '\n' << sec << endl;
}

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

const char O = '#';
const char F = '.';

struct UnionFind {
	int sz;
	vector<int> par, size_;
	UnionFind() {}
	UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1) {
		iota(par.begin(), par.end(), 0);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (size_[x] < size_[y]) swap(x, y);
		par[y] = x;
		size_[x] += size_[y];
	}
	int size(int x) {
		return size_[find(x)];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int main(void) {
	int H, W;
	cin >> H >> W;
	vec<string> MAP(H);

	for (int i = 0; i < H; ++i) {
		cin >> MAP[i];
	}

	vec<UnionFind> uW(H, UnionFind(W));
	vec<UnionFind> uH(W, UnionFind(H));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W - 1; ++j) {
			if (MAP[i][j] == F && MAP[i][j + 1] == F) {
				uW[i].unite(j, j + 1);
			}
		}
	}

	for (int j = 0; j < W; ++j) {
		for (int i = 0; i < H - 1; ++i) {
			if (MAP[i][j] == F && MAP[i + 1][j] == F) {
				uH[j].unite(i, i + 1);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (MAP[i][j] == O)continue;
			int sum = uH[j].size(i) + uW[i].size(j);
			ans = max(ans, sum);
		}
	}

	cout << ans - 1 << endl;
	return 0;

}

Measured memory_bytes: 69376