akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {

    int n;
    cin >> n;
    vector<long int> l(n+1);
    l.at(0) = 2;
    if(n >=  1){
        l.at(1) = 1;
        }
    for(int i = 2; i <= n; ++i){
        l.at(i) = l.at(i-1) + l.at(i-2);
    }

    cout << l.at(n) << endl;

}

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

int main() {
    int N;
    cin >> N;
    int ans;
    if (N%2==0) {
        ans = N/2;
    }
    else{
        ans = N/2 +1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
using namespace std;
stack<long long> ans;
int arr[100001][2];
int par[100001];
long long cnt[100001];
int find(int x){
	if(par[x]==-1) return x;
	else return par[x]=find(par[x]); 
}
long long uni(int a, int b){
	a=find(a);
	b=find(b);
	if(a==b) return 0;
	long long ret=cnt[b]*cnt[a];
	cnt[b]+=cnt[a];
	par[a]=b;
	return ret;
}
int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	long long ret=N*(N-1)/2;
	for(int i=0;i<M;i++){
		scanf("%d %d",&arr[i][0],&arr[i][1]);
		cnt[arr[i][0]]++;
		cnt[arr[i][1]]++;
	}
	for(int i=1;i<=N;i++){
		par[i]=-1;
		cnt[i]=1;
	}
	for(int i=M-1;i>=0;i--){
		ans.push(ret);
		ret-=uni(arr[i][0],arr[i][1]);
	}
	while(!ans.empty()){
		printf("%lld\n",ans.top()-ret);
		ans.pop();
	}
}

Measured memory_bytes: 3868
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            string s = Console.ReadLine();
            int[] reversi = new int[s.Length];
            for(int i=0;i<s.Length;++i)
            {
                reversi[i] = s[i] == 'B' ? 0 : 1;
            }

            int ans = 0;
            int color = reversi[0];
            for(int i=1;i<reversi.Length;++i)
            {
                if(reversi[i] != color)
                {
                    // 反転
                    color = (color + 1) % 2;
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13108
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int a,b,c,d,e,f;
  cin >>a>>b>>c>>d>>e>>f;
  double t = (double)100*e/(100+e);
  double m = 0.0;
  //cout << t << endl;
  ll x = 100*a,y = 0;
  for(int i = 0;i <= 30;i++){
    for(int j = 0;j <= 30;j++){
      if(100*a*i+100*b*j > f)
	break;
      for(int k = 0;k <= 3000;k++){
	if((100*a*i+100*b*j+c*k) > f)
	  break;
	for(int l = 0;l <= 3000;l++){
	  if((100*a*i+100*b*j+c*k+d*l) > f)
	    break;
	  double r = (double)(c*k+d*l)*100/(100*a*i+100*b*j+c*k+d*l);
	  //if(k == 33 && l == 8)
	    //cout << r << endl;
	  if(t >= r){
	    if(m < r){
	      m = r;
	      x = 100*a*i+100*b*j+c*k+d*l;
	      //if(x == 149)
	      //cout << i << " " << j << " " << k << "  " << l << endl;
	      y = c*k+d*l;
	    }
	  }
	}
      }
    }
  }
  cout << x << " "  <<y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N, W;
    cin >> N >> W;

    vec<int> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    int MAX_VALUE = N * 1000 + 1;
    vec<vec<int>> dp(N + 1, vec<int>(MAX_VALUE+1000,1e9+10));
    for (int i = 1; i <= N; ++i) {
        for(int j=MAX_VALUE;j>0;--j) {
            dp[i][j] = min({dp[i][j],dp[i][j+1], dp[i-1][j]});
            if(j<=v[i-1]) dp[i][j] = min(dp[i][j],w[i-1]);
            if(j>=v[i-1]) dp[i][j] = min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
        }
    }

    ll ans = 0;
    rep(i,MAX_VALUE){
        if(dp[N][i] <= W) ans=max(ans,i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 43656
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
    map< string, int > m;

    m.insert(make_pair("AC", 0));
    m.insert(make_pair("WA", 0));
    m.insert(make_pair("TLE", 0));
    m.insert(make_pair("RE", 0));

    int N;

    cin >> N;

    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;

        m[S]++;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;

    return 0;
}

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

constexpr int inf = 1e9;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }

    int ans = inf;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            int tans = 0;
            for(int k = 0; k < h; ++k) {
                for(int l = 0; l < w; ++l) {
                    tans += min(abs(i - k), abs(j - l)) * a[k][l];
                }
            }
            ans = min(ans, tans);
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3164
from itertools import combinations_with_replacement
 
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]
 
ans = 0
for pat in combinations_with_replacement(range(1, m + 1), n):
    score = 0
    for a, b, c, d in abcd:
        a -= 1
        b -= 1
        if pat[b] - pat[a] == c:
            score += d
 
    ans = max(ans, score)
 
print(ans)

Measured memory_bytes: 9132
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    if (std::abs(a - c) <= d || std::abs(a - b) <= d && std::abs(b - c) <= d) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 3rd Year
  MNNIT
  THUMB RULE - THINK FOR DP FIRST AND THEN GREEDY!!!
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define sz(x)	(ll)x.size()
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#define endl '\n'
//unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
//shuffle (foo.begin(), foo.end(), std::default_random_engine(seed));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above-----------------------------------------------

int main()
{
	boost
	ll d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <string.h>

int visited[30][30];
char map[30][30];
int dr[]={-1, 0, 1, 0}, dc[]={0, -1, 0, 1};
int h, w, res;

void dfs(int r, int c)
{
    int i;
    if (visited[r][c]) return;
    map[r][c]='X';
    visited[r][c]=1;
    ++res;
    for(i=0;i<4;++i) {
        int nr=r+dr[i], nc=c+dc[i];
        if (nr<0 || nr>=h || nc<0 || nc>=w || visited[nr][nc] || map[nr][nc]!='.') continue;
        dfs(nr, nc);
    }
}

int main()
{
    while (1) {
        int i, j, sr, sc;
        scanf("%d%d", &w, &h);
        if (w==0) break;

        memset(map, 0, sizeof(map));
        memset(visited, 0, sizeof(visited));
        for(i=0;i<h;++i) {
            scanf("%s", map[i]);
            for(j=0;j<w;++j) if (map[i][j]=='@') { sr=i, sc=j; }
        }

        res=0;
        dfs(sr, sc);
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a*b%2==0) cout<<"No"<<'\n';
  else cout<<"Yes"<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>t(n);
    vector<long long>a(n+1,0);
    for(int i=0; i<n; i++){
        cin >> t[i];
        a[t[i]]++;
    }
    long long sum=0;
    for(int i=1; i<n+1; i++){
        if(a[i]>0) sum += a[i] * (a[i]-1) / 2;
    }
    for(int i=0; i<n; i++){
        cout << sum - a[t[i]] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5536
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
const int MAXN = 1005;
const double eps = 1e-12;


int xs, ys, xt, yt, n;
struct node
{
	int x, y, z;
}p[MAXN];
double f[MAXN][MAXN], dis[MAXN];

double dist(int x, int y, int u, int v)
{
	return sqrt(1.0 * (1ll * (x-u) * (x-u) + 1ll * (y-v) * (y-v)));
}

double calc(int i, int j)
{
	double d = dist(p[i].x, p[i].y, p[j].x, p[j].y);
	if(p[i].z + p[j].z - d < eps) return d - p[i].z - p[j].z;
	return 0;
}

bool vis[MAXN];

int main ()
{
	scanf("%d%d%d%d", &xs, &ys, &xt, &yt);
	scanf("%d", &n); n++;
	for(int i = 1; i < n; i++)
		scanf("%d%d%d", &p[i].x, &p[i].y, &p[i].z);
	p[0].x = xs, p[0].y = ys, p[0].z = 0;
	p[n].x = xt, p[n].y = yt, p[n].z = 0;
	for(int i = 0; i <= n; i++)
		for(int j = i; j <= n; j++)
			f[i][j] = f[j][i] = calc(i, j);
	memset(dis, 127, sizeof dis); dis[0] = 0;
	for(int i = 1; i <= n; i++)
	{
		int k = -1;
		for(int j = 0; j <= n; j++)
			if(!vis[j] && (k == -1 || dis[j] - dis[k] < eps))
				k = j;
		if(k < 0) break;
		vis[k] = 1;
		for(int j = 0; j <= n; j++)
			if(!vis[j] && dis[k] + f[k][j] - dis[j] < eps)
				dis[j] = dis[k] + f[k][j];
	}
	printf("%.10lf\n", dis[n]);
}

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

int main(){
    int S;
    cin >> S;
    int h, m, s;
    h = S / 3600;
    m = (S - h*3600) / 60;
    s = (S - h*3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
using namespace std;

#define equals(a, b) (fabs((a)-(b)) < EPS)
const double EPS = (1e-10);

class Point {
public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (double a) {
        return Point(x*a, y*a);
    }
    Point operator / (double a) {
        return Point(x/a, y/a);
    }

    double abs() {
        return sqrt(norm());
    }
    double norm() {
        return x*x + y*y;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;
// 内積
double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}
// 外積
double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

class Segment {
public:
    Point p1, p2;

    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};
typedef Segment Line;

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    Vector hypo = p - s.p1;
    double r = dot(hypo, base) / base.norm();
    return s.p1 + base*r;
}

class Circle {
public:
    Point c;                    // 中心
    double r;                   // 半径
    Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

double arg(Vector p) {
    return atan2(p.y, p.x);
}
Vector polar(double a, double r) {
    return Point(cos(r)*a, sin(r)*a);
}

pair<Point, Point> getCrossPoints(Circle c1, Circle c2) {
    double d = (c2.c - c1.c).abs();
    double a = acos( (c1.r*c1.r + d*d - c2.r*c2.r)/(2*c1.r*d) );
    double t = arg(c2.c - c1.c);
    return make_pair(c1.c + polar(c1.r, t+a), c1.c + polar(c1.r, t-a));
}

int main(void) {
    double c1x, c1y, c1r, c2x, c2y, c2r;
    cin >> c1x >> c1y >> c1r
        >> c2x >> c2y >> c2r;

    Circle c1(Point(c1x, c1y), c1r), c2(Point(c2x, c2y), c2r);
    pair<Point, Point> ans = getCrossPoints(c1, c2);

    if (ans.first < ans.second) {
        printf("%.9f %.9f %.9f %.9f\n",
               ans.first.x, ans.first.y, ans.second.x, ans.second.y);
    } else {
        printf("%.9f %.9f %.9f %.9f\n",
               ans.second.x, ans.second.y, ans.first.x, ans.first.y);
    }

    return 0;
}

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

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

typedef unsigned long long ull;
typedef long long ll;

#define F first
#define S second
#define all(x) begin(x), end(x)

using namespace std;

void exec()
{
	int n;
	cin >> n;

	vector<double> dp(n + 1);
	dp[0] = 1;

	double ans = 0;
	for (int i = 1; i <= n; ++i) {
		double head;
		cin >> head;

		for (int j = i; j > 0; --j) {
			dp[j] = dp[j] * (1 - head) + dp[j - 1] * head;
		}
	}

	/*for (double i : dp)
		cout << i << endl;*/

	int heads = n, tails = 0;
	for (int i = n; i >= 0; --i) {
		if (heads < tails) break;
		ans = dp[i];
		--heads, ++tails;
	}

	cout << fixed << setprecision(12) << ans << endl;
}

















int main()
{
	exec();

	return 0;
}

Measured memory_bytes: 256
/*input
7
14 14 2 13 56 2 37
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=5e3+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
    int n;
    cin>>n;
    REP(i,n) cin>>arr[i];
    ll ans=INF64;
    REP(i,101){
        ll cs=0;
        REP(j,n){
            cs+=(arr[j]-i)*(arr[j]-i);
        }
        MNTO(ans,cs);
    }
    cout<<ans;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

vector<int64_t> fact, fact_inv;

void create_mod_tables(int num){
    fact.assign(num+1, 1);
    fact_inv.assign(num+1, 1);
    for(int i=1; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[num] = inv_mod(fact[num]);
    for(int i=num; i>0; i--) fact_inv[i-1] = fact_inv[i] * i % MOD;
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

// P = {P[0], P[1], ..., P[N]}
int64_t LagrangeInterpolation(vector<int64_t> P, int64_t T){
    int N = P.size()-1;
    if(T <= N) return P[T];
    int64_t Qi = 1, QTA = 1;
    for(int i=0; i<=N; i++){
        if(i) mul(Qi, MOD-i);
        mul(QTA, T-i);
    }
    int64_t ans = 0;
    for(int i=0; i<=N; i++){
        add(ans, P[i] * inv_mod(Qi) % MOD * QTA % MOD * inv_mod(T-i));
        mul(Qi, (i+1) * inv_mod(MOD-N+i) % MOD);
    }
    return ans;
}

int64_t calc(int N){
    int64_t ans = 0;
    for(int i=0; 2*i+5<=N; i++) add(ans, comb_mod(i+4, 4) * comb_mod(N-2*i+5, 10));
    return ans;
}

void solve(){
    int N;
    cin >> N;
    if(N < 5){
        cout << 0 << endl;
        return;
    }
    int r = (N-5)%2, n = (N-5)/2;
    vector<int64_t> V(16);
    for(int i=0; i<=15; i++) V[i] = calc(2*i+5+r);
    int64_t ans = LagrangeInterpolation(V, n);
    cout << ans << endl;
}

int main(){
    create_mod_tables(100);
    int T;
    cin >> T;
    while(T--) solve();
    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

int a,b,c,d,e,f;
int mw=1,ms=1;

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

	cin>>a>>b>>c>>d>>e>>f;
	REP(i,f/(a*100)+1) {
		int A=i*100*a;
		if(A>f) break;
		REP(j,f/(b*100)+1) {
			int B=j*100*b;
			if(A+B>f) break;
			REP(k,f/c+1) {
				int C=k*c;
				if(A+B+C>f) break;
				REP(l,f/d+1) {
					int D=l*d;
					if(A+B+C+D>f) break;
					if((C+D)>(A+B)/100*e) break;
					if((A+B+C+D)*ms<=(C+D)*(ms+mw)) ms=C+D,mw=A+B;
				}
			}
		}
	}
	cout<<mw+ms<<' '<<ms<<endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

ll N;

vector<vector<ll>> g;

ll dfs(ll u, ll v) {
	ll ret = 0;

	for (ll w : g[v]) {
		if (u == w) { continue; }
		ret ^= dfs(v, w) + 1;
	}

	return ret;
}


int main() {

	cin >> N;
	g.resize(N + 1);

	repn(i, N - 1) {
		ll x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	ll b = dfs(0, 1);

	if (b == 0) { cout << "Bob"; }
	else { cout << "Alice"; }
	
	system("PAUSE");
}


Measured memory_bytes: 10616
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int N; cin >> N;
	vector<int> A(N);
	vector<pair<int,int> > oe(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) {
			oe[i].first = 2;
			oe[i].second = 1;
		}
		else {
			oe[i].first = 1;
			oe[i].second = 2;
		}
	}
	int ans = pow(3,N), sum=1;
	for (int i = 0; i < N; i++) {
		sum *= oe[i].first;
	}

	cout << ans-sum << endl;
}

Measured memory_bytes: 256
import sys
import math
import numpy as np
bl = np.searchsorted

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    T=2**i
    ai=a % (2*T)
    bi=b % (2*T)
    bi.sort()

    tmp=0
    left1 = bl(bi, T - ai)
    right1 = bl(bi, 2*T - ai)
    left2 = bl(bi, 3*T - ai)
    right2 = bl(bi, 4*T - ai)    
    if np.sum(-left1 + right1 -left2 +right2) % 2: ans+=T

print(ans)

Measured memory_bytes: 35876
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll pw[15];

int main(int argc, char const* argv[])
{
  ll n;
  cin >> n;
  pw[0] = 1;
  FOR(i, 1, 15){
    pw[i] = pw[i - 1] * 3;
  }
  set<int> st;
  string s;
  int res = 0;
  for(int k = 3; k < 10; k++){
    for(int i = 0; i < pw[k]; i++){
      ll tmp = i;
      st.clear();
      s = "";
      for(int j = 0; j < k; j++){
        st.insert(tmp % 3);
        if(tmp % 3 == 0)s += "3";
        if(tmp % 3 == 1)s += "5";
        if(tmp % 3 == 2)s += "7";
        tmp /= 3;
      }
      if(st.size() == 3 && stoi(s) <= n)res++;
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a, b, x;
   cin >> a >> b >> x;
   if(a>x) cout << "NO" <<endl;
   else if(a+b<x) cout << "NO" <<endl;
   else cout << "YES" <<endl;
   return 0;
  
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) cout << "Left";
  else if (A + B < C + D) cout << "Right";
  else cout << "Balanced";
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a = 0 , b = 0;
  cin >> a >> b;

  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    
    int cards[4][13];
    for(int suit = 0;suit<4;suit++){
        for(int num = 0;num<13;num++){
            cards[suit][num]=0;
        }
    }

    for(int i=0;i<n;i++)
    {
        char suit;
        int x;
        cin >> suit;
        cin >> x;
        switch(suit){
            case 'S':
                cards[0][x-1]=1;
                break;
            case 'H':
                cards[1][x-1]=1;
                break;
            case 'C':
                cards[2][x-1]=1;
                break;
            case 'D':
                cards[3][x-1]=1;
                break;
        }
    }
    for(int suit = 0;suit<4;suit++){
        for(int num = 0;num<13;num++){
            
            if(cards[suit][num]==0){
                switch(suit){
                    case 0:
                        cout << 'S' << " ";
                        break;
                    case 1:
                        cout << 'H' << " ";
                        break;
                    case 2:
                        cout << 'C' << " ";
                        break;
                    case 3:
                        cout << 'D' << " ";
                        break;
            }
            cout << (num+1) << endl;
                
            }
            
        }
    }
    

}

Measured memory_bytes: 1160
# include <bits/stdc++.h>
using namespace std;
int n,a[100005],dp[100005];
int main()
{
	cin>>n;
	for (int i=1; i<=n; i++)
	{
		cin>>a[i];
	}
	dp[n]=0;
	dp[n+1]=1e9;
	dp[n-1]=abs(a[n-1]-a[n]);
	for (int i=n-2; i>=1; i--)
	{
		dp[i]=min(dp[i+1]+abs(a[i+1]-a[i]),dp[i+2]+abs(a[i+2]-a[i]));
	}
	cout<<dp[1]<<endl;
}

Measured memory_bytes: 1024
/**
 * https://atcoder.jp/contests/abc128/tasks/abc128_d
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

/**
6 4
-10 8 2 1 2 6
 */
int main() {
    int n, k;
    cin >> n >> k;
    if (k <= 0) return 0;
    vector<int> odata(n, 0);
    for (int i = 0; i < n; ++i) {
        int v;
        cin >> v;
        //cout << v << endl;
        odata[i] = v;
    }
    int R = min(n, k);

    int ans = 0;
    for (int r = 1; r <= R; ++r) {
//        cout << "{ the select size:" << r << "}" << endl;
        int lk = k - r;
        for (int l = 0; l <= r; ++l) {
            vector<int> data{};
//            cout << "{ left size:" << l << " right size:" << r - l << " lk:" << lk << "}" << endl;
            for (int i = 0; i < l; ++i) {
                data.push_back(odata[i]);
            }
            for (int i = n - 1; n - 1 - i < (r - l); --i) {
                data.push_back(odata[i]);
            }
            sort(data.begin(), data.end());
            int p = 0;
            for (p = 0; p < lk; ++p) {
                if (data[p] >= 0) {
                    break;
                }
            }
//            cout << " data.size: " << data.size() << " data [0]:" << data[0] << endl;
//            cout << "{p:" << p << "}" << endl;
            int sum = accumulate(data.begin() + p, data.end(), 0);
//            cout << " sum :" << sum << endl;
            ans = max(ans, sum);
        }
    }
    cout << ans <<endl;
    return 0;
}


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

int main() {

	int n; cin>>n;
	int ans = 0;
	
	for(int i = 1; i<=n; i++){
		string s = to_string(i);
		
		if(s.size()&1) ans++;
		
	}
	
	cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  string S, T;
  cin >> S >> T;
  int res = 0;
  for (int i=0; i<(int)S.size(); i++) {
    if (S[i]!=T[i]) res++;
  }
  cout << res << endl;
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[100002], b[100002];
    vector<int> v[100002];
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    vector<int> cross;
    for(int i = 0; i < n; i++){
        if((int)v[i].size() % 2){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        if((int)v[i].size() >= 6){
            cout << "Yes" << endl;
            return 0;
        }
        if((int)v[i].size() == 4) cross.push_back(i);
    }
    if((int)cross.size() >= 3){
        cout << "Yes" << endl;
        return 0;
    }
    if((int)cross.size() <= 1){
        cout << "No" << endl;
        return 0;
    }
    int c0 = cross[0], c1 = cross[1];
    bool used[100002];
    for(int i = 0; i < 4; i++){
        fill(used, used + n, false);
        used[c0] = true;
        int now = v[c0][i];
        while(now != c1){
            used[now] = true;
            if(used[v[now][0]] && used[v[now][1]]){
                cout << "Yes" << endl;
                return 0;
            }
            if(used[v[now][0]]) now = v[now][1];
            else now = v[now][0];
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 6656
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
    char s[100010]={};
    scanf("%s", s);
    int ub=strlen(s);
    s[ub] = '$';

    for (int i=0; i<ub; ++i)
        for (int j=i+1; j<=i+2; ++j)
            if (s[i] == s[j]) {
                printf("%d %d\n", i+1, j+1);
                return 0;
            }

    printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 256
#C
from decimal import Decimal
X,K,D= map(Decimal, input().split())

if X>=0:
    if K*D<=X:
        ans=X-K*D
    else:
        tmp = X%D
        cnt = K-X//D
        if cnt==0:
            ans=tmp
        else:
            if cnt%2==0:
                ans=tmp
            else:
                ans=abs(tmp-D)
else:
    if K*D<=abs(X):
        ans = abs(X+K*D)
    else:
        tmp = -1*abs(X)%D
        cnt = K-abs(X)//D
        if cnt==0:
            ans = abs(tmp)
        else:
            if cnt%2==0:
                ans = abs(tmp)
            else:
                ans=abs(tmp+D)
    
print(ans)

Measured memory_bytes: 9808
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  long long int X;
  cin>>X;
  long long int sum=100;
  long long int cnt=0;
  while(sum<X){
    sum*=1.01;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
	int a,t,s=0,j;
	for(t=0;t<4;t++){
		scanf("%d",&a);
		s+=a;
	}
	j=s;
	for(t=0;t<60;t++){
		j=j-60;
		if(j<0){
			break;
		}
	}
	s-=t*60;
	
	printf("%d\n%d\n",t,s);
return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> t;
    int i = s.size() - 1;
    while(i > 0) {
        int mx = 0;
        for(int j = i; j >= max(0, i - m); --j) {
            if(s[j] == '0') mx = i - j;

        }
        if(mx == 0) {
            cout << -1 << endl;
            return 0;

        }
        t.pb(mx);
        i -= mx;
    }

    reverse(all(t));
    for(int i = 0; i < t.size(); ++i) cout << t[i] << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 1096
N = int(input())
ans = False
count = 0
for _ in range(N):
    a, b = [int(a) for a in input().split()]
    if a==b:
        count += 1
        if count == 3:
            ans = True
    else:
        count = 0

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61812
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    ll n,m;cin>>n>>m;
    ll ans=-1;
    rep(i,sqrt(m)+1){
        if(i==0)continue;
        if(m%i==0&&i*n<=m){
            ans =max(ans,(ll)i);
        }
        if(m%i==0&&(m/i)*n<=m){
            ans =max(ans,m/i);
        }
        
    }
    cout<<ans<<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 i;
		if(a>b){
			i=a;
			a=b;
			b=i;
		}
		if(b>c){
			i=b;
			b=c;
			c=i;
			if(a>b){
				i=a;
				a=b;
				b=i;
			}
		}
		System.out.printf("%d %d %d%n",a,b,c);
	}
}


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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if ((x + r <= W) && (x - r >= 0) && (y + r <= H) && (y - r) >= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

#define MN 30001
bool prime[MN];

int main()
{
	prime[0]=prime[1]=0;

	for(int i=2; i<MN; i++) prime[i]=1;

	for(int i=2; i*i<MN; i++)
	{
		if(prime[i])
		{
			for(int j=i*i; j<MN; j+=i)
			{
				prime[j]=0;
			}
		}
	}

	vector<int> p;

	for(int i=2; i<30001; i++)
		if(prime[i]) p.push_back(i);

	int T;
	while(cin >> T, T)
	{
		int cnt=0;
		for(int i=0; i<p.size(); i++)
		for(int j=i; j<p.size(); j++)
		{
			int t=T-p[i]-p[j];
			if(t<0)			break;
			if(t<p[j])		break;
			if(!prime[t])	continue;


			if(p[i]+p[j]>t)
			{
				cnt++;
			}
		}

		cout << cnt << endl;
	}

}

Measured memory_bytes: 964
#include<stdio.h>
int main(void){
  int h[10],i=0,j=0,max,t;
  do{
    scanf("%d",&h[i]);
      i++;
      }while(i<10);
  for(i=0;i<3;i++){
    max=0;
    for(j=i;j<10;j++){
      if(max<h[j]){
	max=h[j];
	t=j;
      }
    }
    h[t]=h[i];
    h[i]=max;

    printf("%d\n",h[i]);
  }
  return 0;
  }

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

int main()
{
    int N;
    cin >> N;
    int p[N];
    rep(i, N) cin >> p[i];

    int diff = 0;
    int m = p[0];
    for (int i = 1; i < N; i++) {
        m = min(m, p[i-1]);
        if (p[i] > m) {
            diff++;
        }
    }

    cout << N - diff << endl;

    return 0;
}

Measured memory_bytes: 1024
import math

N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

L = []
for i in range(N):
    for j in range(i+1, N):
        L.append( math.sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) ) )
print(sum(L)*2/N)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int n; ll d;
ll a[300001];
int main() {
	cin >> n >> d;
	ll s = 0;
	rep(i, n) {
		cin >> a[i];
		a[i]--; a[i] %= (d + 1);
		s ^= a[i];
	}
	if (s==0)cout << "Second" << endl;
	else cout << "First" << endl;
	//stop
	return 0;
}



Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
int main(){
    int c[3][3];
    string ans = "Yes";
    for(int i = 0;i < 3;i ++) for(int j = 0;j < 3;j ++) cin >> c[i][j];
    for(int i = 1;i < 3;i ++) for(int j = 1;j < 3;j ++){
        if(c[i][0] - c[0][0] != c[i][j] - c[0][j]) ans = "No"; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N, W;
ll w1, v1;
// vw1[i]: weightがw1+iである品物のvalueのvector
vector<ll> vw1[10];

int main()
{
    cin >> N >> W;
    cin >> w1 >> v1;
    vw1[0].push_back(v1);

    for (int i = 0; i < N - 1; i++)
    {
        ll w, v;
        cin >> w >> v;
        for (int j = 0; j <= 3; j++)
        {
            if (w == w1 + j)
            {
                vw1[j].push_back(v);
            }
        }
    }

    // w1〜w1+3の各weightごとに価値が高い順にsort
    for (int j = 0; j <= 3; j++)
    {
        sort(vw1[j].begin(), vw1[j].end(), greater<ll>());
    }

    ll ans = 0, sum = 0;
    // weightが
    // w1のものをi個、
    // w1+1のものをj個、
    // w1+2のものをk個、
    // w1+3のものをl個
    // 取った場合を全探索してmaxをとる
    for (int i = 0; i <= vw1[0].size() && w1 * i <= W; i++)
    {
        for (int j = 0; j <= vw1[1].size() && w1 * i + (w1 + 1) * j <= W; j++)
        {
            for (int k = 0; k <= vw1[2].size() && w1 * i + (w1 + 1) * j + (w1 + 2) * k <= W; k++)
            {
                sum = 0;
                sum += accumulate(vw1[0].begin(), vw1[0].begin() + i, 0LL);
                sum += accumulate(vw1[1].begin(), vw1[1].begin() + j, 0LL);
                sum += accumulate(vw1[2].begin(), vw1[2].begin() + k, 0LL);

                ll rest_w = W - w1 * i - (w1 + 1) * j - (w1 + 2) * k;
                ll l = min(ll(vw1[3].size()), rest_w / (w1 + 3));
                sum += accumulate(vw1[3].begin(), vw1[3].begin() + l, 0LL);
                ans = max(ans, sum);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

def TopoSort_cnt(n,cnt):
    start=deque()
    for i in xrange(n):
        if indeg[i]==0 :
            start.append(i)
    cnt+=len(start)
    while len(start)>0:
        i=start.popleft()
        ans.append(i)
        tmp=0
        for j in g[i]:
            indeg[j]-=1
            if indeg[j]==0:
                start.append(j)
                tmp+=1
        cnt=max(cnt,cnt*tmp)
    return ans,cnt

def solve(n,m):
    for i in xrange(m):
        wt,lt=map(int,raw_input().split())
        wt-=1;lt-=1
        g[wt].append(lt)
        indeg[lt]+=1
    ans,cnt=TopoSort_cnt(n,0)
    if cnt>1:
        for i in xrange(n):
            print(ans[i]+1)
        print(1)
    else:
        for i in xrange(n):
            print(ans[i]+1)
        print(0)

n=int(raw_input())
m=int(raw_input())
indeg=[0]*n
g=[[] for _ in xrange(n)]
ans=[]

solve(n,m)

Measured memory_bytes: 10428
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    long i = 1;
    while (i * (i + 1) / 2 < N) i++;
    StringBuilder sb = new StringBuilder();
    for (int j = 1; j <= i; j++) if (j != i * (i + 1) / 2 - N) sb.append(j).append('\n');
    System.out.print(sb.toString());
  }
}


Measured memory_bytes: 23764
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()

ans = float('inf')
for a in range(1, int(N**0.5)+1):
	if N % a == 0:
		b = N // a
		ans = min(ans, a + b - 2)
print(ans)


Measured memory_bytes: 40300
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M;
  cin >> N >> M;
  vector<long long> H(N),A(M),B(M);
  vector<bool> G(N,true);
  for (long long i = 0; i < N; i++){
    cin >> H.at(i);
  }
  for (long long i = 0; i < M; i++){
    cin >> A.at(i) >> B.at(i);
    if ( H.at(A.at(i) - 1) <= H.at(B.at(i) - 1) ){
      G.at(A.at(i) - 1) = false;
    }
    if ( H.at(A.at(i) - 1) >= H.at(B.at(i) - 1) ){
      G.at(B.at(i) - 1) = false;
    }
  }

  long long count = 0;
  for (long long i = 0; i < N; i++){
    if (G.at(i)){
      count++;
    }
  }
  
  cout << count;
    
}

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

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

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

  vector<vector<int>> a(n, vector<int>(3));
  rep(i, n) {
    rep(j, 3) {
      cin >> a.at(i).at(j);
    }
  }

  vector<vector<int>> dp(n + 1, vector<int>(3));
  rep(i, n) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) {
          continue;
        } else {
          chmax(dp.at(i + 1).at(k), dp.at(i).at(j) + a.at(i).at(k));
        }
      }
    }
  }
  int ans = 0;
  rep(i, 3) {
    ans = max(ans, dp.at(n).at(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14068
n = int(input())
mydict = {}
for _ in range(n):
    tmp=sorted(input(), key=str.lower)
    tmp = ''.join(sorted(tmp))
    if tmp in mydict:
        mydict[tmp]+=1
    else:
        mydict.setdefault(tmp, 1)
ans = 0
for i in mydict.values():
    ans+=i*(i-1)/2
print(int(ans))



Measured memory_bytes: 21852
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 110;
int n,m,t[N];
char s[N][N],S[N];

int main(){
	n=read();
	For(i,1,n) scanf("%s%d",s[i]+1,&t[i]);
	scanf("%s",S+1),m=strlen(S+1);
	For(i,1,n){
		bool flag=1;
		if (strlen(s[i]+1)!=m) continue;
		For(j,1,m) if (S[j]!=s[i][j]){flag=0;break;}
		if (flag){
			int ans=0;
			For(j,i+1,n) ans+=t[j];
			printf("%d\n",ans);
			break;
		}
	}
}

Measured memory_bytes: 3828
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i, n, m, a[N], b[N], vis[N], comp;
vi g[N];

void dfs(int v)
{
    vis[v] = 1;
    comp++;
    for (int u : g[v])
    {
        if (vis[u])
            continue;
        dfs(u);
    }
}

void solve()
{
    cin >> n >> m;
    for (i = 1; i <= m; i++)
    {
        cin >> a[i] >> b[i];
        g[a[i]].pb(b[i]);
        g[b[i]].pb(a[i]);
    }
    int ans = 0;
    for (i = 1; i <= n; i++)
    {
        if (!vis[i])
        {
            comp = 0;
            dfs(i);
            ans = max(ans, comp);
        }
    }
    cout << ans;
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 28528