akhauriyash/Code-Regression huggingface dataset:
//Sinhov : "Hi stalker!"
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
vector<vector<pair<ll,ll> > > gr(100001,vector<pair<ll,ll> >());
vector<ll>dist(100001);
vector<bool>visited(100001,0);
void dfs(ll node){
    visited[node]=1;
    for(auto e:gr[node]){
        if(!visited[e.first]){
            dist[e.first]=dist[node]+e.second;
            dfs(e.first);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    ll i,t=1,n,a,b,c,d,q,k;
    cin>>n;
    for(i=0;i<n-1;i++){
        cin>>a>>b>>c;
        gr[a].pb({b,c});
        gr[b].pb({a,c});
    }
    cin>>q>>k;
    dist[k]=0;
    dfs(k);
    //for(i=1;i<n+1;i++)
    //    cout<<dist[i]<<" ";
    for(i=0;i<q;i++){
        cin>>a>>b;
        cout<<dist[a]+dist[b]<<"\n";
    }
    return 0;
}

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

#pragma GCC optimize ("O3")

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	string c;
	long long a, b;
	cin >> a >> c;
	b = (c[0]-'0')*100+(c[2]-'0')*10+c[3]-'0';
	cout << a*b/100 << "\n";
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint mod=1'000'000'007;
    std::vector<lint>a(26);
    lint n;std::string s;std::cin>>n>>s;
    for(char c:s)a.at(c-'a')++;
    lint ans=1;
    for(lint x:a)ans=ans*(x+1)%mod;
    std::cout<<ans-1<<'\n';
}


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

inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}

inline void write(int x){
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);putchar(x%10+'0');
}

inline void writeln(int x){
	write(x);puts("");
}
#define Max 100
int n,m;
char a[Max][Max];

int main(){
	n=read();m=read();
	for(int i=1;i<=n;i++){
		scanf("%s",a[i]+1);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#'){
				if(a[i][j+1]!='#'&&a[i][j-1]!='#'&&a[i+1][j]!='#'&&a[i-1][j]!='#'){
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

map<int, int> mp;



int main() {
	ll n, k,a,b;
	cin >> n >> k;
	map<ll, ll> mp;
	rep(i, n) {
		cin >> a >> b;
		mp[a] += b;
	}

	
	for (const auto& elm : mp) {
		k -= elm.second;
		if (k <= 0) {
			cout << elm.first << endl;
			return 0;
		}
	}
	
}



Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int digits(int n) {
	int ans = 0;
	while (n) {
		++ans;
		n /= 10;
	}
	return ans;
}

int main() {

	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		if (digits(i) % 2 == 1) {
			++ans;
		}
	}
	cout << ans << endl;




}

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

void solve(){
	ll n, sum=0;
	cin >> n;
	for(ll i=1; i<=n; ++i){
		for(ll j=1; j<=n; ++j){
			ll tt = __gcd(i,j);
			for(ll k=1; k<=n; ++k){
				sum += __gcd(k,tt);
			}
		}
	}
	cout << sum << "\n";
}

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


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

int main() {

  char S;
  cin >> S;

  if (65 <= (int) S && (int) S <= 90) {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
  
  return 0;

}

Measured memory_bytes: 3528
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i], a[i]-=(i+1);
  
  sort(a.begin(),a.end());

  int tmp = a[n/2];

  int ans = 0;
  REP(i,n) ans += abs(a[i]-tmp);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
N = int(input())
dic,rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Measured memory_bytes: 36464
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


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

int main() {
	ll n;
	ll N, X;
	ll sum = 0;
	ll m[100000];
	cin >> N >> X;
	REP(i, N) {
		cin >> m[i];
	}
	sort(m, m + N);
	REP(i, N) {
		X -= m[i];
	}
	sum = N + X / m[0];
	cout << sum;

	return 0;


}

Measured memory_bytes: 256
import sys
import heapq
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_minus = list(map(lambda x: -x, a))
    a_bef, a_aft = a[:n], a_minus[-n:]
    a_bef_sum, a_aft_sum = {n: sum(a_bef)}, {2 * n: -sum(a_aft)}

    heapq.heapify(a_bef)
    heapq.heapify(a_aft)
    for i in range(n):
        bef_key = n + i
        heapq.heappush(a_bef, a[bef_key])
        a_bef_sum[bef_key+1] = a_bef_sum[bef_key] - heapq.heappop(a_bef) + a[bef_key]

        aft_key = n * 2 - i - 1
        heapq.heappush(a_aft, a_minus[aft_key])
        a_aft_sum[aft_key] = a_aft_sum[aft_key+1] + heapq.heappop(a_aft) + a[aft_key]

    ans = - pow(10, 15)
    for i in range(n + 1):
        diff = a_bef_sum[n+i] - a_aft_sum[n+i]
        if diff > ans:
            ans = diff
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64092
#include <bits/stdc++.h>
using namespace std;
 
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; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    rep(i, 0, h){
        rep(j, 0, w){
            if(i<h-b && j<w-a)cout << 0;
            else if(i<h-b && j>=w-a)cout << 1;
            else if(i>=h-b && j<w-a)cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3640
//import java.util.*;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        char[] a = scn.next().toCharArray();
        int n = a.length;
        int hug = 0;
        int limit = n/2 ;
        for(int i = 0; i < n; i++) {
          
			if ( i >= limit ){
				break;
			}
			if(a[i] != a[n-i-1]){
				//i = 0;
				//a[n-i-1] = a[i];
				hug = hug + 1;
			}
          
        }

		 System.out.println(Integer.toString(hug));

    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a == b){
    cout << "Draw" << endl;
  }
  else if(a == 1){
    cout << "Alice" << endl;
  }
  else if(b == 1){
    cout << "Bob" << endl;
  }
  else if(a < b){
    cout << "Bob" << endl;
  }
  else if(a > b){
    cout << "Alice" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define bs              binary_search
#define pqb             priority_queue<int>
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define test(x)         int x; cin>>x; while(x--)
#define pi              3.14159265358979323846
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
// int pow(int a, int b, int c)
// {
// 	int res = 1;
// 	while (b > 0)
// 	{
// 		if (b % 2)
// 			res = (res * a) % c;
// 		a = (a * a) % c;
// 		b >>= 1;
// 	}
// 	return res;
// }
/*********************CODE BEGINS*******************/
void solve()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b;
}
int32_t main()
{
	c_p_c();
	// test(x)
	solve();
}

Measured memory_bytes: 3608
N = int(input())
X = list(map(int, input().split()))
X = list(sorted(X))
if N == 1:
  print(0)
  exit()
ans = float('inf')
for p in range(X[0], X[N - 1] + 1):
  sum = 0
  for x in X:
    sum += (x - p) ** 2
  ans = min(sum, ans)
print(ans)

Measured memory_bytes: 3064
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl N;

void solve(void) {
  // N = floor(X * 1.08) = X * 1.08 - d (0 <= d < 1)
  ld Xcand = static_cast<ld>(N) / 1.08;
  // Xcand = N/1.08 = X - d/1.08
  // Xcand 
  if (1.08 * (ceil(Xcand) - Xcand) < 1) {
    cout << ceil(Xcand) << endl;
  } else {
    cout << ":(" << endl;
  }
}

int main(void) {
  cin >> N;
  solve();
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"math"
	"os"
	"strconv"
)

const YES = "Yes"

type IntList []int

func (a IntList) ChMin(i int, value int) bool {
	curV := a[i]
	if curV > value {
		a[i] = value
		return true
	}
	return false
}
func lib_NewIntList(length int, initialValue int) IntList {
	ret := make([]int, length, length)
	for i := 0; i < length; i++ {
		ret[i] = initialValue
	}
	return ret
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var M int
	scanner.Scan()
	M, _ = strconv.Atoi(scanner.Text())
	A := make([]int, M)
	B := make([]int, M)
	for i := 0; i < M; i++ {
		scanner.Scan()
		A[i], _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		B[i], _ = strconv.Atoi(scanner.Text())
	}
	solve(N, M, A, B)
}
func solve(N int, M int, A []int, B []int) {
	m := lib_NewIntList(N+10, math.MaxInt64/2)
	m[1] = 0
	routes := map[int][]int{}
	for i := 0; i < len(A); i++ {
		a, b := A[i], B[i]
		routes[a] = append(routes[a], b)
		routes[b] = append(routes[b], a)
	}
	queue := list.New()
	queue.PushBack(1)
	sirube := lib_NewIntList(N+10, -1)
	sirube[1] = 0
	for queue.Len() > 0 {
		room := queue.Front()
		queue.Remove(room)
		roomId := room.Value.(int)
		neighbors := routes[roomId]
		for _, n := range neighbors {
			if sirube[n] != -1 {
				continue
			}
			if m.ChMin(n, m[roomId]+1) {
				sirube[n] = roomId
			}
			queue.PushBack(n)
		}
	}
	fmt.Println(YES)
	for i := 2; i <= N; i++ {
		fmt.Println(sirube[i])
	}
}


Measured memory_bytes: 29784
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b,c,d;
	string s;
	cin>>n>>a>>b>>c>>d>>s;
	a--; b--; c--; d--;

	bool ok=true;
	range(i,a,max(c,d))if(s[i]=='#' and s[i+1]=='#')ok=false;

	if(c<d){
		Yn(ok);
	}else{
		bool ok2=false;
		range(i,b,d+1){
			ok2 |= (s[i-1]=='.' and s[i]=='.' and s[i+1]=='.');
		}
		Yn(ok and ok2);
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll MOD = 1000000007LL;
/*メモ XOR問題のまとめ
性質 1「交換則、結合則が成り立つ」
　　 2「a xor a = 0」
　　 3「ある数xのb番目のビットが1である <=> x mod 2^(b+1) ≧ 2^b」
　　 4「0≦aのとき、4a, 4a+1, 4a+2, 4a+3のxor和は0」
方針 
!!!!!1「xor計算は各ビットで独立なので別々に計算」
　　 2「trieを使ったxorの最大最小探索がある解説」
・しゃくとり法は[ｌ,r)で考えるとわかりやすいよ！
*/
int main(){
    ll n,c;
    std::cin >> n>>c;
    std::vector<ll> x(n),v(n);
    rep(i,n)std::cin >> x[i]>>v[i];
    std::vector<ll> rx(x),rv(v);
    reverse(all(rx));reverse(all(rv));
    rep(i,n)rx[i]=c-rx[i];
    std::vector<ll> val(n),rval(n);
    val[0]=v[0];rval[0]=rv[0];
    rep(i,n-1){
        val[i+1]=val[i]+v[i+1];
        rval[i+1]=rval[i]+rv[i+1];
    }
    std::vector<ll> nnval(n);
    rep(i,n)nnval[i]=val[i]-2*x[i];
    
    
    std::vector<ll> rnnval(n);
    rep(i,n)rnnval[i]=rval[i]-2*rx[i];
    
    rep(i,n-1)nnval[i+1]=max(nnval[i+1],nnval[i]);
    rep(i,n-1)rnnval[i+1]=max(rnnval[i+1],rnnval[i]);
    ll lans=0ll,rans=0ll;
    std::vector<ll> nval(n);
    rep(i,n)nval[i]=val[i]-x[i];
    std::vector<ll> rnval(n);
    rep(i,n)rnval[i]=rval[i]-rx[i];
    //rep(i,n)std::cout << nval[i] << std::endl;
    rep(i,n){
        ll d1=nval[i],d2=rnval[i];
        
        if(n-i-2>=0){
            d1+=max(0ll,rnnval[max(n-i-2,0ll)]);
            d2+=max(0ll,nnval[max(n-i-2,0ll)]);
        }
        lans=max(lans,d1);
        rans=max(rans,d2);
      //  std::cout << i<<" "<<n-i-1 << std::endl;
    }
    std::cout << max(rans,lans) << std::endl;
}

Measured memory_bytes: 8064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC072B_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            for(var i = 0; i < s.Length; i+=2)
            {
                Console.Write(s[i]);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 11360
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  string s;
  cin >> s;
  
  int ans = MOD;
  REP(i,26){
    int pre = s.size();
    int cnt = -1;
    RREP(j,s.size()){
      if(s[j]-'a' != i) continue;
	  cnt = max(cnt,pre-j-1);
      pre = j;
    }
    if(pre == s.size()) continue;
    cnt = max(cnt,pre);
    ans = min(ans,cnt);
  }
   
  cout << ans << endl;

  return 0;
}
// たぶん距離でやっているとおもわれる

Measured memory_bytes: 256
fn main() {
  let _: usize = read();
  let s: String = read();
  
  let ans =["SS","SW","WS","WW"].iter().filter_map(|pat| valid(&s, pat)).next();
  println!("{}", ans.unwrap_or("-1".to_string())); 
}

fn valid(s: &str, pat: &str) -> Option<String> {
  let s = s.chars().collect::<Vec<_>>();
  let mut pat = pat.chars().collect::<Vec<_>>();
  
  let l = s.len();
  for i in 1 .. l + 1 {
    let prev = pat[(i-1)%l];
    match (s[i%l], pat[i%l]) {
      ('o', 'S') => pat.push(prev),
      ('o', 'W') => pat.push(if prev=='S' {'W'} else {'S'}),
      ('x', 'S') => pat.push(if prev=='S' {'W'} else {'S'}),
      ('x', 'W') => pat.push(prev),
      _ => unreachable!()
    }
  }
  
  if pat[0] == pat[l] && pat[1] == pat[l+1] {
    pat.pop();
    pat.pop();
    Some(pat.iter().map(|&c| c).collect::<String>())
  } else {
    None
  }
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}


Measured memory_bytes: 4352
import java.util.Scanner;
class Main {

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String str1 = sc.next();
	    char[] strArray1 = new char[str1.length()];

	    for (int i = 0; i < str1.length(); i ++){
	    	strArray1[i] = str1.charAt(i);
	    	if (Character.isUpperCase( strArray1[i] )){
	    		System.out.print(String.valueOf(strArray1[i]).toLowerCase());

	    	} else {
	    		System.out.print(String.valueOf(strArray1[i]).toUpperCase());
	    	}
	    }

	    while (sc.hasNext()){
	    	String str = sc.next();
		    char[] strArray = new char[str.length()];
		    System.out.print(" ");

		    for (int i = 0; i < str.length(); i ++){
		    	strArray[i] = str.charAt(i);
		    	if (Character.isUpperCase( strArray[i] )){
		    		System.out.print(String.valueOf(strArray[i]).toLowerCase());

		    	} else {
		    		System.out.print(String.valueOf(strArray[i]).toUpperCase());
		    	}
		    }
	    }
	    System.out.println("");

	}

}



Measured memory_bytes: 27176
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> A(N);
  long long sum = 0;
  int m         = 1e9 + 1;
  int count     = 0;
  for (int i = 0; i < N; i++) {
	  cin >> A[i];
	  sum += abs(A[i]);
	  m    = min(abs(A[i]), m);
	  if (A[i] < 0) {
		  count++;
		}
	}
  cout << sum - (count % 2 == 0 ? 0 : 2 * m) << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int i;
		for(i = 1; i <= n; ++i){
			if(i % 3 == 0){
				System.out.print(" "+i);
				}
			else if(i % 10 == 3){
				System.out.print(" "+i);
			}
			else if(i % 100 >= 30 && i % 100 < 40){
				System.out.print(" "+i);
			}
			else if(i % 1000 >= 300 && i % 1000 < 400){
				System.out.print(" "+i);
			}
			else if(i % 10000 >= 3000 && i % 10000 < 4000){
				System.out.print(" "+i);
			}
		}
		System.out.println();
	}
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int A,B,C, D, N;
string S;
bool flag = true;

void solve(){
    rep(i, N-1){
        if(S.substr(i,2) =="##"){
            if( (A <= i && i+1 <= C) || ( B <= i && i+1 <= D)){
                flag = false;
                break;
            }
        }
    }

    if(flag && D < C){
        flag = false;

        rep(i, N-2){
            if(S.substr(i,3) == "..." &&  B <= i+1 && i+1 <= D) flag = true;
        }
    }

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

int main(){
    cin >> N >> A >> B >> C >> D >> S;

    A--, B--, C--, D--;

    solve();
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;
int main()
{
  string a,b,c;
  cin>>a>>b>>c;
  char d=toupper(a[0]);
  char e=toupper(b[0]);
  char f=toupper(c[0]);
  cout<<d<<e<<f<<endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
a = [int(i) for i in input().split()]
j=0
for i in range(N):
    b=a[i]
    if b==j+1:
        j+=1
if j ==0:
    s=-1
else:s=N-j
print(s)

Measured memory_bytes: 25768
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    ll n, w;
    cin>>n>>w;

    ll weight[n+1];
    ll profit[n+1];

    for(ll i=1; i<=n; i++){
        cin>>weight[i]>>profit[i];
    }

    int maxProfit = 100001;

    vector<vector<ll> > dp(n+1, vector<ll> (maxProfit, INT_MAX));

    for(int i=0; i<=n; i++){
        dp[i][0] = 0;
    }

    for(int i=1; i <= n; i++){
        for(int j=1; j < maxProfit; j++){
            dp[i][j] = dp[i-1][j];

            if(profit[i] <= j && dp[i-1][j - profit[i]] != INT_MAX){
                dp[i][j] = min(dp[i][j], weight[i] + dp[i-1][j - profit[i]]);
            }
        }
    }

    ll ans = LONG_MAX;

    for(int j=1; j<maxProfit; j++){
        if(dp[n][j] <= w){
            ans = j;
        }
    }

    if(ans == INT_MAX)
        ans = 0;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 83180
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
struct node{
    int x,i;
    node():x(0),i(0){}
    node(int y,int j):x(y),i(j){}
};
bool operator < (node a,node b)
{
	return a.x<b.x;
}
stack<int>s;
int n,x[80001],idx,tot,id[80001],low[80001],dfn[80001],scc,col[80001];
vector<node>vec;
vector<int>point[80001];

void build(int nod,int l,int r)
{
    id[nod]=++tot;
    if(nod>1)point[id[nod>>1]].push_back(tot);
    if(l==r)
	{
		int v=vec[l-1].i;
		point[id[nod]].push_back(v<=n?v+n:v-n);
		return;
	}
    int mid=l+r>>1;
    build(nod<<1,l,mid);
	build(nod<<1|1,mid+1,r);
}
void update(int nod,int l,int r,int a,int b,int x){
    if(a>b)return;
    if(l==a&&r==b)
	{
		point[x].push_back(id[nod]);
		return;
	}
    int mid=l+r>>1;
    if(mid>=b)update(nod<<1,l,mid,a,b,x);
	else if(mid<a)update(nod<<1|1,mid+1,r,a,b,x);
	else update(nod<<1,l,mid,a,mid,x),update(nod<<1|1,mid+1,r,mid+1,b,x);
}
pair<int,int> get(int i,int m){
    pair<int,int> res;int l=1,r=i,mid;
    while(l<=r)if(vec[i-1].x-vec[(mid=l+r>>1)-1].x>=m)l=mid+1;else r=mid-1;
    res.first=r+1,l=i,r=n<<1;
    while(l<=r)if(vec[(mid=l+r>>1)-1].x-vec[i-1].x<m)l=mid+1;else r=mid-1;
    res.second=l-1;
    return res;
}

void tarjan(int u)
{
    low[u]=dfn[u]=++idx;s.push(u);
    for(int i=0;i<point[u].size();i++)
	{
		int v=point[u][i];
		if(!dfn[v]){tarjan(v);low[u]=min(low[u],low[v]);}
		else if(dfn[v]>0)low[u]=min(low[u],dfn[v]);
	}
    if(low[u]==dfn[u]){int x;++scc;while(x!=u)x=s.top(),s.pop(),dfn[x]=-dfn[x],col[x]=scc;}
}
bool pd(int mid)
{
	scc=idx=0;
    memset(low,0,sizeof(low)),
	memset(dfn,0,sizeof(dfn));
	for(int i=1;i<=80000;i++)point[i].clear();
    build(1,1,tot=n<<1);
    for(int i=1;i<=n<<1;i++)
	{
		int r=vec[i-1].i;
		pair<int,int>pr=get(i,mid);
		update(1,1,n<<1,pr.first,i-1,r);
		update(1,1,n<<1,i+1,pr.second,r);
	}
    for(int i=1;i<=n<<1;i++)if(!dfn[i])tarjan(i);
    for(int i=1;i<=n;i++)
		if(col[i]==col[i+n])return false;
    return true;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)
	{
		x[i]=read();x[i+n]=read();
		vec.push_back(node(x[i],i));
		vec.push_back(node(x[i+n],i+n));
	}
    sort(vec.begin(),vec.end());
    int l=0,r=1e9;
	while(l<r)
	{
		int mid=(l+r+1)/2;
		if(pd(mid))l=mid;
		else r=mid-1;
	}
    cout<<l; 
}

Measured memory_bytes: 12624
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

x,y = I()
ans = abs(abs(x)-abs(y))
if x*y<0:
    ans += 1
elif (x > 0 and y == 0) or (y < 0 and x == 0):
    ans += 1
elif x > y:
    ans += 2
print(ans)


Measured memory_bytes: 9976
#ABC106B
def main():
    import sys
    N = int(sys.stdin.readline())
    
    def calc(num):
        cnt = 0
        for i in range(num, 0, -1):
            if num  % i==0:
                cnt+=1
        if cnt==8:
            #print(cnt, num)
            return 1
        return 0
        
    
    ans = 0
    for i in range(1, N+1, 2):
        ans +=calc(i)
    print(ans)
    
                    
    

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

ll MOD=100000007;

ll dp1[100001][5];
ll dps1[100001];
ll dp2[100001][3];
ll dps2[100001];

main(){
  string in;

  dp1[1][0]=1;
  dp2[1][0]=1;
  for(int i=2;i<=100000;++i){
    rep(j,5)
      dp1[i][0]+=dp1[i-1][j];

    rep(j,3)dp2[i][0]+=dp2[i-1][j];
    
    for(int j=1;j<5;++j){
      if(i-j>=0)dp1[i][j]+=dp1[i-j][0];
    }

    for(int j=1;j<3;++j){
      if(i-j>=0)dp2[i][j]+=dp2[i-j][0];
    }
    rep(j,5)dp1[i][j]%=MOD;
    rep(j,3)dp2[i][j]%=MOD;
  }



  rep(k,100001){
    int sum=0;    
    rep(i,5){
      //cout<<dp1[k][i]<<' ';
      sum+=dp1[k][i];
    }
    if(k>=5)sum+=dps1[k-5];
    //cout<<sum<<endl;
    dps1[k]=sum%MOD;

    sum=0;
    rep(i,3)sum+=dp2[k][i];
    if(k>=3)sum+=dps2[k-3];
    dps2[k]=sum%MOD;
  }
  
  while(cin>>in,in!="#"){
    int idx=0;
    ll ans=1;
    while(idx<SZ(in)){
      int num=0;
      while(idx+num<SZ(in) && in[idx]==in[idx+num])++num;
      if(in[idx]!='8' && in[idx]!='0')ans=(ans*dps1[num])%MOD;
      else ans=(ans*dps2[num])%MOD;
      idx+=num;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;
int a[41],b[41],c[41];
int dp[41][401][401];
int N,Ma,Mb;
int dfs(int i,int x,int y){
	if(dp[i][x][y]!=-1) return dp[i][x][y];
	if(i==N){
		if(x*Mb==y*Ma&&y!=0) return 0;
		return 10000;
	}
	dp[i][x][y]=min(dfs(i+1,x,y),c[i]+dfs(i+1,x+a[i],y+b[i]));
	return dp[i][x][y];
}

int main(){

	cin>>N>>Ma>>Mb;
	REP(i,0,N){
		cin>>a[i]>>b[i]>>c[i];
	}
	memset(dp,-1,sizeof dp);
	int ans=dfs(0,0,0);
	if(ans>=10000) ans=-1;
	p(ans);
	return 0;
}



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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const ll inf = 1e17;
const int modn = 1e9+7;
const int MAX = 1e5;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n, W;
	cin>>n>>W;
	vector<ll> w(n+1);
	vector<ll> val(n+1);
	ll maxval=0;
	for(int i=1; i<=n; i++) {
		cin>>w[i]>>val[i];
		maxval+=val[i];
	}
	
	vector<vector<ll>> dp(n+1, vector<ll>(maxval+1));
	for(int i=0; i<=n; i++) {
		dp[i][0]=0;
	}
	for(ll i=1; i<=maxval; i++) {
		dp[0][i]=inf;
	}
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=maxval; j++) {
			ll ans1=dp[i-1][j];
			ll ans2=inf;
			if(j>=val[i])
				ans2=dp[i-1][j-val[i]]+w[i];
			dp[i][j]=min(ans1, ans2);
		}
	}
	
	//~ printVV(dp);
	
	ll ans=0;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=maxval; j++) {
			if(dp[i][j]<=W) {
				ans=j;
			}
		}
	}
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 80256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
    int a = 10;

    int N;

    cin >> N;
    VI avec(N);

    REP(i,N){
        cin >> avec[i];
    }
    sort(avec.begin(), avec.end());

    int olda = -1;
    int newa = -1;
    int count = 0;
    int ans = 0;
    if(N==0){
        cout << "0" << endl;
        return 0;
    }
    newa = avec[0];
    REP(i,N){
        olda = newa;
        newa = avec[i];        
        if(olda != newa  ){
            if(count < olda) ans += count;
            else             ans += count - olda;
            count = 0;
        }
        count++;
    }


    if(count < olda) ans += count;
    else             ans += count - olda;

    cout << ans << endl;
   
}





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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vi ans(n);

    rep(i, 2) {
        int cnt = 0;
        rep(j, n) {
            if(s[j] == 'R') cnt++;
            else {
                ans[j] += cnt / 2;
                ans[j - 1] += (cnt+1) / 2;
                cnt = 0;
            }
        }

        reverse(all(ans));
        reverse(all(s));
        rep(j, n) {
            if(s[j] == 'R') s[j] = 'L';
            else s[j] = 'R';
        }
    }

    rep(i, n) {
        cout << ans[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 1024
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

int main()
{
	speed;
	
	string s;
	cin>>s;
	ll k;
	cin>>k;

	ll l=s.length();
	ll ind=-1;
	for(ll i=0;i<l;i++)
	{
		if(s[i]!='1')
		{
			ind=i;
			break;
		}
	}

	if(ind==-1)
	{
		cout<<1;

	}else if(k<=ind ){
		cout<<1;
	}else{
		cout<<s[ind];
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a;
  scanf("%d",&a);
  int i;
  i = 1;
  long sum = 0;
  while (i <= a)
  {
    if (!(i % 3 == 0 || i % 5 == 0))
      sum += i;
    i++;
  }
  printf("%ld",sum);
}

Measured memory_bytes: 1732
n, t = input().split()
n = int(n)
t = int(t)

a = [int(x) for x in input().split()]
sum = 0

for i in range(1, n):
    #print ('a[' + str(i) + '] = ' + str(a[i]))
    if a[i] - a[i - 1] > t:
        tmp = t
    else:
        tmp = a[i] - a[i - 1]
    #print ('tmp = ' + str(tmp))
    sum += tmp
sum += t
print (sum)

Measured memory_bytes: 25248
class RoundRobin(object):
    def __init__(self, n, q, names, times):
        self.n = n
        self.q = q
        self.size = 2 * n

        self.queue = [0] * self.size
        self.queue[:n] = [ ( names[i], int(times[i]) ) for i in range(n) ]
        self.head = 0
        self.tail = n

    def enqueue(self, x):
        self.queue[self.tail] = x
        self.tail = ( self.tail + 1 ) % self.size
        return

    def dequeue(self):
        x = self.queue[self.head]
        self.queue[self.head] = 0
        self.head = ( self.head + 1 ) % self.size
        return x

    def execute(self):
        t = 0
        while 1:
            u = self.dequeue()
            if u[1] > self.q:
                t += self.q
                self.enqueue( (u[0], u[1] - self.q ) )
            else:
                t += u[1]
                print(u[0], t)
            if self.head == self.tail:
                break
        return

n, q = map(int, input().split())

names = [0]*n
times = [0]*n
for i in range(n):
    names[i], times[i] = input().split()

model = RoundRobin(n, q, names, times)
model.execute()


Measured memory_bytes: 13924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int mod=1e9+7;
ll binpow(ll a,ll b)
{
    if(b<0) return 0; 
    ll ans=1;
    while(b)
    {
        if(b%2) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return ans;
}
int main()
{
   ll n;
   cin>>n;
   ll val=binpow(10,n);
   ll val1=binpow(9,n);
   ll val2=binpow(8,n);
  // cout<<val<<" "<<val1<<" "<<val2<<"\n";
  ll val3=(val-((2*val1)%mod)+mod+val2)%mod;
cout<<val3<<"\n";



}

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

using namespace std;
const int MAXN=3005,MOD=1e9+7;
char s[MAXN];
int n,m,x,y,pre[MAXN],lst[MAXN],dp[MAXN][MAXN];

int main()
{
	scanf("%d%d%s",&n,&m,s+1);s[n+1]='0';
	for(int i=1;i<=n+1;i++) 
		pre[i]=(s[i]-'0')+pre[i-1],lst[i]=i;
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x,&y),lst[x]=max(lst[x],y);
	for(int i=1;i<=n+1;i++) lst[i]=max(lst[i],lst[i-1]);
	
	dp[1][pre[lst[1]]]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
			if(dp[i][j])
			{
				int l=lst[i]+1,r=lst[i+1];
				if(j) (dp[i+1][pre[r]-pre[l-1]+j-1]+=dp[i][j])%=MOD;
				if(lst[i]-(i-1)-j) (dp[i+1][pre[r]-pre[l-1]+j]+=dp[i][j])%=MOD;
			}
	printf("%d",dp[n+1][0]);
	return 0;
}

Measured memory_bytes: 33920
local s = io.read()
local t = {}
for i = 1, 2019 do
  t[i] = 0
end
t[2019] = 1
local mul = 1
local v = 0
local ret = 0
for i = #s, 1, -1 do
  v = v + mul * (s:sub(i, i):byte() - 48)
  v = v % 2019
  if v == 0 then
    ret = ret + t[2019]
    t[2019] = t[2019] + 1
  else
    ret = ret + t[v]
    t[v] = t[v] + 1
  end
  mul = (mul * 10) % 2019
end
print(ret)


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

long long D[100001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, W;
	long long ans=0;
	cin>>N>>W;
	memset(D,-1,sizeof(D));
	D[0]=0;
	for(int i=0;i<N;i++) {
		int w, v;
		cin>>w>>v;
		for(int j=W-w;j>=0;j--) if(D[j]!=-1) {
			D[j+w]=max(D[j+w],D[j]+v);
			ans=max(ans,D[j+w]);
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(c-b==b-a)cout << "YES" << endl;
    else{cout<<"NO"<<endl;}
 
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int r, c, sum, sumOfAll;
		int[][] sheet;
		String[] size = in.readLine().split(" ");
		r = Integer.parseInt(size[0]);
		c = Integer.parseInt(size[1]);
		StringBuilder sb = new StringBuilder((r + 1) * (c + 1));
		sheet = new int[r][c];
		for (int i = 0; i < r; i += 1) {
			sum = 0;
			String[] array = in.readLine().split(" ");
			for (int j = 0; j < c; j += 1) {
				sheet[i][j] = Integer.parseInt(array[j]);
				sb.append(sheet[i][j]).append(" ");
				sum += sheet[i][j];
			}
			sb.append(sum + System.getProperty("line.separator"));
		}
		in = null;
		sumOfAll = 0;
		for (int m = 0; m < c; m += 1) {
			sum = 0;
			for (int n = 0; n < r; n += 1) {
				sum += sheet[n][m];
			}
			sumOfAll += sum;
			sb.append(sum).append(" ");
		}
		sb.append(sumOfAll);
		System.out.println(sb);
		sb = null;
	}
}

Measured memory_bytes: 23144