akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
#include <queue>

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define MAX_NUM 2e5
typedef long long int ll;
using namespace std;

int main(void) {
	ll n=0,k=0, ans=0;
	cin >> n >> k;
	vector<ll> enemy(MAX_NUM+1);

	rep(i, n) cin >> enemy[i];
	sort(enemy.begin(), enemy.end());
	rep(i, k) enemy.pop_back();
	rep(i, enemy.size()) ans += enemy[i];
	cout << ans << endl;
	return 0;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#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 (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

    int A, B;
    cin >> A >> B;
    cout << (A * B) << endl;
    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
string n;
int main()
{
	cin>>n;
	bool C=false,F=false;
	for(int q=0;q<=n.size();q++)
	{
		if(n[q]=='C')C=true;
		if(n[q]=='F'&&C==true)
		{
			cout<<"Yes";
			return 0;
		}
		else continue;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define C char
#define D double
#define F float
#define LL long long
#define ULLI unsigned long long int
#define LLI long long int
#define LLD long long double
#define LD long double
#define S string
#define PI (2.0*acos(0.0))
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define READ 		freopen("input.txt","r",stdin)
#define WRITE  		freopen("output.txt","w",stdout)
using namespace std;

int main()
{
    S s;
    cin>>s;
    if(s=="SUN") cout<<"7\n";
    else if(s=="MON") cout<<"6\n";
    else if(s=="TUE") cout<<"5\n";
    else if(s=="WED") cout<<"4\n";
    else if(s=="THU") cout<<"3\n";
    else if(s=="FRI") cout<<"2\n";
    else if(s=="SAT") cout<<"1\n";
    return 0;
}


Measured memory_bytes: 256
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let readln () = read_line () |> split_on_char ' ' |> List.map int_of_string

let solve n q =
  let s = Array.init n (fun i -> i) in
  let rec find u =
    if u = s.(u) then u
    else begin
      s.(u) <- find s.(u);
      s.(u)
    end in
  for _ = 0 to q - 1 do
    match readln () with
    | n :: x :: y :: _ ->
      if n = 0 then s.(find x) <- find y
      else print_endline (if find x = find y then "1" else "0")
    | _ -> assert false
  done

let () =
  match readln () with
  | [n; q] -> solve n q
  | _ -> assert false

Measured memory_bytes: 4492
import sys
import fractions
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

A, B, C, D = MAP()
# Cで割り切れる数 = B/C - A/C
c_b = B//C
c_a = A//C if A%C else A//C-1
c = c_b-c_a

d_b = B//D
d_a = A//D if A%D else A//D-1
d = d_b-d_a

E = (C*D) // (fractions.gcd(C,D))
#print(E)
e_b = B//E
e_a = A//E if A%E else A//E-1
e = e_b - e_a

#print(c, d, e)

print((B-A+1)-(c+d-e))


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = SZ(s);
    ll ans = 0;
    rep(i, n){
        if(s[i] == 'g') ans++;
        if(s[i] == 'p') ans--;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};





int main(){
	int n; ll k;
	cin >> n >> k;
	vector<ll> a(n), f(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> f[i];
	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());

	auto ok = [&](ll x) {
		ll cost = 0;
		rep(i,n) {
			cost += max(0LL, a[i]-x/f[i]);
		}
		return cost <= k;
	};

	ll l = -1, r = INF;
	while(r-l>1) {
		ll mid = (r+l)/2;
		if(ok(mid)) r = mid;
		else l = mid;
	}

	cout << r << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int ans = 0;
  for(int i = 0;i < 4;i++){
    if(a[i] == '+'){
      ans++;
    }else{
      ans--;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef std::pair<ll, ll> PLL;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT

using namespace std;

signed main() {
  ll N;
  cin >> N;
  vector<PLL> v;
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    v.emplace_back(a-b, a+b);
  }
  sort(v.begin(), v.end(), [](const PLL &x, const PLL &y) {
      return x.second < y.second;
      });
  ll ans = 0, R = -1e18;
  for (auto b : v) {
    if (R <= b.first) {
      R = b.second;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	char hyou[8][8];
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			cin >> hyou[i][j];
		}
	}

	cout << "90" << endl;
	for (int i = 0; i < 8; i++) {
		for (int j = 7; j >= 0; j--) {
			cout << hyou[j][i];
		} 
		cout << endl;
	}

	cout << "180" << endl;
	for (int i = 7; i >= 0; i--) {
		for (int j = 7; j >= 0; j--) {
			cout << hyou[i][j];
		}
		cout << endl;
	}

	cout << "270" << endl;
	for (int i = 7; i >= 0; i--) {
		for (int j = 0; j < 8; j++) {
			cout << hyou[j][i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1136
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;

int main()
{
	int a, b, m;
	cin >> a >> b >> m;
	vector<int>A(a), B(b);
	for (int i = 0; i < a; i++)
		cin >> A[i];
	for (int i = 0; i < b; i++)
		cin >> B[i];
	int ans = *min_element(A.begin(), A.end()) + *min_element(B.begin(), B.end());
	for (int i = 0; i < m; i++) {
		int u, v, val;
		cin >> u >> v >> val;
		u--, v--;
		ans = min(A[u] + B[v] - val, ans);
	}
	cout << ans;
		
			
}

Measured memory_bytes: 1152
// AOJ 2447 A Two Floors Dungeon
// 2018.2.2 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define QMAX 100000
typedef struct { short s; char f, r, c; } Q;
Q q[QMAX+2]; int top, end;

int W, H, S;
char map[53][53];
char sw[11][53][53];
int mov[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
int memo[1024][2][53][53];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int check(int s, int f, int r, int c)
{
	int i, g;

    if (map[r][c] == '|') return 1;
    g = map[r][c] == '^' || isupper(map[r][c]);
    for (i = 0; i < S; ++i) if ((s >> i) & 1) g ^= sw[i][r][c];
    return f == g;
}

void enq(int ns, int nf, int nr, int nc, int s, int f, int r, int c)
{
	if (memo[ns][nf][nr][nc] >= 0) return;
	memo[ns][nf][nr][nc] = memo[s][f][r][c] + 1;
	q[end].s = ns, q[end].f = nf, q[end].r = nr, q[end].c = nc;
	if (++end == QMAX) end = 0;
}

int calc(int sr, int sc)
{
	int k, s, f, r, c, nr, nc;

	memset(memo, -1, sizeof memo);
	q[0].s = q[0].f = 0, q[0].r = sr, q[0].c = sc, top = 0, end = 1;
	memo[0][0][sr][sc] = 0;
    while (top != end) {
		s = q[top].s, f = q[top].f, r = q[top].r, c = q[top].c;
		if (++top == QMAX) top = 0;
		if (map[r][c] == '&') return memo[s][f][r][c];
		if (map[r][c] == '|') enq(s, f ^ 1, r, c, s, f, r, c);
		if (isalpha(map[r][c])) {
			k = tolower(map[r][c]) - 'a';
			enq(s ^ (1 << k), f ^ sw[k][r][c], r, c, s, f, r, c);
        }
        for (k = 0; k < 4; k++) {
            nr = r + mov[k][0], nc = c + mov[k][1];
			if (map[nr][nc] == '#') continue;
			if (!check(s, f, nr, nc)) continue;
			enq(s, f, nr, nc, s, f, r, c);
		}
	}
	return -1;
}

int main()
{
	int i, r, c, sr, sc; 
	char buf[53];

	W = in(), H = in();
	sr = -1;
	for (r = 0; r < H; r++) {
		fgets(map[r], 53, stdin);
		if (sr >= 0) continue;
		for (c = 0; c < W; c++) {
			if (map[r][c] == '%') sr = r, sc = c;
        }
	}

	S = in();
	for (i = 0; i < S; i++) {
		for (r = 0; r < H; r++) {
			fgets(buf, 53, stdin);
			for (c = 0; c < W; c++) {
				if (buf[c] == '*') sw[i][r][c] = 1;
			}
		}
	}
	printf("%d\n", calc(sr, sc));
    return 0;
}


Measured memory_bytes: 24828
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).length())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_value(aint(a))
#define maxin(a) *max_value(aint(a))
#define X first
#define Y second
#define fiint(a, x) memset(a, x, lengthof(a))
#define pb push_back
#define pf push_front
#define mp make_pair
#define aint(v) v.begin(), v.end()
#define raint(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(aint(v), (int)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
const int M = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
    start();
    string s;
    cin>>s;
    int sm=0;
    for(int i=0;i<s.size();i++){
        sm+=(s[i]-'0');
    }
    if(sm%9==0)cout<<"Yes"<<el;
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	
	cout << (s=="ABC"?"ARC":"ABC") << endl;

}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
    int ap,a,b,c,p=0,count=0;
    cin >> a >> b >> c;
    for(int i=0;i<b+1-a;i++){
    ap=a+p;
        if(c%ap==0){
            count++;
        }
        p++;

    }
    cout << count << endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#include<climits>
#define INF (1<<29)
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

#define MAX_SIZE 400000

long long segMax[MAX_SIZE - 1], segAdd[MAX_SIZE - 1];


int n;

//区間[a, b)に値xを加算する.
void add(int a, int b, long long x, int k = 0, int l = 0, int r = n)
{
	if (r <= a || b <= l) return;
	
	if (a <= l && r <= b){
		segAdd[k] += x;
		while (k){
			k = (k - 1) / 2;
			segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
		}
		return;
	}
	
	add(a, b, x, k * 2 + 1, l, (l + r) / 2);
	add(a, b, x, k * 2 + 2, (l + r) / 2, r);
}

long long getMax(int a, int b, int k = 0, int l = 0, int r = n)
{
	if (r <= a || b <= l) return (LLONG_MIN);
	
	if (a <= l && r <= b) return (segMax[k] + segAdd[k]);
	
	long long left = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
	long long right = getMax(a, b, k * 2 + 2, (l + r) / 2, r);
	
	return (max(left, right) + segAdd[k]);
	
}


int a[100000];
void init(){
	memset(segMax,0,sizeof(segMax));
	memset(segAdd,0,sizeof(segAdd));
	rep(i,n)add(i,i+1,a[i]);
}


long long m;
int c;

long long calc(int r){
	long long s=0;
	for(int i=1;i<n;i++){
		add(i,min(i+r+1,n),-c);
	}
	//cout<<'r'<<r<<endl;
	rep(i,n){
		//rep(i,n)cout<<getMax(i,i+1)<<' ';cout<<endl;
		s+=getMax(max(0,i-r),min(n,i+r+1));
		add(0,i+1,-c);
		add(i+1,min(n,i+r+2),c);
	}
	return s;
}


int main(){
	cin>>n>>m>>c;
	rep(i,n)cin>>a[i];
	int l=-1,r=n;
	while(r-l>1){
		int mid=(l+r)/2;
		init();
		if(calc(mid)<m)l=mid;
		else r=mid;
	}
	if(r==n)r=-1;
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 7820
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MAX=1000001;

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

    int ans=(a+b+c)+max({a,b,c})*((1<<k)-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;

int power_int(int a, int b) {
  int x = 1;
  while (b > 0) {
    x *= a;
    b--;
  }
  return x;
}

int main() {
  int n;
  cin >> n;
  long x[1010], y[1010], u[1010], v[1010];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  int parity = (x[0] + y[0]) % 2;

  bool check = true;
  for (int i = 0; i < n; i++) {
    if ((x[i] + y[i] - parity) % 2 != 0) check = false;
  }

  if (check) {
    if (parity == 0) {
      cout << 32 << endl;
      for (int i = 30; i > -1; i--) {
        cout << power_int(2, i) << " ";
      }
      cout << 1 << endl;
      for (int i = 0; i < n; i++) {
        x[i]++;
      }
    }
    else {
      cout << 31 << endl;
      for (int i = 30; i > -1; i--) {
        cout << power_int(2, i) << " ";
      }
      cout << endl;
    }

    for (int i = 0; i < n; i++) {
      u[i] = x[i] + y[i];
      v[i] = x[i] - y[i];
    }

    for (int i = 0; i < n; i++) {
      for (int j = 30; j > -1; j--) {
        if (u[i] > 0 && v[i] > 0) {
          cout << 'R';
          u[i] -= power_int(2, j);
          v[i] -= power_int(2, j);
        }
        else if (u[i] > 0 && v[i] < 0) {
          cout << 'U';
          u[i] -= power_int(2, j);
          v[i] += power_int(2, j);
        }
        else if (u[i] < 0 && v[i] > 0) {
          cout << 'D';
          u[i] += power_int(2, j);
          v[i] -= power_int(2, j);
        }
        else {
          cout << 'L';
          u[i] += power_int(2, j);
          v[i] += power_int(2, j);
        }
      }
      if (parity == 0) cout << 'L';
      cout << endl;
    }
  }

  else {
    cout << "-1" << endl;
  }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll ans = 0;
	int mi = 1;
	int n;cin >> n;

	REP(i, n){
		int a;cin >> a;
		if(i == 0){
			ans += a - 1;
			continue;
		}

		if(a == mi + 1){
			mi++;
			continue;
		}

		ans += (a - 1) / (mi + 1);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int x;
    cin >> x;
    ll ans = 0;
    ans += 1000*(x/500);
    x %= 500;
    ans += 5*(x/5);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,cnt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i)
		if (i%2==1) ++cnt;
	cout<<fixed<<setprecision(8)<<(double)cnt/(double)n;
	return 0;
}

Measured memory_bytes: 256
import sys


def calc_gcd(x, y):
    """ ?????§??¬?´???°????¨?????????? """
    if y == 0:
        return x
    else:
        return int(calc_gcd(y, x % y))


def calc_lcm(x, y):
    """ ????°???¬?????°????¨?????????? """
    return int((x * y) / calc_gcd(x, y))


if __name__ == '__main__':
    # ??????????????\?????¨???????????????
    for line in sys.stdin:
        x, y = map(int, line.split(' '))
        print('{0} {1}'.format(calc_gcd(x, y), calc_lcm(x, y)))

Measured memory_bytes: 7552
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
int INPUT_INT() { int d; cin >> d; return d; } // 入力をpush_back(d)やarray[d]に使う時に無駄な変数を使わない

// ------------------- include, typedef, define END. -------------------

int main(){
	int a = 0, b = 0;
	FOR(i, 0, 7){
		cin >> a >> b;
		cout << abs(a - b) << endl;
	}
	return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string s;
    cin >> s;

    string ans = "";
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(s[i] == 'B'){
            if(!ans.empty()){
                int l = ans.size();
                ans.erase(l-1);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3576
s=input()
a=int(s[:2])
b=int(s[2:])

if 0<a<13 and 0<b<13:
    print('AMBIGUOUS')
elif 0<a<13 :
    print('MMYY')
elif 0<b<13:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#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){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

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

  z = 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 n, i, x;
   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");
      }*/  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: 24040
#include <bits/stdc++.h>

using namespace std;

const int N = 2020, inF = N * N;

int n, cnt[N], sigma[N], mini[N];
string s;
vector<int> nei[N];

void input() {
	cin >> n >> s;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		nei[--u].push_back(--v);
		nei[v].push_back(u);
	}
}

void dfs(int v, int par) {
	cnt[v] = s[v] - '0';
	sigma[v] = 0;
	int s = 0;
	for (int u: nei[v])
		if (u ^ par) {
			dfs(u, v);
			cnt[v] += cnt[u];
			sigma[v] += sigma[u] + cnt[u];
		}
	mini[v] = sigma[v] & 1;
	for (int u: nei[v])
		if (u ^ par)
			mini[v] = max(mini[v], (mini[u] + cnt[u]) - (sigma[v] - (sigma[u] + cnt[u])));
	//cerr << v + 1 << " : " << cnt[v] 
}

int solve(int v) {
	dfs(v, -1);
	return (mini[v]? inF: sigma[v] >> 1);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	input();
	//solve(1);return 0;
	int ans = inF;
	for (int v = 0; v < n; v++)
		ans = min(ans, solve(v));
	cout << (ans == inF? -1: ans);
}


Measured memory_bytes: 512
def read():
	return [int(i) for i in input().split(" ")]
N, x = read()
A = read()
ans = sum(A)
tempcost = ans
BC = A[:]
for i in range(1, N):
	BC = [BC[j - 1] if BC[j - 1] < BC[j] else BC[j] for j in range(N)] 
	tempcost = x * i + sum(BC)
	if(ans > tempcost):
		ans = tempcost
print(ans)


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n; cin >> n;
  map<ll, ll> flag;
  vll a(n);
  rep(i, n)
  {
    cin >> a[i];
    if(a[i] % 4 == 0)
    {
      if(flag.count(4)) flag[4]++;
      else flag[4] = 1;
    }
    else if(a[i] % 2 == 0)
    {
      if(!flag.count(2)) flag[2] = 1;
    }
    else
    {
      if(flag.count(1)) flag[1]++;
      else flag[1] = 1;
    }
  }
  if(flag.count(2)) flag[1]++;
  if(flag[1] <= flag[4] + 1)
  fin("Yes")
  else
  {
    fin("No")
  }
  return;
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 1024
from operator import itemgetter
N, K = map(int, input().split())
ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append((a,b))
ab.sort(key=itemgetter(0))

R = [0]*(N+1)
for i in range(1,N+1):
    R[i] += R[i-1] + ab[i-1][1]

for i in range(1,N+1):
    if R[i-1]<K<=R[i]:
        print(ab[i-1][0])

Measured memory_bytes: 21208
/* basic header */
#include <bits/stdc++.h>
/* define */
#define ll long long
#define dou double
#define pb emplace_back
#define mp make_pair
#define sot(a,b) sort(a+1,a+1+b)
#define rep1(i,a,b) for(int i=a;i<=b;++i)
#define rep0(i,a,b) for(int i=a;i<b;++i)
#define eps 1e-8
#define int_inf 0x3f3f3f3f
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lson (curpos<<1)
#define rson (curpos<<1|1)
/* namespace */
using namespace std;
/* header end */

const int maxn=1e5+10;
char s[maxn],t[maxn];

int main() {
	scanf("%s",s+1);
	scanf("%s",t+1);
	int ans=0;
	for (int i=1;i<=3;i++)
		ans+=s[i]==t[i];
	printf("%d\n",ans);
    return 0;
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

#define MAX_N 100100

ll N;
ll A[MAX_N];
ll d[MAX_N];

int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    
    ll suma = 0;
    REP(i, N) {cin >> A[i];suma+=A[i];}
    ll K = suma / ( N * (N+1) / 2 );
    if (suma % ( N * (N+1) / 2 ) != 0) {
        cout << "NO" << endl;
        return 0;
    }
    REP(i, N) d[i] = A[(i+1)%N] - A[i%N];
    ll sumd = 0;
    REP(i, N) {
        if (d[i] > K || (K - d[i]) % N != 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    return 0;
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,cnt=0;
  string s,t;
  cin>>s>>t;
  for(i=0;i<3;i++)cnt+=(s.at(i)==t.at(i)?1:0);
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<ctime>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 1000000
#define INF 0x3f3f3f3f
char S[MAXN+5];
bool check(int x,int y){
	for(int i=x+1;i<y-1;i++)
		if(S[i]=='#'&&S[i+1]=='#')
			return 0;
	return 1;
}
int main(){
	//freopen("jump.in","r",stdin);
	//freopen("jump.out","w",stdout);
	int n=read(),a=read(),b=read(),c=read(),d=read();
	scanf("%s",S+1);
	if(S[a]=='#'||S[b]=='#'||S[c]=='#'||S[d]=='#'){
		puts("No");
		return 0;
	}
	if(c<b){
		if(!check(a,c)||!check(b,d))
			puts("No");
		else puts("Yes");
	}
	else if(b<c&&c<d){
		if(!check(a,c)||!check(b,d))
			puts("No");
		else puts("Yes");
	}
	else{
		if(!check(a,c)||!check(b,d))
			puts("No");
		else{
			for(int i=b;i<=d;i++)
				if(S[i-1]=='.'&&S[i]=='.'&&S[i+1]=='.'){
					puts("Yes");
					return 0;
				}
			puts("No");
		}
	}
    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      rrep(i,1,n+1){
        pos=i;
        cnt=0;
        if(i%2==0)continue;
        rrep(j,1,i+1){
          if(pos%j==0)cnt++;
        }
        if(cnt==8)ans++;
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;


int main(){
	ll a,b,c,d,k; cin >> a >> b >> c >> d >> k;
	ll x = c*60+d - a*60 - b;
	cout << max(0LL,x-k) << endl;
}

Measured memory_bytes: 3636
def main():
    a = []
    b = []
    for i in range(3):
        buf = input()
        buflist = buf.split()
        a.append(int(buflist[0]))
        b.append(int(buflist[1]))
    count = [0, 0, 0, 0]
    for i in a:
        count[i-1] += 1
    for i in b:
        count[i-1] += 1
    for i in count:
        if i >= 3:
            print("NO")
            return
    print("YES")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
int a,b,c,x,n,m,p,turn,maxim,minim,v[2001];
int main (void) {
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i ++) {
        cin >> v[i];
    }
    if (n > 1)
    cout << max(abs(v[n]-b),abs(v[n-1]-v[n]));
    else
    cout << abs(v[n]-b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[5];
int main(){
	scanf("%s",a+1);
	if(a[1]==a[2]&&a[1]==a[3]&&a[1]==a[4])puts("No");
	else if(a[1]==a[2]&&a[3]==a[4])puts("Yes");
	else if(a[1]==a[3]&&a[2]==a[4])puts("Yes");
	else if(a[1]==a[4]&&a[2]==a[3])puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>
int main ()
{
	int n,br=0,r=0;
	scanf("%i",&n);
	char s[n+1];
	scanf("%s",&s);
	for(int j=0;j<10;j++)
	{
		for(int k=0;k<10;k++)
		{
			for(int l=0;l<10;l++)
			{
				br=0;
				for(int i=0;i<=n;i++)
				{
					if(s[i]-'0'==j && br==0)
					{
						br=1;
					}
					else if(br==1 && s[i]-'0'==k)
					{
						br=2;
					}
					else if(br==2 && s[i]-'0'==l)
					{
						br=3;
					}
				}
				if(br==3)	r++;
			}
		}
	}
	printf("%i",r);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define REP(i,n) for(i=0;i<n;i++)

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    int a = iin(), b = iin(), c = iin();
    int count = 0;
    for (; a <= b; a++) {
        if (c % a == 0) count++;
    }
    iout(count);
    return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> p(m);
	rep(i,m){
		cin >> p[i].first >> p[i].second;
	}

	vector<pair<int, int>> s(all(p));
	sort(all(s));


	rep(i,m){
		printf("%06d%06d\n", p[i].first, 1 + static_cast<int>(
					distance(lower_bound(all(s), make_pair(p[i].first, -1)),
							 lower_bound(all(s), p[i]))));
	}
}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	final static int A500 = 500;
	final static int B100 = 100;
	final static int C50 = 50;

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.nextLine());
		int b = Integer.parseInt(sc.nextLine());
		int c = Integer.parseInt(sc.nextLine());
		int x = Integer.parseInt(sc.nextLine());

		int count = 0;

		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					if (x == A500 * i + B100 * j + C50 * k) {
						count++;
					}
				}
			}

		}

		System.out.println(count);

	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long x,n;
	cin>>x>>n;
	if (x*500>=n)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
//素数判定
bool prime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
signed main() {
	ll n;
	cin >> n;
	if (n == 10 || n == 100 || n == 1000 | n == 10000 || n == 100000)cout << 10 << endl;
	else {
		ll i = 1, ans = 0;
		while (i <= n) {
			ans += n % (i * 10) / i;
			i *= 10;
		}
		cout << ans << endl;
	}
	ggr
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define ll long long
int main(){
    int n,w;
    cin>>n>>w;
    ll a[2][n],dp[n*1000+1];
    for(int i=0;i<n;i++)cin>>a[0][i]>>a[1][i];
    for(int i=0;i<=n*1000;i++) dp[i]=INT_MAX;
    ll mx=0;
    for(int i=0;i<n;i++)
    {  
        for(ll j=n*1000;j>=1;j--){
            if(j>a[1][i] && dp[j-a[1][i]]!=INT_MAX ){ dp[j]=min(dp[j],dp[j-a[1][i]]+a[0][i]); }
            else if(j==a[1][i] ) dp[j]=min(dp[j],a[0][i]); 
                if( dp[j]!=INT_MAX && dp[j]<=w)  mx=max(j,mx);
            
        }
    }
    cout<<mx<<endl;
    return 0;
}

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

// (: +1, ): -1
// カッコ列は折れ線にする
// 正しいカッコ列の条件: (1) 合計が0 (2) 途中で0未満にならない
// 基準点から「最下点は相対的にいくつ上か」と「最終点はいくつ上か」

bool check(vector<P> s)
{
    int h = 0;
    for (P p : s)
    {
        int b = h + p.first;
        if (b < 0)
            return false;
        h += p.second;
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    vector<P> ls, rs;
    int total = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        int h = 0, b = 0;
        for (char c : s)
        {
            if (c == '(')
                ++h;
            else
                --h;
            b = min(b, h);
        }
        if (h > 0)
            ls.emplace_back(b, h);
        else
            rs.emplace_back(b - h, -h);
        total += h;
    }

    // 最終点が大きい順ではなくて，最下点が大きい順：最下点が大きい順が一番余裕がある並べ方になるはずで，それでもだめなら絶対にできない
    sort(ls.rbegin(), ls.rend()); // 各パーツを最下点について降順にソート
    sort(rs.rbegin(), rs.rend());
    if (check(ls) && check(rs) && total == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

typedef long long int ll;

ll absl(ll n)
{
	if(n<0)
	{
		return -1*n;
	}
	return n;
}
int main()
{
	ll n,i,j,f,s,k;
	cin>>n>>k;
	vector<ll > dp(n),a(n);
	cin>>a[0];
	cin>>a[1];
	ll mini=absl(f-s);
	
	dp[0]=0;
	dp[1]=absl(a[0]-a[1]);
	for(i=2;i<n;i++)
	{
		cin>>a[i];
		dp[i]=dp[i-1]+absl(a[i]-a[i-1]);
		for(j=i-2;j>=i-k&&j>=0;j--)
		{
			dp[i]=min(absl(a[i]-a[j])+dp[j],dp[i]);
			
		}
	
	}
	cout<<dp[n-1]<<'\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    int ret = 1;
    FOR(i, 1, N + 1) {
        ret = (int)(ret * 1LL * i % 1000000007);
    }

    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 256
import itertools
import collections

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n = getint()
a = getints()

def cnt(n):
    if n % 2 == 0:
        return 1 + cnt(n//2)
    return 0

res = 0
for d in a:
    res += cnt(d)

print(res)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  ll x;
  cin >> x;
  ll res = x/11ll*2;
  x%11 ? x%11 <= 6 ? res++ : res += 2 : res;
  cout << res << endl;



  return 0;
}

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

int main() {
    int X, N;
    cin >> X >> N;
    int p[102] = {0};

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

    int result = 0;
    int i = 0;
    while(true){
        if(p[X - i] == 0){
            result = X - i;
            break;
        }
        if(p[X + i] == 0){
            result = X + i;
            break;
        }
        i++;
    }
    cout << result <<"\n";
    return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    void input(){

    }
    void solve(){
        input();
        string s;
        cin >> s;
        int cnt = 0;
        for(auto c : s) if(c == '2') cnt++;
        cout << cnt << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void solve() {
	int N;
	cin >> N;
	vl a(N), dp(N, INT_MAX);
	rep(i, N) cin >> a[i];
	if (N == 1) {cout<< 0<<endl; return;}
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	FOR(i, 2, N - 1) dp[i] = min(dp[i-1]+abs(a[i] - a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
	cout << dp[N-1] << endl;
}

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


Measured memory_bytes: 1792
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    if (s[s.size() - 1] == 's') s += 'e';
    s += 's';

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int D, G;
  cin >> D >> G;
  vector<int> P(D), C(D);
  rep(i, D) cin >> P[i] >> C[i];
  int ans = 1e9;
  for(int bit = 0; bit < (1 << D); ++bit){
    int s = 0, cnt = 0, remain_max = -1;
    for(int i = 0; i < D; ++i){
      if(bit >> i & 1){
        s += 100 * (i + 1) * P[i] + C[i];
        cnt += P[i];
      }else{
        remain_max = i;
      }
    }
    if (s < G){
      int s1 = 100 * (remain_max + 1);
      int need = (G - s + s1 - 1) / s1;
      if (need >= P[remain_max]) continue;
      cnt += need;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600