akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


int h[110];

int main(){
  int N;
  cin >> N;
  int ans = 0;
  int M = 0;
  rep(i,N){
    int p;
    cin >> p;
    ans += p;
    M = max(p,M);
  }
  cout << ans - M/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll a,b;cin>>a>>b;
    ll mx=a+b;
    mx=max(mx,a-b);
    mx=max(mx,a*b);
    cout<<mx<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  long long A,B;
  cin>>A>>B;
  
  long long l;
  
  for(long long i=1;i<=B;i++){
    if((A*i)%B==0){
      l=A*i;
      break;
    }
  }
  
  cout<<l<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

int get(int x, int y, int n) {
  if (y >= x) {
    return y - x;
  }
  return n - x + y;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
	int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < k; i++) {
    cin >> a[i];
  }
  int mx = 0;
  for (int i = 0; i < k; i++) {
    int to = (i + 1) % k;
    mx = max(mx, get(a[i], a[to], n));
  }
  cout << n - mx << '\n';
} 

Measured memory_bytes: 8064
S = input()
K = int(input())

len_array = [0] * 100

s_old = S[0]
count = 0
first_flag = 1
first_count = 0
last_count = 0
for s in S:
    if s_old == s:
        count += 1
    else:
        if first_flag:
            first_count = count
            first_flag = 0
        len_array[count - 1] += 1
        count = 1
    s_old = s
last_count = count
len_array[count - 1] += 1
if count == len(S):
    print(count * K // 2)
    exit()

if S[0] != S[-1]:
    ans = 0
    for i, l in enumerate(len_array):
        ans += (i + 1) // 2 * l
    print(ans * K)
    exit()
else:
    len_array[first_count - 1] -= 1
    len_array[last_count - 1] -= 1
    ans = 0
    for i, l in enumerate(len_array):
        ans += (i + 1) // 2 * l
    ans = ans * K + ((first_count + last_count) // 2) * (
        K - 1) + first_count // 2 + last_count // 2
    print(ans)
    exit()

Measured memory_bytes: 38336
n=int(input())
a=input().split()
for i in range(n):
  a[i]=int(a[i])
r=0
for k in range(n-1):
  if a[k]>a[k+1]:
    w=a[k]-a[k+1]
    a[k+1]=a[k]
    r=r+w
print(r)

Measured memory_bytes: 25036
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];
    bool f = false;;
    REP(i, N) if(a[i]&1) f = true;
    if(f)pr("first");
    else pr("second");
}

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

using namespace std;

#define ll long long

int main(){

ll n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
n--;
for(int i = 0; i <= n; ++i){
ll mn = i * c - (n - i) * d;
ll mx = i * d - (n - i) * c;
if(mn <= b - a && b - a <= mx){
puts("YES");
return 0;
}
}
puts("NO");
return 0;
}

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

int main() {
  int N, M , C;
  cin >> N >> M >> C;
  
  vector<int> B(M,0);
  for(int m=0; m<M; m++) {
    cin >> B[m];
  }
  
  int ans = 0;
  for(int n=0; n<N; n++) {
    int sum = 0;
    for(int m=0; m<M; m++) {
      int A;
      cin >> A;
      sum += A * B[m];
    } 
    if(sum+C>0) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	long long int ans, a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 0)ans = a - b;
	else ans = b - a;
	if (ans < -1000000000000000000 || 1000000000000000000 < ans)cout << "Unfair" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
integer N,M
integer a,b
integer,allocatable,dimension(:,:)::graph
integer,allocatable,dimension(:)::visited
read*,N,M
allocate(graph(N,N),visited(N))
graph=0;visited=0
do i=1,M
  read*,A,B
  graph(A,B)=1
  graph(B,A)=1
end do
visited(1)=1
print*,DFS(1,N,visited)
contains
recursive function DFS(node,N,visited)result(res)
  implicit none
  integer::node,N,i
  integer,dimension(:)::visited(N)
  integer res
  res=0
  if(allpoint(N,visited))then
    res=1
    return
  endif
  do i=1,N
    if(graph(node,i)==1 .and. visited(i)/=1 )then
      visited(i)=1
      res=res+dfs(i,N,visited)
      visited(i)=0
    endif
  end do
  return
end function
function allpoint(N,visited)
  integer N
  integer,dimension(:)::visited(N)
  logical allpoint
  allpoint=.true.
  do i=1,N
    allpoint=allpoint.and.(visited(i)==1)
  end do
end function
end

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,l;
	string a[110];
	cin>>n>>l;
	char b[110];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)
		cout<<a[i];
	cout<<endl; 
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a= sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int num = b/a;
		if(num>c) {System.out.println(c);}
		else {System.out.println(num);}

	}
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>0&&a<10&&b>0&&b<10)
	{
		cout<<a*b<<endl;
	}
	else
	{
		cout<<"-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define str string
#define pi pair
#define tup tuple
#define vec vector
#define temp template
#define tn typename

#define ff first
#define ss second
#define SZ(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front 
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk make_pair

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++) 
#define ROF(i, a, b) for (ll i = (a); i >= (b); i--)
#define trav(a, x) for (auto &a : x)
#define popcount __builtin_popcount
#define ctz __builtin_ctz
#define clz __builtin_clz
#define gcd __gcd

// DEBUG
#define ts to_string
temp<tn A, tn B> str ts(pi<A, B> p);
temp<tn A, tn B, tn C> str ts(tup<A, B, C> p);
str ts(const str& s) { return '"' + s + '"'; }
str ts(const char* s) { return ts((str) s); }
str ts(bool b) { return (b ? "true" : "false"); }
str ts(vec<bool> v) { bool f = true; str res = "{";
FOR(i, 0, static_cast<ll>(v.size()) - 1) 
{ if (!f) res += ", "; res += ts(v[i]);
f = false; } res += "}"; return res; }
temp<size_t N> str ts(bitset<N> v) { str res = "";
trav(a, v) { res += (char) ('0' + a); } return res; }
temp<tn A> str ts(A v) { bool f = true; str res = "{";
trav(x, v) { if (!f) res += ", "; res += ts(x);
f = false; } res += "}"; return res; }
temp<tn A, tn B> str ts(pi<A, B> p) { 
  return "(" + ts(p.ff) + ", " + ts(p.ss) + ")"; }
temp<tn A, tn B, tn C> str ts(tup<A, B, C> t) {
  return "(" + ts(get<0>(t)) + ", " + ts(get<1>(t)) + ", " + ts(get<2>(t)) + ")"; }
void DBG() { cerr << endl; }
temp<tn H, tn... T> void DBG(H h, T... t) { cerr << " " << ts(h); DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", DBG(__VA_ARGS__);

// INPUT AND OUTPUT
temp<tn T> void re(T& x) { cin >> x; };
temp<tn H, tn... T> void re(H& h, T&... t) { re(h); re(t...); }
temp<tn T> void pr(T x) { cout << x; };
temp<tn H, tn... T> void pr(H h, T... t) { pr(h); pr(t...); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b;
  re(a, b);
  pr(a * b, '\n');
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
vector<int64_t> par(100005);

void init(int64_t n){
  rep(i,n) par[i] = i;
}

int root(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = root(par[x]);
  }
}

bool same(int x,int y){
  return root(x) == root(y);
}

void unite(int x,int y){
  x = root(x);
  y = root(y);
  if(x == y)return;
  par[x] = y;
  //cout << "#";
}
    
 
int main(){
  int64_t n,m;
  cin >> n >> m;
  vector<int64_t> p(n);
  rep(i,n){
    cin >> p.at(i);
  }
  init(n);
  rep(i,m){
    int64_t x,y;
    cin >> x >> y;
    unite(x-1,y-1);
  }
  int64_t cnt = 0;
  rep(i,n){
    if(same(i,p[i]-1)){
      cnt++;
    }
  }
  /*rep(i,n){
    cout << par[i];
  }*/
  cout << cnt << endl;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  
  vector<int> x(n,1);
  
  for(int i=2;i<=n;i++){
    int a=i;
    for(int j=2;j<=i;j++){
      while(a%j==0){
        a/=j;
        x.at(j-1)++;
      }
    }
  }
  
  long long int k=1;
  
  for(int i=0;i<n;i++){
      k*=x.at(i);
      k%=1000000007;
  }
  
  cout << k%1000000007 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	int n,a,b;
	cin >> n >> a >> b;
	int p[n] = {0},cnt[3] = {0};
	
	rep(i,0,n){
		cin >> p[i];
		
		if(p[i] <= a){
			cnt[0]++;
		}
		else if(p[i] > b){
			cnt[2]++;
		}
		else{
			cnt[1]++;
		}
	}
	
	cout << min(cnt[0],min(cnt[1],cnt[2])) << endl;
	return 0;

}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

using event_sub = pair<int, ll>; // -1: insert, 0: delete, 1 :query
using event = pair<ll, event_sub>;

int main() {
    // source
    ll n, q;
    cin >> n >> q;
    ll s[n], t[n], x[n];
    rep(i, n) { cin >> s[i] >> t[i] >> x[i]; }
    ll d[q];
    rep(i, q) { cin >> d[i]; }

    // calculate
    vector<event> v;
    rep(i, n) {
        v.push_back({s[i] - x[i], event_sub(-1, x[i])});
        v.push_back({t[i] - x[i], event_sub(0, x[i])});
    }
    rep(i, q) { v.push_back({d[i], event_sub(1, i)}); }

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

    vector<ll> ans(q);
    multiset<ll> se;
    for (auto p : v) {
        ll x_num = p.first;
        int type = p.second.first;
        ll val = p.second.second;

        if (type == -1) {
            se.insert(val);
        } else if (type == 0) {
            se.erase(se.find(val));
        } else {
            if (se.empty()) {
                ans[val] = -1;
            } else {
                ans[val] = *(se.begin());
            }
        }
    }

    rep(i, q) { cout << ans[i] << endl; }
    return 0;
}



Measured memory_bytes: 34532
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmin(T &a, T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<vector<int>> edges(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edges[a].emplace_back(b);
	}

	auto bfs = [&](int st) {
		
		// stからの最短経路 bfs, stが出てきたらloopにメモ
		vector<int> dist(N, INF), prev(N, -1), loop;
		dist[st] = 0;
		queue<int> que;
		que.emplace(st);
		while (!que.empty()) {
			int now = que.front(); que.pop();
			for (const auto &e : edges[now]) {
				if (e == st) loop.emplace_back(now);
				if (dist[e] != INF) continue;
				prev[e] = now;
				dist[e] = dist[now] + 1;
				que.emplace(e);
			}
		}

		// dist[loopの要素] が最短の時のインデックスを求め、prevから経路復元
		vector<int> res;
		int cyc_sz = INF, min_e = -1;
		for (const auto &e : loop) if(chmin(cyc_sz, dist[e])) min_e = e;
		if (min_e == -1) res =  vector<int>(N + 1);
		else {
			res.emplace_back(min_e);
			while (dist[min_e] > 0) res.emplace_back(min_e = prev[min_e]);
		}

		return res;

	};

	vector<int> ans(N + 1);
	for (int st = 0; st < N; st++) {
		auto tmp = bfs(st);
		if (ans.size() > tmp.size()) ans = tmp;
	}

	if (ans.size() == N + 1) cout << -1 << "\n";
	else {
		cout << ans.size() << "\n";
		for (const auto &e : ans) cout << e + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 384
main = interact main'

main' :: String -> String
main'
    = show . f . map read . words . head . lines

f :: [Integer] -> Integer
f [a, b] = (g a) + (g b) + (h a b)

g 1 = 300000
g 2 = 200000
g 3 = 100000
g _ = 0

h 1 1 = 400000
h _ _ = 0

Measured memory_bytes: 380
s=list(input())
t=list(input())
match=[]
accord=[]
for i in range(len(s)):
    if s[i] in match:
        ind=match.index(s[i])
        acc=accord[ind]
        if t[i]!=acc:
            print('No')
            exit()
    elif t[i] in accord:
        ind=accord.index(t[i])
        mat=match[ind]
        if s[i]!=mat:
            print('No')
            exit()
    else:
        match.append(s[i])
        accord.append(t[i])
print('Yes')

Measured memory_bytes: 6704
import java.util.*;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int d=sc.nextInt();

		int r=2*d+1;

		int ans = (n+(r-1))/r;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 35532
N = int(input())
S = input()
alphabet = [
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
    "H",
    "I",
    "J",
    "K",
    "L",
    "M",
    "N",
    "O",
    "P",
    "Q",
    "R",
    "S",
    "T",
    "U",
    "V",
    "W",
    "X",
    "Y",
    "Z",
]
ans = []
for s in S:
    ans.append(alphabet[(alphabet.index(s) + N) % 26])
print("".join(ans))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define mod 1
int main()
{
  ll k,a,b ;
  cin >> k >> a >> b ;
  if(a%k==0||b%k==0) cout << "OK" << endl;
  else if((a/k)!=(b/k)) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
#define INF 10000000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
const int MAX_V=100001;
const int MAX_N=101;
ll dp[MAX_N][MAX_V];
int main(void){
    int N,W;
    cin>>N>>W;
    int w[N],v[N];
    for(int i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<MAX_N;i++){
        for(int j=0;j<MAX_V;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<MAX_V;j++){
            if(j-v[i]>=0){
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            
        }
    }
    ll ans=0;
    for(ll j=0;j<MAX_V;j++){
        if(dp[N][j]<=W)ans=j;
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 79232
//  Author : Amit Kumar 

#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

int main(void){
    

#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 

#ifdef HELL_JUDGE
    auto INITIAL_TIME = high_resolution_clock::now();
#endif 
    int n; cin >> n; 
    vector<int>v(n);
    for(auto&itr:v){cin >> itr;}
    sort(v.begin() , v.end() , greater<int>());
    queue<int>q;
    int64_t counter{};
    bool firsttime = true;
    bool ff = true;
    int x = 2;
    for(auto&itr:v){
        q.push(itr);
        if(firsttime){
            firsttime = false; 
            continue;
        }
        if(ff){
            counter += q.front(); 
            q.pop();
            ff =false;
            continue;
        }
        if(x){
            counter+=q.front();
            x--;
        }else{
            q.pop();
            x = 1; 
            counter+=q.front();
        }
    }
    cout << counter << '\n'; 
#ifdef HELL_JUDGE
    auto FINAL_TIME = high_resolution_clock::now();
    cout << "Time : "
         << duration_cast<milliseconds>(FINAL_TIME-INITIAL_TIME).count() 
         << " ms" << '\n'; 
#endif 
    return 0;
}


Measured memory_bytes: 4568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	int N;
	cin>>N;
	vector<int> a(N);
	int asum=0;
	rep(i,N){
		cin>>a[i];
		asum+=a[i];
	}
	rep(i,N)a[i]=abs(N*a[i]-asum);
	int d=inf,ans;
	rep(i,N){
		if(d>a[i]){
			d=a[i];
			ans=i;
		}
	}
	cout<<ans<<endl;
}

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

void Main()
{
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

int f(int i)
{
    if (i % 2 == 0)
        return i / 2;
    else
        return 3 * i + 1;
}

int main()
{
    int s;
    cin >> s;
    vector<int> a;
    for (int i = 1; i <= 1000000; i++)
    {
        if (i == 1)
            a.push_back(s);
        else
        {
            int ai = f(a[i - 2]);
            int cnt = count(a.begin(), a.end(), ai);
            if (cnt > 0)
            {
                cout << i << endl;
                return 0;
            }
            else
                a.push_back(ai);
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N, X; cin >> N >> X; int S[N];
  rep(i, N){
    cin >> S[i];
  }
  sort(S, S+N);
  ll dp[N+1][X+1] = {};
  rep(i, X+1){
    dp[0][i] = i;
  }
  rep(i, N){
    rep(j, X+1){
      dp[i+1][j] = dp[i][j%S[i]] + i*dp[i][j];
      dp[i+1][j]%=mod;
    }
  }
  cout << dp[N][X] << endl;
}

Measured memory_bytes: 157312
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.Array.Unboxed
import Data.Bits
import Data.Bool
import Data.Char
import Data.Coerce
import Data.Function
import Data.Int 
import Data.IORef
import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  [n, x, t] <- getIntList
  print $ solve n x t

solve n x t
  | r > 0 = (q + 1) * t
  | otherwise = q * t
  where
    (q, r) = divMod n x

-- Input

getInt :: IO Int
getInt = readLn
second :: (b -> c) -> (a, b) -> (a, c)
second f (a, b) = (a, f b)

readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = fmap (second BS.tail) . BS.readInt

getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n readInt <$> BS.getLine
 
getIntList :: IO [Int]
getIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

getIntegerList :: IO [Integer]
getIntegerList = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

getIntPair :: IO (Int, Int)
getIntPair = do
  v <- getIntVec 2
  return (v V.! 0, v V.! 1)

-- Search

bisearch :: (Int -> Bool) -> (Int, Int) -> (Int, Int)
bisearch check = bis
  where
    bis (l, r)
      | l + 1 == r = (l, r)
      | check mid  = bis (mid, r)
      | otherwise  = bis (l, mid)
      where
        mid = l + (r - l) `div` 2

-- Modular Arithmetic
--
 
modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined
---
 
exEuclid :: (Eq a, Integral a) => a -> a -> (a, a, a)
exEuclid !f !g = loop 1 0 0 1 f g
  where loop !u0 !u1 !v0 !v1 !f 0 = (f, u0, v0)
        loop !u0 !u1 !v0 !v1 !f g =
          case divMod f g of
            (q,r) -> loop u1 (u0 - q * u1) v1 (v0 - q * v1) g r
 
recipM :: Int64 -> Int64
recipM !x = case exEuclid x modulo of
             (1,a,_) -> a `mod` modulo
             (-1,a,_) -> (-a) `mod` modulo
divM :: Int64 -> Int64 -> Int64
divM !x !y = x `mulMod` recipM y
 
instance Fractional N where
  (/) = coerce divM
  recip = coerce recipM
  fromRational = undefined

-- 組み合わせ
powerset :: [a] -> [[a]]  
powerset xs = filterM (\x -> [True, False]) xs


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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int res =1;
    int i =0;
    while(res < m)
    {
        i++;
        res = res + (n -1);
    }

    cout << i;
    return 0;
}

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

int main()
{
  int A, B, flag = -1;

  cin >> A >> B;
  for (int i = 0; i < 2000; i++)
  {
    if ((int)(i * 0.08) == A && (int)(i * 0.1) == B)
    {
      flag = i;
      break;
    }
    
  }
  cout << flag << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define INF 2e9
#define LLINF 11e16
 
using namespace std;
 
typedef long long ll;

int main(){
	string s,t;
	cin >> s >> t;
	
	int ans = 0;
	rep(i, 3){
		if(s.at(i) ==t.at(i)) ans++;
	}
	cout << ans << endl;
	
	return 0;
}
	
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	init();

	int K; cin >> K;
	ll sum = 0;
	rep(i, 1, K + 1) {
		rep(j, 1, K + 1) {
			rep(k, 1, K + 1) {
				sum += gcd(i, gcd(j, k));
			}
		}
	}
	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<math.h>

int main(){
long long x;
scanf("%lld",&x);
double a=sqrt(8*x+1);
double k=(a-1)/2;
//printf("%.4f\n",k);
long long m=k;
if(k>m) m++;
printf("%lld",m);
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        cs: [[usize; m + 1]; n],
    }

    let mut ans = std::usize::MAX;

    for i in 0..(1 << n) {
        let mut cost = 0;
        let mut skills = vec![0; m];

        for j in 0..n {
            if (i >> j) & 1 == 1 {
                cost += cs[j][0];
                for k in 1..=m {
                    skills[k - 1] += cs[j][k];
                }
            };
        }

        if skills.iter().all(|&s| s >= x) {
            ans = std::cmp::min(ans, cost);
        }
    }

    if ans == std::usize::MAX {
        echo!(-1);
    } else {
        echo!(ans);
    }
}


Measured memory_bytes: 2192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int a[3]={0};
    rep(i,n){
        if(v[i]%4==0)a[0]++;
        else if(v[i]%2==0)a[1]++;
        else a[2]++;
    }
    if(a[2]<=a[0])fin("Yes");
    else if(a[2]==a[0]+1&&a[1]==0)fin("Yes");
    else fin("No");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

const int MAX = 100005;
const int nil = -1;

struct Node{int parent, left, right; };

Node T[MAX];

// 先行順巡回
void preparse(int u){
    if(u == nil) return;
    printf(" %d", u);
    preparse(T[u].left);
    preparse(T[u].right);
}

// 中間順巡回
void inparse(int u){
    if(u == nil) return;
    inparse(T[u].left);
    printf(" %d", u);
    inparse(T[u].right);
}

// 後行順巡回
void postparse(int u){
    if(u == nil) return;
    postparse(T[u].left);
    postparse(T[u].right);
    printf(" %d", u);
}

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

    int n; cin >> n;
    for(int i=0; i<n; ++i) T[i].parent = nil;

    for(int i=0; i<n; ++i){
        int id, l, r;
        cin >> id >> l >> r;
        T[id].left = l;
        T[id].right = r;
        if(l != nil) T[l].parent = id;
        if(r != nil) T[r].parent = id;
    }

    int root;
    for(int i=0; i<n; ++i) if(T[i].parent == nil) root = i;

    printf("Preorder\n");
    preparse(root);
    printf("\n");

    printf("Inorder\n");
    inparse(root);
    printf("\n");

    printf("Postorder\n");
    postparse(root);
    printf("\n");
    
    return 0;
}




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

using namespace std;

using ll = long long;

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

    int n;
    string s;
    cin >> n >> s;

    map<char, int> c;

    for (char e : s) {
        c[e]++;
    }

    vector<pair<char, ll>> v;
    copy(c.begin(),c.end(), back_inserter(v));

    ll res1 = 0;
    int v2 = (int) v.size() / 2;
    for (int i = 0; i < 1 << v2; ++i) {
        ll sub_res = 1;
        for (int j = 0; j < v2; ++j) {
            if (i >> j & 1) {
                sub_res *= v[j].second;
                sub_res %= (ll) 1e9 + 7;
            }
        }
        res1 += sub_res;
        res1 %= (ll) 1e9 + 7;
    }

    ll res2 = 0;
    for (int i = 0; i < 1 << (v.size() - v2); ++i) {
        ll sub_res = 1;
        for (int j = 0; j < (v.size() - v2); ++j) {
            if (i >> j & 1) {
                sub_res *= v[v2 + j].second;
                sub_res %= (ll) 1e9 + 7;
            }
        }
        res2 += sub_res;
        res2 %= (ll) 1e9 + 7;
    }
    ll res = res1 * res2 - 1;
    res %= (ll) 1e9 + 7;

    cout << res << '\n';

    return 0;
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
    string s;
    cin>>s;
    int mm=(s[5]-'0')*10+(s[6]-'0');
    int dd=(s[8]-'0')*10+(s[9]-'0');
    if(mm>4)
     cout<<"TBD\n";
     else
      cout<<"Heisei\n";
      return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

bool _find(vi &arr,int n){
    
    for(int i=1;i<n;i++){
        if(arr[i]>arr[i-1]){
            arr[i]--;
        }
        else if(arr[i]<arr[i-1]){
            return false;
        }
    }
    return true;
}
int sameParity(int a,int b){
    if(a%2==0 && b%2==0){return 1;}
    if(a%2!=0 && b%2!=0){return 1;}
    return 0;
}
void solve(){
    
    ll n,a,b;
    cin>>n>>a>>b;
    
    // if 1 of them is odd and the other one even, they won't ever meet
    // unless ....!
    ll ans=(b-a)/2;
    if(!sameParity(a,b)){
        ans+=1+min(a-1,n-b);
    }
    cout<<ans<<endl;
}





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

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task "A"

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

int U[maxn], V[maxn];
vector<int> adj[maxn];
int N;
int deg[maxn];
int res = 0;
int ans[maxn];

void dfs(int u, int p, int last)
{
    int color = 1;
    if (color == last) ++color;
    for (int i : adj[u]){
        int v = U[i] + V[i] - u;
        if (v != p){
            ans[i] = color;
            dfs(v, u, ans[i]);
            ++color;
            if (color == last) ++color;
        }
    }
}

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    cin >> N;
    for (int i=1; i<N; ++i){
        cin >> U[i] >> V[i];
        adj[U[i]].pb(i); adj[V[i]].pb(i);
        ++deg[U[i]]; ++deg[V[i]];
    }
    for (int i=1; i<=N; ++i){
        res = max(res, deg[i]);
    }
    dfs(1, -1, -1);
    cout << res << '\n';
    for (int i=1; i<N; ++i)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 9088
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
ll n, k, v[100010];
int main() {
	cin >> n >> k;
	ll a, b;
	rep(i, n) {
		cin >> a >> b;
		v[a] += b;
	}
	rep(i, 100010) {
		k -= v[i];
		if (k <= 0) { cout << i << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(void){
    char top[3];
    scanf("%s",top);
    int cash = 700;
    if(top[0] == 'o')cash += 100;
    if(top[1] == 'o')cash += 100;
    if(top[2] == 'o')cash += 100;
    printf("%d",cash);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int w[10];
	rep(i, 0, 5) if (next<int>() == 0) cout<<i+1<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int h = Integer.parseInt(tmpArray[0]);
		int n = Integer.parseInt(tmpArray[1]);
		
		int a[] = new int[n];
		tmpArray = br.readLine().split(" ");
		
		int sum = 0;
		for(int i = 0; i < n ; i++) {
			a[i] = Integer.parseInt(tmpArray[i]);
			sum += a[i];
		}
		
		if(sum >= h) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


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

int main(){
  int N;cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  int count=1;
  for(int i=1;i<N;i++){
    if(A.at(i-1)!=A.at(i)) count++;
  }
  cout<<count<<endl;
}



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

struct node {
	struct node* right;
	struct node* left;
	struct node* parent;
	int key;
};
typedef struct node* Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x) {
while(x->left !=NIL) x=x->left;
return x;
}

/*
Node treeMaximum(Node x) {
	while()

}

*/

Node treeSearch(Node u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;

}

Node treeSuccessor(Node x) {
	if (x->right != NIL) return treeMinimum(x->right);
	Node y = x->parent;
	while (y != NIL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}
void treeDelete(Node z) {
	Node y; // node to be deleted
	Node x; // child of y

	if (z->left == NIL || z->right == NIL)y = z;
	else y = treeSuccessor(z);

	if (y->left != NIL) x = y->left;
	else x = y->right;

	if (x != NIL)x->parent = y->parent;

	if (y->parent == NIL)root = x;
	else {
		if (y == y->parent->left) {
			y->parent->left = x;
		}
		else {
			y->parent->right = x;
		}
	}

	if (y != NIL)z->key = y->key;

	free(y);
}

void insert(int k) {
	Node y = NIL;
	Node x = root;
	Node z;

	z = (Node)malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;

	if (y == NIL) root = z;
	else if (z->key < y->key) y->left = z;
	else y->right = z;

}

void inorder(Node u) {
	if (u != NIL) {
		inorder(u->left);
		printf(" %d", u->key);
		inorder(u->right);
	}
}

void preorder(Node u) {
	if (u != NIL) {
		printf(" %d", u->key);
		preorder(u->left);
		preorder(u->right);
	}
}


int main() {
	int  i, x, n;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", com);
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i') {
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd') {
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}

	}

	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int N;
    cin >> N;

    vector<ll> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    map<pair<ll,ll>, int> diff;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i != j) {
                diff[make_pair(x[i] - x[j], y[i] - y[j])]++;
            }
        }
    }

    int maxval = 0;
    for (auto itr = diff.begin(); itr != diff.end(); itr++) {
        maxval = max(maxval, itr->second);
    }

    cout << N - maxval << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 384
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
print(answer)

Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {  
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int R = I.nextInt();
		int C = I.nextInt();
		char[][] grid = new char[R][C];
		boolean good=true;
		for (int i = 0; i < R; i++) {
			grid[i] = I.next().toCharArray();
		}
		for (int r = 0; r < R; r++) {
			for (int c = 0; c < C; c++) {
				//O.p(grid[r][c]);
				if (grid[r][c]=='#') {
					int cnt = 0;
					if (r>0&&grid[r-1][c]=='#') cnt++;
					if (r<R-1&&grid[r+1][c]=='#') cnt++;
					if (c>0&&grid[r][c-1]=='#') cnt++;
					if (c<C-1&&grid[r][c+1]=='#') cnt++;
					if (cnt==0) good=false;
				}
			}
			//O.p("\n");
		}
		O.pln(good?"Yes":"No");
	}
	public static long abs(long x, long y) {return Math.abs(x-y);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25740