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


int main(){
  int h1,h2;
  cin>>h1>>h2;
 
  int k1,k2;
  cin>>k1>>k2;
  
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if(a*h1+b*h2+(h1/10)*c+(h2/20)*d < a*k1+b*k2+(k1/10)*c+(k2/20)*d) cout<<"kenjiro"<<endl;
  if(a*h1+b*h2+(h1/10)*c+(h2/20)*d > a*k1+b*k2+(k1/10)*c+(k2/20)*d) cout<<"hiroshi"<<endl;
  if(a*h1+b*h2+(h1/10)*c+(h2/20)*d == a*k1+b*k2+(k1/10)*c+(k2/20)*d) cout<<"even"<<endl;
  
  return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long mini=1000000009;
    int n,k;
    scanf("%d%d",&n,&k);
    long long a[n+1];
    for(int i=0; i<n; i++)scanf("%lld",&a[i]);
    sort(a,a+n);
    for(int i=0; i<=n-k; i++)
    {
        int val = a[i+k-1]-a[i];
        if(val<mini)mini=val;
    }
    printf("%lld\n",mini);
}


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

int main(){
    int x, y, z, k;
    scanf("%d%d%d%d", &x, &y, &z, &k);
    vector<LL> a(x), b(y), c(z);
    for(int i = 0;i < x;i++)    scanf("%llu", &a[i]);
    for(int i = 0;i < y;i++)    scanf("%llu", &b[i]);
    for(int i = 0;i < z;i++)    scanf("%llu", &c[i]);
    vector<LL> ab;
    for(auto s : a) for(auto t : b) ab.push_back(s+t);
    sort(ab.rbegin(), ab.rend());
    vector<LL> abk(k), abc;
    copy(ab.begin(), ab.begin()+min(k, (int)ab.size()), abk.begin());
    for(auto s : abk)   for(auto t : c) abc.push_back(s+t);
    sort(abc.rbegin(), abc.rend());
    for(int i = 0;i < k;i++)    printf("%llu\n", abc[i]);
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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


int main(){
  ll N,C,K;
  cin >> N >> C >> K;
  VLL T(N);
  rep(i,N) cin >> T[i];
  sort(all(T));
  ll busCnt = 0;
  ll nextTime = 0;
  ll busMember = 0;
  rep(i,N){
    if(nextTime < T[i] || busMember >= C){
      //cout << i << endl;
      nextTime = T[i] + K;
      busCnt ++;
      busMember=1;
    }else{
      busMember++;
    }
  }
  cout << busCnt << endl;
  return 0;
}


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

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	int ans = (n/2) + (n&1);
	cout << ans << '\n';

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
vint G[111111];

bool used[111111];
bool need[111111];

vint ans;
bool dfs(int v){
    used[v]=true;
    bool ok=need[v];
    bool done=false;
    for(auto u:G[v]){
        if(used[u])continue;
        if(need[u]){
            dfs(u);
            ok=true;
            done=true;
            break;
        }
    }
    for(auto u:G[v]){
        if(done)break;
        if(used[u])continue;
        if(dfs(u)){
            ok=true;
            break;
        }
    }

    if(done||ok)ans.pb(v);
    return done||ok;
}
signed main(){
    cin>>N>>M;
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }

    vpint hoge;
    rep(i,N)hoge.pb({G[i].size(),i});
    sort(all(hoge));

    int x=hoge[0].se;
    int y=hoge[1].se;
    for(auto u:G[x])need[u]=1;
    for(auto u:G[y])need[u]=1;

    need[x]=1;
    need[y]=0;
    used[y]=1;
    dfs(x);

    vint latte=ans;
    reverse(all(latte));
    ans.clear();
    used[y]=0;
    need[y]=1;
    dfs(latte.back());
    ans.pop_back();
    reverse(all(ans));
    latte.insert(latte.end(),all(ans));

    printf("%lld\n",(int)latte.size());
    rep(i,latte.size()){
        if(i)printf(" ");
        printf("%lld",latte[i]+1);
    }puts("");
    return 0;
}


Measured memory_bytes: 15472
#include <iostream>

using namespace std;

int main(){
  int a,b,c;
  int check;
  
  cin >> a >> b >> c;
  
  check=a+b+c;
  if(check>21){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
    return 0;
}

Measured memory_bytes: 256
n = input()
s = list(raw_input().strip())

blacks = s.count('#')
whites = n - blacks

ans = min(blacks, whites)

b, w = 0, 0
for i in xrange(n):
    if s[i] == '#': b += 1
    else: w += 1

    v = (i + 1) - w + n - i - 1 - (blacks - b)
    ans = min(ans, v)

print ans

Measured memory_bytes: 40556
#include<cstdio>
#define M 131072
#define N 20
inline long long min(long long x,long long y){return x<y?x:y;}
int e[M],n;long long f[M][N][N],g[M],h[M];bool c[M][N][N];
long long dfs(int u,int v,int w)
{
    if(v+1==w)return 0ll;
    if(c[u][v][w])return f[u][v][w];
    c[u][v][w]=true,f[u][v][w]=0x7fffffffffffffffll;
    for(int i=v+1;i<w;i++)f[u][v][w]=min(f[u][v][w],dfs(u<<1,v,i)+dfs(u<<1|1,i,w)+e[i]*(g[u]+h[u]));
    return f[u][v][w];
}
int main()
{
    scanf("%d",&n),g[1]=h[1]=1;
    for(int i=1;i<=n;i++)scanf("%d",e+i);
    for(int i=1;i<1<<n-2;i++)g[i<<1]=g[i],h[i<<1]=g[i<<1|1]=g[i]+h[i],h[i<<1|1]=h[i];
    return 0&(printf("%lld\n",e[1]+e[n]+dfs(1,1,n)));
}

Measured memory_bytes: 235648
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int MOD = 1000000007;
const int INF = 2000000000;
const long double PI = acosl(-1);
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
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; }

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string T;
    cin >> T;
    int N = SZ(T);


    int ans = 0;
    REP(i,N) {
        if (T[i] == 'P') cout << T[i];
        else if (T[i] == 'D') cout << T[i];
        else cout << 'D';
    }
    cout << endl;
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/nomura2020/nomura2020_b && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/nomura2020/nomura2020_b && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/nomura2020/nomura2020_b && sh submit.sh
*/


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

int main() {
	long long N;
	cin >> N;
	long long small;
	for (int n = 0;n<5;++n) {
		long long num;
		cin >> num;
		if (0==n) {
			small = num;
		}
		else {
			small = min(small, num);
		}
	}
	long long ans = 5;
	ans--;
	ans += N / small;
	if (0 != N%small) {
		ans++;
	}
	cout << ans << endl;
}


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

int main(void){cin.tie(0);ios_base::sync_with_stdio(false);
    int nc,nr;
    cin>>nc>>nr;
    vector<int> v(nc,0);
    
    int f;
    int s;
    for(int i=0;i<nr;++i){
        cin>>f>>s;
        v[f-1]+=1;
        v[s-1]+=1;
    }
    for(auto a:v){cout<<a<<'\n';}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
int main(){
  int n,x,i;
  cin>>n>>x;
  vector <int> L(n);
  for(i=0;i<n;i++) cin>>L[i];
  cout<<n+(x-accumulate(L.begin(),L.end(),0))/ *min_element(L.begin(),L.end());
 }

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

int main() {
  int n;
  cin >> n;
  int ans = n * n * n;
  cout << ans << endl;
  return 0;
}

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

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) {
        return f[x] == x;
    }
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main() {
    int N;
    cin >> N;
    Sieve sieve(1e6);
    map<int, int> s;
    for (int i = 2; i <= N; i++) {
        for (auto e : sieve.factor(i)) {
            s[e.first] += e.second;
        }
    }
    int over75 = 0;
    int over25 = 0;
    int over15 = 0;
    int over5  = 0;
    int over3  = 0;
    for (auto e : s) {
        if (e.second >= 74) over75++;
        if (e.second >= 24) over25++;
        if (e.second >= 14) over15++;
        if (e.second >= 4) over5++;
        if (e.second >= 2) over3++;
    }
    int ans = 0;
    ans += over75;
    ans += (over25) * (over3-1);
    ans += (over15) * (over5-1);
    ans += (over5)*(over5-1)*(over3-2)/2;
    cout << ans << endl;
}

Measured memory_bytes: 4732
N = int(input())
a = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
    cnt, mod = divmod(a[i], 2)
    ans += cnt
    if i < N - 1 and a[i + 1] != 0:
        a[i + 1] += mod

print(ans)

Measured memory_bytes: 13000
function Main(input) {
  input = input.split("\n")
  n = Number(input[0]);
  ans = 0;
  for(var i=1; i<=n; i++){
    if(String(i).length%2 == 1){
      ans++;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10956
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SYOU(x) fixed<<setprecision(x) //小数点桁数を指定する
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){

    INT(N);
    int pay = 0;
    while(pay < N){
        pay += 1000;
    }
    cout << pay - N << endl;
    return 0;
}

Measured memory_bytes: 3732
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0

for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            y=500*i+100*j+50*k
            if x==y:
                count+=1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int abs(int x){
    return x >= 0 ? x : -x;
}


int main(){
    int n; cin >> n;
    int h[n],d[n];

    rep(i,n){
        cin >> h[i];
        d[i] = 0;
    } 

    d[0] = 0;
    d[1] = abs(h[1]- h[0]);

    for(int i= 2 ; i < n ; i++){
        d[i] = min(abs(h[i]-h[i-1]) + d[i-1] , abs(h[i]-h[i-2])+d[i-2]);
    }

    cout << d[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

//後ろから考える Mulitaple Arrays

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),B(N);
    
    for(ll i = 0;i < N;i++){
        cin >> A.at(i) >> B.at(i);
    }

    ll rs = 0,amari=0;

    for(ll i = N -1;i >= 0;i--){
            A.at(i) += rs;
        if(A.at(i) % B.at(i) != 0){
            amari = A.at(i) % B.at(i);
            rs += B.at(i) - amari;
        }
    }

    cout << rs << endl;
    

}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        int[] wary = {0, w};
        int[] hary = {0, h};
        for (int i = 0; i < n; i++) {
            int x = Integer.parseInt(sc.next());
            int y = Integer.parseInt(sc.next());
            int a = Integer.parseInt(sc.next());
            switch (a) {
                case 1:
                    if (x > wary[0]) {
                        wary[0] = x;
                    }
                    break;
                case 2:
                    if (x < wary[1]) {
                        wary[1] = x;
                    }
                    break;
                case 3:
                    if (y > hary[0]) {
                        hary[0] = y;
                    }
                    break;
                case 4:
                    if (y < hary[1]) {
                        hary[1] = y;
                    }
                    break;
            }
        }
        int x = wary[1] < wary[0] ? 0 : wary[1] - wary[0];
        int y = hary[1] < hary[0] ? 0 : hary[1] - hary[0];
        System.out.println(x * y);
    }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long answer = 0;
		for (int i = 0; i < N; i++) {
			long x = input.nextLong();
			while (x%2==0) {
				answer++;
				x/=2;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 34292
n = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(1, n-1):
  p1 = A[i-1]
  p2 = A[i]
  p3 = A[i+1]
  if (p1 > p2 and p2 > p3) or (p3 > p2 and p2 > p1):
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<vector<int> > data(N);

  for (int i = 0; i < N; i++)
  {
    int A,B,C;
    cin>>A>>B>>C;
    data[i].push_back(A);
    data[i].push_back(B);
    data[i].push_back(C);
  }

  int ANS = -1*I64_MAX;
  for (int i = 0; i < 8; i++)
  {

    vector<int> val(N,0);
    int X = 0,Y = 0,Z = 0;
    if(i&(1<<0))X=1;//1なら正 0なら負を加算
    if(i&(1<<1))Y=1;//1なら正 0なら負を加算
    if(i&(1<<2))Z=1;//1なら正 0なら負を加算


    // DEBUG("call");
    for (int j = 0; j < N; j++)
    {
    val[j] += (int)((X==1)?1:-1)*data[j][0];
    val[j] += (int)((Y==1)?1:-1)*data[j][1];
    val[j] += (int)((Z==1)?1:-1)*data[j][2];
    }
    

    sort(val.begin(),val.end(),greater<int>());
    int SUM = 0;
    for (int k = 0; k < M; k++)
    {
      SUM +=val[k];
      
    }
    // DEBUG(i);
    // DEBUG(SUM);
    chmax(ANS,SUM);
  }
  cout<<ANS<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
	ll X, K, D;
	scanf("%lld%lld%lld", &X, &K, &D);
	X = abs(X);
	if (K & 1) {
		X -= D;
		X = abs(X);
	}
	K >>= 1;
	D *= 2;
	ll r = X / D;
	if (r >= K) {
		printf("%lld\n", X - K * D);
		return 0;
	}
	printf("%lld\n", min(X - r * D, (r + 1) * D - X));
	return 0;
}


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


int main() {
	int k, s, c=0;
	cin>>k>>s;
	for(int i=0; i<=k; i++){
		for(int j=0; j<=k; j++){
			if(s-i-j<=k & s-i-j>=0) c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  a.append(input())
ac = a.count('AC')
wa = a.count('WA')
tle = a.count('TLE')
re = a.count('RE')
print('AC', 'x', ac)
print('WA', 'x', wa)
print('TLE', 'x', tle)
print('RE', 'x', re)

Measured memory_bytes: 16292
n = int(input())
a = input().split()
q = int(input())
d = dict()
s = 0
for num in a:
  if num in d:
    d[num] += 1
  else:
    d[num] = 1
  s += int(num)
for i in range(q):
  B, C = input().split()
  if B in d:
    if C in d:
      d[C] += d[B]
    else:
      d[C] = d[B]
    s += (int(C)-int(B))*d[B]
    d[B] = 0
  print(s)


Measured memory_bytes: 20956
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int L, R; cin >> L >> R;
	int ans = 2019;
	rep(i, L, min(R, L + 2020)) {
		rep(j, i + 1, min(i + 1 + 2020, R + 1)) {
			int x= (i % 2019)*(j % 2019) % 2019;
			chmin(ans, x);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int n;
ll a[200010];
ll f[200010],m[200010];
int main(int argc,char** argv){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		f[a[i]]++;
	}
	ll sum=0ll;
	rep(j,n){
		int i=a[j];
		if(m[i])continue;
		m[i]=(f[i]*(f[i]-1ll))/2ll;
		//cout<<m[i]<<" "<<i<<endl;
		sum+=m[i];
	}
	rep(i,n){
		ll ans=sum-(f[a[i]]*(f[a[i]]-1ll))/2ll;
		ans+=((f[a[i]]-1ll)*(f[a[i]]-2ll))/2ll;
		cout<<ans<<endl;
	}
	return 0;
}

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

int main()
{ 
  string s;
  int i,count=0;
  cin>>s;
  for(i=0;i<s.size();i++)
  {
    if(s[i]=='o')
    count++;
  }


if(count+15-s.size() >=8)
cout<<"YES\n";
else
cout<<"NO\n";

return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string

	fmt.Scan(&s)
	ans := ""
	for _, c := range s {
		if c == '0' {
			ans += "0"
		} else if c == '1' {
			ans += "1"
		} else {
			if len(ans) > 0 {
				ans = ans[:len(ans)-1]
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>

int main() {
    int t5 = 0, t7 = 0;
    for(int i = 0; i < 3; i++) {
        int a;
        
        scanf("%d", &a);
        if(a == 5) {
            t5++;
        } else if(a == 7) {
            t7++;
        }
    }
    if(t5 == 2 && t7 == 1) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  string L[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin >> s;
  rep(i,7) {
    if (s == L[i]) {
      cout << (7-i) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  int n; cin>>n;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) a[i]-=i;
  sort(a,a+n); int mn=a[n/2];
  for(int i=0;i<n;i++) a[i]-=mn;
  ll an=0;
  for(int i=0;i<n;i++) an+=abs(a[i]);
  cout<<an<<endl;
}

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

using namespace std;
#define pb push_back
#define db(x) cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 212345

int n;
int h[MAXN];
ll a[MAXN];
ll dp[MAXN];
ll tree[4 * MAXN];

void update(int node, int l, int r, int pos, ll val)
{
    if (l == r)
    {
        tree[node] = val;
        return;
    }

    int mid = (l + r)/2;

    if (pos <= mid)
        update(node * 2 + 1, l, mid, pos, val);
    else
        update(node * 2 + 2, mid + 1, r, pos, val);

    tree[node] = max(tree[node * 2 + 1], tree[node * 2 + 2]);
}

ll query(int node, int l, int r, int tl, int tr)
{
    if (r < tl || l > tr)
        return 0;
    
    if (tl <= l && r <= tr)
        return tree[node];

    int mid = (l + r)/2;
    return max(query(node * 2 + 1, l, mid, tl, tr),
               query(node * 2 + 2, mid + 1, r, tl, tr));
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &h[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }

    for (int i = 0; i < n; i++)
    {
        ll v = query(0, 0, n - 1, 0, h[i]);
        update(0, 0, n - 1, h[i], v + a[i]);
    }

    printf("%lld\n", query(0, 0, n - 1, 0, n - 1));
    
}

Measured memory_bytes: 8960
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
vector<vector<int>>erase(vector<vector<int>>field) {
	int dx[4] = { -1,0,1,0 };
	int dy[4] = { 0,1,0,-1 };

	vector<vector<int>>dels(13,vector<int>(6));
	UnionFind uf(78);
	for (int nowy = 0; nowy < 13; ++nowy) {
		for (int nowx = 0; nowx < 6; ++nowx) {
			if (field[nowy][nowx] != -1 && field[nowy][nowx] != 0) {
				for (int way = 0; way < 4; ++way) {
					const int nextx = nowx + dx[way];
					const int nexty = nowy + dy[way];
					if (nextx >= 0 && nextx < 6 && nexty >= 0 && nexty < 13) {
						if (field[nexty][nextx] == field[nowy][nowx]) {
							uf.unionSet(nowy*6+nowx,nexty*6+nextx);
						}
					}
				}
			}
		}
	}
	for (int nowy = 0; nowy < 13; ++nowy) {
		for (int nowx = 0; nowx < 6; ++nowx) {
			if (field[nowy][nowx] != -1 && field[nowy][nowx] != 0) {
				if (uf.size(nowy * 6 + nowx) >= 4) {
					dels[nowy][nowx]=true;
				}
			}
		}
	}
	vector<vector<int>>fin_dels(dels);
	for (int nowy = 0; nowy < 13; ++nowy) {
		for (int nowx = 0; nowx < 6; ++nowx) {
			if (field[nowy][nowx] ==-1) {
				for (int way = 0; way < 4; ++way) {
					const int nextx = nowx + dx[way];
					const int nexty = nowy + dy[way];
					if (nextx >= 0 && nextx < 6 && nexty >= 0 && nexty < 13) {
						if (dels[nexty][nextx]) {
							fin_dels[nowy][nowx]=true;
						}
					}
				}
			}
		}
	}
	return fin_dels;
}
vector<vector<int>>fall(vector<vector<int>>field) {
	for (int k = 0; k < 13; ++k) {
		for (int nowy = 12; nowy > 0; --nowy) {
			for (int nowx = 0; nowx < 6; ++nowx) {
				if (!field[nowy][nowx]) {
					swap(field[nowy][nowx],field[nowy-1][nowx]);
				}
			}
		}
	}
	return field;
}

int solve(vector<vector<int>>field) {
	int ans=0;
	while (true) {
		vector<vector<int>>dels(erase(field));
		bool flag=false;
		for (int y = 0; y < 13; ++y) {
			for (int x = 0; x < 6; ++x) {
				if (dels[y][x]) {
					field[y][x]=0;
					flag=true;
				}
			}
		}
		if(!flag)return ans;
		field=fall(field);
		ans++;
	}
}

int main() {
	int Q;cin>>Q;
	
	while (Q--) {
		vector<vector<int>>field(13, vector<int>(6));
		map<char, int>mp;
		mp['R'] = 1;
		mp['B'] = 2;
		mp['.'] = 0;
		mp['G'] = 3;
		mp['P'] = 4;
		mp['O']=-1;
		mp['Y']=5;
		for (int i = 0; i < 12; ++i) {
			string st;cin>>st;
			for (int j = 0; j < 6; ++j) {
				char ch(st[j]);
				field[i+1][j]=mp[ch];
			}
		}
		int ans=solve(field);
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){
    int a[3];
    rep(i,3)cin>>a[i];
    sort(a,a+3);
    cout<<a[0]*a[1]/2<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
E1=set()
EN=set()
for i in range(M):
    x,y=map(int,input().split())
    if x==1 or y==1:
        E1.add(x)
        E1.add(y)

    if x==N or y==N:
        EN.add(x)
        EN.add(y)

if E1 & EN!=set():
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 19000
#include<bits/stdc++.h>
using namespace std;
#define  mem(a,x) memset(a,x,sizeof(a));
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;
int main()
{
    ft
    int t,i,j,n,m,l=1,r;
    cin>>n;
    map<int,int>mp;
    mp[n]=1;
    while(1)
    {
        if(n%2==0)
        {
            n/=2;
        }
        else
        {
            n=3*n+1;
        }
        l++;
        if(mp[n]==1)
        {
            cout<<l<<"\n";
            return 0;
        }
        mp[n]=1;
    }
    return 0;
}



Measured memory_bytes: 3612
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n, m;
	cin >> n >> m;
	ll a;
	ll sum = 0;
	rep(i, m){
		cin >> a;
		sum += a;
	}

	if(sum > n) co(-1);
	else co(n - sum);

	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n; cin >> n;
	ll a[n]; zep(i, 0, n)cin >> a[i];
	
	ll q; cin >> q;
	ll MAX = 100000;
	ll cnt[MAX + 1]; memset(cnt, 0, sizeof(cnt));
	ll ans = 0;
	zep(i, 0, n){
		cnt[a[i]]++;
		ans += a[i];
	}
	
	zep(i, 0, q){
		ll b, c; cin >> b >> c;
		ans += -b * cnt[b] + c * cnt[b];
		cnt[c] += cnt[b]; cnt[b] = 0;
		print(ans)
	}
	
	return 0;
}

Measured memory_bytes: 5200
package main

import "fmt"

func main() {
	var A, B, C, D, E, F int
	fmt.Scan(&A, &B, &C, &D, &E, &F)

	ans1, ans2 := 100*A, 0
	tmp := 0.0
	for a := 0; a*A*100 <= F; a++ {
		for b := 0; b*B*100 <= F; b++ {
			for c := 0; c*C <= F; c++ {
				for d := 0; d*D <= F; d++ {
					w := a*A*100 + b*B*100
					s := c*C + d*D
					if w+s > F {
						continue
					}

					if float64(s) <= float64(w)/100.0*float64(E) {
						p := 100 * float64(s) / (float64(w) + float64(s))
						if tmp < p {
							tmp = p
							ans1 = s + w
							ans2 = s
						}
					}
				}
			}
		}
	}

	fmt.Println(ans1, ans2)
}


Measured memory_bytes: 512
#include <iostream>
#include <ios>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    long long N, T;
    cin >> N >> T;
    vector<long long> A(N, 0LL);
    for (auto & a : A) cin >> a;
    vector<long long > buy(N, 0LL);
    buy[0] = A[0];
    for (int i = 1; i != N; ++i) buy[i] = min(buy[i - 1], A[i]);
    int count = 0;
    long long max_profit = 0;
    for (int i = 1; i != N; ++i){
        long long profit = A[i] - buy[i];
        if (profit == max_profit){
            ++count;
        }else if (profit > max_profit){
            max_profit = profit;
            count = 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>ll(b);i--)
using ll = long long;
using namespace std;

int main(){
	ll n,k;
	cin>>n>>k;
	ll v[100];
	rep(i,0,n)cin>>v[i];
	vector<ll> st;
	ll q=0;
	ll r=0;
	ll x=0;
	vector<ll> s;
	rep(in,1,min(k,n)+1){
		rep(div,0,in+1){
		x=k-in;
		rep(j,0,div) st.push_back(v[j]);
		irep(k,n-1,n-1-(in-div))st.push_back(v[k]);
		sort(st.begin(),st.end(),greater<ll>());
		rep(i,0,st.size()) if(st[i]>=0) s.push_back(st[i]);
		sort(st.begin(),st.end());
		rep(i,0,st.size()) if(st[i]<0)s.push_back(st[i]);
		rep(o,0,s.size()) {
			if(s[o]>=0) r+=s[o];
			else if(x>0 &&s[o]<0) x--;
			else if(x==0 && s[o]<0) r+=s[o];
		}
		//cout<<r<<endl;
		q=max(q,r);
		r=0;
		//rep(i,0,s.size())cout<<s[i]<<"  ";
		st.erase(st.begin(),st.end());
		s.erase(s.begin(),s.end());
		}
	}
	cout<<q;
}



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

int main()
{
  int n;
  cin>>n;
  
  int wk1=1,wk2=1;
  if(n==1){
    int input;
    cin>>input;
    if(input%2==0)
      cout<<1<<endl;
    else
      cout<<2<<endl;
  }
  else{
    for(int i=0;i<n;i++){
      int input;
      cin>>input;
      wk1*=3;
      if(input%2==0){
       wk2*=2;
      }else{
        wk2*=1;
      }
    }
    cout<<wk1-wk2<<endl;;
  }

  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto xs = readints;
    xs.sort();

    auto ans = abs(xs[0] - xs[1]) + abs(xs[1] - xs[2]);
    writeln(ans);
}

Measured memory_bytes: 256
def slow_solve(S):
    l = 2 ** (len(S) - 1)
    sum = 0
    for i in range(l):
        bi = ("{:0%db}" % (len(S) - 1)).format(i)
        ope = []
        for b in bi:
            if b == "0":
                ope.append("")
            else:
                ope.append("+")
        ope.append("")
        p = ""
        for s, o in zip(S, ope):
            p += s
            p += o
        sum += eval(p)
    return sum

if __name__ == "__main__":
    print(slow_solve(input()))


Measured memory_bytes: 3064
#!/usr/bin/python3

import os
import sys


def main():
    S = inp()

    D = ['SAT', 'FRI', 'THU', 'WED', 'TUE', 'MON', 'SUN']
    i = D.index(S)
    print(i + 1)


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
n, m = map(int, input().split())
A = list(map(int, input().split()))

sum_A = sum(A)
j = 0
for i in range(m):
    maxA = max(A)
    if maxA >= sum_A/(4*m):
        j += 1
    A.remove(maxA)
if j == m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    string newT;
    newT = t;
    if(!newT.empty())
    {
        newT.pop_back();
    }
//    cout << "naewT: " << newT << endl;
    if(s == newT)
    {
        cout << "Yes" << "\n";
    }
    else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

ll a[403], s[403];
ll dp[403][403];

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 1; i <= N; i++) s[i] = s[i - 1] + a[i - 1];
	for (int d = 2; d <= N; d++) {
		for (int i = 0; i + d <= N; i++) {
			dp[i][i + d] = min(dp[i + 1][i + d], dp[i][i + d - 1]) + s[i + d] - s[i];
			for (int j = i; j < i + d; j++) {
				dp[i][i + d] = min(dp[i][i + d], dp[i][j] + dp[j][i + d] + s[i + d] - s[i]);
			}
		}
	}
	cout << dp[0][N] << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <unordered_map>
int main() {
    auto n = 0;
    std::cin >> n;

    auto names = std::unordered_map<std::string, int>();
    for (auto i_ = 0; i_ < n; ++i_) {
        auto s = std::string();
        std::cin >> s;
        names[s]++;
    }

    auto m = 0;
    std::cin >> m;
    for (auto i_ = 0; i_ < m; ++i_) {
        auto s = std::string();
        std::cin >> s;
        names[s]--;
    }

    const auto max_value = std::max_element(names.begin(), names.end(), [](const auto& a, const auto& b) {
                               return a.second < b.second;
                           })->second;
    std::cout << std::max(max_value, 0) << std::endl;

    return 0;
}

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

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

using namespace std;

const int INF=1<<29;

string s;
int dp[1000001][2];

int dfs(int i,int carry){
	if(i==s.length()) return carry;

	if(dp[i][carry]!=-1) return dp[i][carry];

	int res=INF,a=s[i]-'0';
	rep(d,10){
		res=min(res,dfs(i+1,(a+d+carry)/10)+(a+d+carry)%10+d);
	}
	return dp[i][carry]=res;
}

int main(){
	memset(dp,-1,sizeof dp);

	cin>>s;
	reverse(s.begin(),s.end());

	printf("%d\n",dfs(0,0));

	return 0;
}


Measured memory_bytes: 87300
#!/usr/bin/ruby
# encoding: utf-8

# 長さ4の文字列
S = gets.chomp

Su = S[0,2].to_i # Sのうえ
Ss = S[2,2].to_i # Sのした

if Su == 0 or Ss == 0 then
  if Su <= 12 and Su >= 1 then
    puts "MMYY"
    exit
  end
  if Ss <= 12 and Ss >= 1 then
    puts "YYMM"
    exit
  end
  
  puts "NA"
  exit
end

if Su > 12 and Ss > 12 then
  puts "NA"
  exit
end

if Su > 12 and Ss <= 12 then
  puts "YYMM"
  exit
end

if Su <= 12 and Ss > 12 then
  puts "MMYY"
  exit
end

if Su <= 12 and Ss <= 12 then
  puts "AMBIGUOUS"
  exit
end


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

using namespace std;
const int MAXN = 2 * (int)1e5 + 5;
vector<int> G[MAXN];
bool visited[MAXN];

void dfs(int cur, int par) {
  visited[cur] = true;
  for (int i = 0; i < G[cur].size(); ++i) {
    int next = G[cur][i];
    if (next != par && !visited[next]) {
      dfs(next, cur);
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int l;
      cin >> l;
      l = l + n - 1;
      G[i].push_back(l);
      G[l].push_back(i);
    }
  }
  dfs(0, -1);
  for (int i = 0; i < n; ++i) {
    if (!visited[i]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}



Measured memory_bytes: 8832
def slove():
    import sys
    input = sys.stdin.readline
    n, m, x = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    ca = 0
    cb = 0
    for i in range(m):
        if a[i] < x:
            ca += 1
        else:
            cb += 1
    print(min(ca, cb))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    long long b,c,d=0,e=0,i=0;
    char a;
    cin>>a;
    i = (int) (a);
    if(i>=97){cout<<'a';return 0;}
    if(i<97){cout<<'A';return 0;}
}


Measured memory_bytes: 3624
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{ string s;
 bool flag=false;
 cin >> s;
 for(int i=0;i<s.size();i++)
 { if(s[i]=='7')
 {flag=true;}}
 if(flag)
 {cout <<"Yes" <<endl;}
 else 
 {cout << "No" <<endl;}
 return 0;}

Measured memory_bytes: 3628