akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define clr(x) memset(x, 0, sizeof(x))
#define all(a) a.begin(),a.end()
#define forn(i, a,b) for(int i = int(a); i < int(b); ++i)
#define forn_r(i, b, a) for(int i = int(b); i > int(a); i--)
#define trav(a,x) for (auto& a : x)
#define printArray(array, length) for(int i = 0; i < length; i++) cout<< array[i] << (i == length - 1 ? '\n' : ' ');
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define debug(x) cout << #x << "=" << x << endl
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
template <typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template <typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f;
inline ll gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(int a, int b) { return a * b / gcd(a, b); }

ll A[200004], n, k;

bool eval(int num) {
    ll kk = k;
    for (auto i : A) {
        kk -= (i%num)?(i/num):i/num-1;
        if (kk<0) return 0;
    }
    return 1;
}

int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> A[i];
    ll s = 1, e = INT_MAX, mid;
    while (s <= e) {
        mid = (s + e) / 2;
        if (eval(mid)) e = mid-1;
        else s = mid+1;
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 5100
object Main extends App {

  import scala.io.StdIn._
  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.tabulate(h){_ ⇒ readLine.trim.split(' ').map(_.toInt)}
  var stack: List[CoordinatePair] = Nil
  for (i ← 0 until h){
    if (i % 2 == 0) {
      for (j ← 1 until w) {
        if (state(i)(j - 1) % 2 == 1){
          stack = CoordinatePair(Coordinate(i, j - 1), Coordinate(i, j))::stack
          state(i)(j - 1) -= 1
          state(i)(j) += 1
        }
      }
      if (state(i)(w - 1) % 2 == 1 && i + 1 < h){
        stack = CoordinatePair(Coordinate(i, w - 1), Coordinate(i + 1, w - 1))::stack
        state(i)(w - 1) -= 1
        state(i + 1)(w - 1) += 1
      }
    } else {
      for (j ← (1 until w).reverse) {
        if (state(i)(j) % 2 == 1){
          stack = CoordinatePair(Coordinate(i, j), Coordinate(i, j - 1))::stack
          state(i)(j) -= 1
          state(i)(j - 1) += 1
        }
      }
      if (state(i)(0) % 2 == 1 && i + 1 < h){
        stack = CoordinatePair(Coordinate(i, 0), Coordinate(i + 1, 0))::stack
        state(i)(0) -= 1
        state(i + 1)(0) += 1
      }
    }
  }
  println(stack.size)
  for (CoordinatePair(from, to) ← stack.reverse){
    println(
      s"${from.y + 1} ${from.x + 1} ${to.y + 1} ${to.x + 1}"
    )
  }
  case class Coordinate(y: Int, x: Int)
  case class CoordinatePair(from: Coordinate, to: Coordinate)
}


Measured memory_bytes: 85648
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define sz(v) (ll)v.size()
#define inf 1000000000000000000
#define vll vector<ll>
using namespace std;
const int N=500005;

void solve()
{
	ll n,k;
	cin>>n>>k;
	if(k==1)
		cout<<0;
	else
		cout<<n-k;
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using namespace std;
const ll INF = 1ll<<60;

int main(){
    ll n; cin >> n;
    vector<pair<ll,ll>> U, R, D, L;
    rep(i,n){
        ll x, y; char u;
        cin >> x >> y >> u;
        if(u == 'U') U.pb(make_pair(x,y));
        else if(u == 'R') R.pb(make_pair(x,y));
        else if(u == 'D') D.pb(make_pair(x,y));
        else if(u == 'L') L.pb(make_pair(x,y));
    }
    
    ll ans = INF;

    rep(count,4){
        // 正面衝突
        vector<vector<pair<ll,char>>> crash180(200200,vector<pair<ll,char>>());
        rep(i,(int)U.size()) crash180[U[i].first].pb(make_pair(U[i].second,'U'));
        rep(i,(int)D.size()) crash180[D[i].first].pb(make_pair(D[i].second,'D'));
        rep(i,200200){
            sort(all(crash180[i]));
            rep(j,(int)crash180[i].size()-1)
                if(crash180[i][j].second == 'U' && crash180[i][j+1].second == 'D')
                    chmin(ans,(crash180[i][j+1].first-crash180[i][j].first)*5);
        }
        // 側面衝突
        vector<vector<pair<ll,char>>> crash90(400400,vector<pair<ll,char>>());
        rep(i,(int)U.size()) crash90[U[i].first+U[i].second].pb(make_pair(U[i].second,'U'));
        rep(i,(int)R.size()) crash90[R[i].first+R[i].second].pb(make_pair(R[i].second,'R'));
        rep(i,400400){
            sort(all(crash90[i]));
            rep(j,(int)crash90[i].size()-1)
                if(crash90[i][j].second == 'U' && crash90[i][j+1].second == 'R')
                    chmin(ans,(crash90[i][j+1].first-crash90[i][j].first)*10);
        }
        // 座標変換
        vector<pair<ll,ll>> NU, NR, ND, NL;
        rep(i,(int)U.size()) NR.pb(make_pair(U[i].second,200000-U[i].first));
        rep(i,(int)R.size()) ND.pb(make_pair(R[i].second,200000-R[i].first));
        rep(i,(int)D.size()) NL.pb(make_pair(D[i].second,200000-D[i].first));
        rep(i,(int)L.size()) NU.pb(make_pair(L[i].second,200000-L[i].first));
      swap(U,NU); swap(R,NR); swap(D,ND); swap(L,NL);
    }
    if(ans == INF) cout << "SAFE" << endl;
    else cout << ans << endl;
    return 0;
}

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VLL = vector<ll>;
using VD = vector<double>;
using VVI = vector<VI>;
using VVD = vector<VD>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

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

    int n;
    cin >> n;
    VPI work(n);
    REP(i, n)
    cin >> work[i].second >> work[i].first;
    sort(ALL(work));
    VLL endtime(n);
    endtime[0] = work[0].second;
    FOR(i, 1, n - 1) {
        endtime[i] = endtime[i - 1] + work[i].second;
    }

    bool ans = true;
    REP(i, n) {
        if (endtime[i] > work[i].first) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << ln;

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define MOD2 998244353
#define sp fixed<<setprecision
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll add(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD + b%MOD + MOD)%MOD;}
ll sub(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD - b%MOD + MOD)%MOD;}
ll mul(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return ((a%MOD)*(b%MOD) + MOD)%MOD;}
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (sz(name)) {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
const ll MAXN=300005;
ll dp[MAXN];
ll tree[4*MAXN];
void build(int v,int tl,int tr){
  if(tl==tr){
    tree[v]=dp[tl];
  }
  else{
    int tm=(tl+tr)/2;
    build(2*v,tl,tm);
    build(2*v+1,tm+1,tr);
    tree[v]=max(tree[2*v],tree[2*v+1]);
  }
}
int maxi(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return INT_MIN;
    if (l == tl && r == tr) {
        return tree[v];
    }
    int tm = (tl + tr) / 2;
    return max(maxi(v*2, tl, tm, l, min(r, tm)),maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
}
void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        tree[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        tree[v]=max(tree[2*v],tree[2*v+1]);
    }
}
int main(){
  //  setIO();
    for(int i=0;i<MAXN;i++)
      dp[i]=0;
    build(1,0,MAXN-1);
    ll n,k;
    cin>>n>>k;
    ll res=1;
    for(int i=0;i<n;i++){
      ll x;
      cin>>x;
      //cout<<"hi\n";
      ll max_par=maxi(1,0,MAXN-1,max(x-k,0LL),min(x+k,MAXN-1));
      max_par++;
      //cout<<"hi2\n";
      res=max(res,max_par);
      update(1,0,MAXN-1,x,max_par);
      //cout<<"hi3\n";
    }
    cout<<res;
}


Measured memory_bytes: 14168
N,K = map(int,input().split())
H = list(map(int,input().split()))
H = [0]+H
dp = [[10**12]*(N+1) for _ in range(N+1)]
dp[0][0] = 0
for x in range(N+1):
    for y in range(1,N+1):
        for z in range(x):
            dp[x][y] = min(dp[x][y],dp[z][y-1]+max(H[x]-H[z],0))

ans = 10**12
for x in range(N+1):
    ans = min(dp[x][N-K],ans)

print(ans)

Measured memory_bytes: 42988
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+9;
const int mod=1e9+7;
#define ll long long 
int dp[N],ans[N];
vector<int>g[N];
int siz[N];
int n;
int frac[N],inv[N];
void init(){
    frac[0]=frac[1]=inv[0]=inv[1]=1;
    for(int i=2;i<N;i++)frac[i]=1ll*frac[i-1]*i%mod,inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<N;i++)inv[i]=1ll*inv[i]*inv[i-1]%mod;
}
int C(int a,int b){return 1ll*frac[a]*inv[b]%mod*inv[a-b]%mod;}
void dfs1(int u,int fa){
   dp[u]=1;
   for(auto v:g[u]){
      if(v==fa)continue;
      dfs1(v,u);
      siz[u]+=siz[v];
      dp[u]=1ll*dp[v]*C(siz[u],siz[v])%mod*dp[u]%mod;
   }
   siz[u]++;
}
int ny(int a){
   if(a==1)return 1;
   else return 1ll*(mod-mod/a)*ny(mod%a)%mod;
}
void dfs2(int u,int fa){
   for(auto v:g[u]){
      if(v==fa)continue;
      dp[v]=1ll*dp[v]*C(n-1,n-siz[v])%mod*dp[u]%mod*ny(1ll*C(n-1,siz[v])*dp[v]%mod)%mod;
      dfs2(v,u);
   }
}
int main(){
   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
   init();
   cin>>n;
   for(int i=1,a,b;i<n;i++)cin>>a>>b,g[a].push_back(b),g[b].push_back(a);
   dfs1(1,0);dfs2(1,0);
   for(int i=1;i<=n;i++)cout<<dp[i]<<endl;
   return 0;
}

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

const int maxn = 500005;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int n, k;
int p[maxn], q[maxn], r[maxn], cnt;
int Min[maxn << 2];

#define mid ((l + r) >> 1)
#define lch (s << 1)
#define rch (s << 1 | 1)

void build(int s, int l, int r)
{
	Min[s] = n + 1;
	if (l == r) return ;
	build(lch, l, mid);
	build(rch, mid + 1, r);
}

void modify(int s, int l, int r, int p, int v)
{
	if (l == r) return Min[s] = v, void();
	if (p <= mid) modify(lch, l, mid, p, v);
	else modify(rch, mid + 1, r, p, v);
	Min[s] = min(Min[lch], Min[rch]);
}

int query(int s, int l, int r, int ql, int qr)
{
	if (ql <= l && r <= qr) return Min[s];
	int res = n + 1;
	if (ql <= mid) res = min(res, query(lch, l, mid, ql, qr));
	if (qr >= mid + 1) res = min(res, query(rch, mid + 1, r, ql, qr));
	return res;
}

struct edge
{
	int to, next;
} e[maxn << 1];
int h[maxn], deg[maxn], tot;

priority_queue<int> que;

void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]}; h[u] = tot;
	++deg[v];
}

int main()
{
	n = gi(); k = gi();
	for (int i = 1; i <= n; ++i) q[p[i] = gi()] = i;
	build(1, 1, n);
	for (int i = n, x; i >= 1; --i) {
		x = query(1, 1, n, max(1, q[i] - k + 1), q[i]);
		if (x <= n) add(q[x], q[i]);
		x = query(1, 1, n, q[i], min(n, q[i] + k - 1));
		if (x <= n) add(q[x], q[i]);
		modify(1, 1, n, q[i], i);
	}

	for (int i = 1; i <= n; ++i)
		if (!deg[i]) que.push(i);
	int u;
	while (!que.empty()) {
		r[++cnt] = u = que.top(); que.pop();
		for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
			if (!(--deg[v])) que.push(v);
	}
	reverse(r + 1, r + n + 1);
	for (int i = 1; i <= n; ++i) p[r[i]] = i;
	for (int i = 1; i <= n; ++i) printf("%d\n", p[i]);
	
	return 0;
}



Measured memory_bytes: 27384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    int total = 0;
    ll ans = 0;
    
    rep(i, N) {
        cin >> A[i];
        total += A[i];
    }
    
    vector<vector<ll>> dp(N + 1, vector<ll>(total + 1, INT_MIN));
    dp[0][0] = 1;
    
    rep(i, N) {
        rep(ii, total - A[i] + 1) {
            if (dp[i][ii] == INT_MIN) {
                continue;
            }
            
            dp[i + 1][ii] = ((dp[i + 1][ii] == INT_MIN) ? dp[i][ii] : dp[i][ii] + dp[i + 1][ii]);
            
            if (dp[i + 1][ii + A[i]] == INT_MIN) {
                dp[i + 1][ii + A[i]] = dp[i][ii];
            }
            else {
                dp[i + 1][ii + A[i]] = dp[i + 1][ii + A[i]] + dp[i][ii];
            }
        }
    }
    
    rep(i, total + 1) {
        if (((i % 2) == P) && (dp[N][i] != INT_MIN)) {
            ans += dp[N][i];
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        String ans = "No";
        
        for(int i = 1; i <= 9; i++){
            for(int j = 1; j <= 9; j++){
                if(n == i * j){
                    ans = "Yes";
                    break;
                }
            }
        }
        
        out.println(ans);
        out.close();
        
    }
}

Measured memory_bytes: 32780
#include <stdio.h>

using namespace std;

void output(int H[3][10]){
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			printf(" %d",H[i][j]);
		}
		printf("\n");
	}
}


int main(){
	int H1[3][10],H2[3][10],H3[3][10],H4[3][10],n,h_num,f_num,r_num,div_num;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			H1[i][j] = H2[i][j] = H3[i][j] = H4[i][j] = 0;
		}
	}
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d",&h_num,&f_num,&r_num,&div_num);
		switch(h_num){
		case 1:
			H1[f_num-1][r_num-1] += div_num;
			break;
		case 2:
			H2[f_num-1][r_num-1] += div_num;
			break;
		case 3:
			H3[f_num-1][r_num-1] += div_num;
			break;
		case 4:
			H4[f_num-1][r_num-1] += div_num;
			break;
		}
	}

	output(H1);
	printf("####################\n");
	output(H2);
	printf("####################\n");
	output(H3);
	printf("####################\n");
	output(H4);

}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)

int main() {
	int n,in;
	ll ans = 0;
	vi a,b;
	cin >> n;
	rep(i, n) {
		cin >> in;
		a.pb(in);
	}
	cin >> n;
	rep(i, n) {
		cin >> in;
		b.pb(in);
	}
	sort(a.begin(), a.end());
	rep(i, n) {
		if (binary_search(a.begin(), a.end(), b[i]))ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3556
namespace ABC131.C
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;




    public class Program
    {

        public static void Main(string[] args)
        {
            var l = ReadInputsAsLong().ToArray();
            WriteLine(Solve(l[0], l[1], l[2], l[3]));

        }
        public static long Solve(long a, long b, long c, long d)
        {
            //2 3|4 5 6 7 8 9
            //^   ^   ^   ^
            long divisor_c = b / c - (a - 1) / c;
            long divisor_d = b / d - (a - 1) / d;
            var lcm = LCM(d, c);
            long divisor_cd = b / (lcm) - (a - 1) / (lcm);

            return (b - a + 1) - divisor_c - divisor_d + divisor_cd;
        }
        public static long LCM(long a, long b)
        {
            return a * b / (GCD(a, b));
        }
        public static long GCD(long a, long b)
        {
            var r = a % b;
            while (r > 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        public static long _Solve(long a, long b, long c, long d)
        {
            long count = 0;
            for (long i = a; i <= b; i++)
            {
                if (i % c != 0 && i % d != 0) count++;
            }
            return count;
        }


        static IEnumerable<long> ReadInputsAsLong() => ReadLine().Split(' ').Select(x => long.Parse(x));

    }
}


Measured memory_bytes: 13396
import sys
rr = lambda: sys.stdin.readline().strip()
rri = lambda: int(rr())
rrs = lambda: [int(_) for _ in rr().split()]

from operator import itemgetter

N = rri()
data = [[i + 1] + rr().split() for i in range(N)]

for d in data:
	d[2] = int(d[2])

data.sort(key=itemgetter(2), reverse=True)
data.sort(key=itemgetter(1))

for d in data:
	print(d[0])

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
#include<regex>
#include<numeric>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	double v,t,y,N;
	int n;
	
	while(scanf("%lf",&v)!=EOF){
		t = v/9.8;
		y = 4.9*t*t;
		N = (y+5)/5;
		n = (int)N;
		if(n==N)
		printf("%d\n",n);
		else
		printf("%d\n",n+1);
	}
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A, A + N);
    int prev = -1;
    for (int i = 0; i < N; i++)
    {
        if (prev == A[i])
        {
            cout << "NO" << endl;
            return 0;
        }
        prev = A[i];
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1024
// Problem : C - Lining Up
// Contest : AtCoder Beginner Contest 050
// URL : https://atcoder.jp/contests/abc050/tasks/arc066_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T, size_t N> ostream& operator << (ostream &os, const array<T, N> &a) {os << "("; for (int i=0; i<(int)N; i++) {if (i) os << ", "; os << a[i];} return os << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

#define MOD 1000000007

int a[100000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> a[i];
    
    sort(a, a + n);
    bool ok = true;
    int power = 1;
    if (n % 2) {
        for (int i=0; i<n; i+=2) {
            ok &= a[i] == i && (i == 0 || a[i-1] == i);
            if (i > 0) power = power * 2 % MOD;
        }
    } else {
        for (int i=0; i<n; i+=2) {
            ok &= a[i] == i + 1 && a[i+1] == i + 1;
            power = power * 2 % MOD;
        }
    }
    
    cout << (ok ? power : 0) << "\n";

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

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

  int ans = 0;
  for(int i = 0; i < N; i++){
    int h, w;
    cin >> h >> w;
    if(H <= h && W <= w) ans++;
  }
  
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
head, tail = map(int, input().split())
flag=True
for i in range(m-1):
    l,r = map(int, input().split())
    if head<l and l<=tail:
        head=l
    elif l>tail:
        flag=False
        break
    if tail>r and head<=r:
        tail = r
    elif r<head:
        flag=False
        break
print(tail-head+1 if flag==True else 0)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	ll n2 = 1<<n;
	multiset<ll> s;
	s.ins(-1);
	rep(i, n2){
		ll temp; cin>>temp;
		s.ins(temp);
	}
	vll u;
	auto itr=s.end(); itr--;
	u.pb(*itr);
	s.erase(itr);
	rep(i, n){
		vll v = u;
		sort(v.begin(), v.end());
		while(v.size()){
			ll par = v.back();
			auto it = s.lower_bound(par); it--;
			if (*it == -1){
				cout << "No\n";
				return 0;
			}
			u.pb(*it);
			v.pop_back();
			s.erase(it);
		}
	}
	cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 15852
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

P = mymath.pnum_eratosthenes(105000)

while True:
    N = int(input())

    if N == 0:
        break

    print(sum(P[:N]))

    


Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{int N, M;
 cin >> N >> M;
 vector<int> L(M);
 vector<int> R(M);
 
 rep(i,M) cin >> L.at(i) >> R.at(i);
 int l = 0;
 int r = 100010;
 rep(i,M) {
   l = max (l,L.at(i));
   r = min (r,R.at(i));
 }
 int ans = r-l+1;
 if ( l > r) ans = 0;
 
 cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    string s,t;
    int i,flag=0;
    cin>>s>>t;
    for(i=0;i<s.size();i++){
      if(s[i]!=t[i]){
        flag=1;
        break;
      }
    }
      if(flag)
        cout<<"No"<<endl;
      else
        cout<<"Yes"<<endl;
    
  }


Measured memory_bytes: 3604
#include <stdio.h>

int main(){
	int a, b, c;
	int i;
	int cnt = 0;
	
	while( scanf("%d %d %d", &a, &b, &c) != EOF )

	for(i=a; i<=b; i++) {
		if(c%i == 0) cnt++;
	}

	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


class FermatCombination {
    private:
        llong *factrial;    //階乗を保持
        llong *inverse; //逆元を保持
        llong MOD;

    public:
        FermatCombination(int size, llong mod);
        ~FermatCombination();
        llong combine(int n, int k);
        llong pow(llong x, int n);
};
	
FermatCombination::FermatCombination(int size, llong mod) {
    this->factrial = new llong[size + 1];
    this->inverse = new llong[size + 1];
    this->MOD = mod;
    
    this->factrial[0] = 1;
    this->inverse[0] = 1;
    
    for (int i = 1; i <= size; i++) {
        factrial[i] = (factrial[i - 1] * i) % MOD;  //階乗を求める
        inverse[i] = pow(factrial[i], (int) MOD - 2) % MOD; // フェルマーの小定理で逆元を求める
    }
}

FermatCombination::~FermatCombination(){
    delete[] this->inverse;
    delete[] this->factrial;
}

llong FermatCombination::combine(int n, int k) {
    return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

llong FermatCombination::pow(llong x, int n) { //x^n 計算量O(logn)
    llong ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x % MOD;
        }
        x = x * x % MOD; //一周する度にx, x^2, x^4, x^8となる
        n >>= 1; //桁をずらす n = n >> 1
    }
    return ans;
}

int main(){
	const llong mod = (llong) pow(10,9)+7;
	int h, w, a, b;
	cin >> h >> w >> a >> b;

	llong tmp = max(b+h-a-1, h-1+w-b-1);
    FermatCombination *com = new FermatCombination(tmp, mod);

	llong ans=0;
	llong firptn, secptn;
	if(w-b==1){
		ans=com->combine(b+h-a-1, b);
	}else{
		REP(i, h-a-1){
			firptn = com->combine(b+i, i);
			//右にbマス進んだあと下に降りると重複するので強制的に右へ進むことにする
			secptn = com->combine((h-1-i)+(w-b-2), h-1-i);
			ans=(ans+(firptn*secptn)%mod)%mod;
		}
		firptn = com->combine(b+h-a-1, b);
		secptn = com->combine(w-b-1+a, a);
		ans=(ans+(firptn*secptn)%mod)%mod;
	}
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 3328
n, d = map(int, input().split())
if d == 1 and n%((d*2)+1) == 0:
    print(int(n/(d*2+1)))
elif d == 1:
    print(int(n/(d*2+1))+1)
elif d*2+1 >= n:
    print(1)
elif n%((d*2)+1) == 0:
    print(int(n/(d*2+1)))
else:
    print(int(n/(d*2+1))+1)

Measured memory_bytes: 38416
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	long long int x,i,j,ans=0;
	cin>>x;
  	
	for(i=1;i<=x;i++){
		for(j=2;j<=1000;j++){
			if(pow(i,j)>x)break;
			if(pow(i,j)<=x){
              long long int t=pow(i,j);
				ans=max(ans,t);
           
			}
		}
	}
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    Hs = list(map(int, input().split()))

    cnt = 0
    ans = 0
    [cnt for i in range(N-1)]
    for i in range(N-1):
        if Hs[i] >= Hs[i + 1]:
            cnt += 1
        else:
            if ans < cnt:
                ans = cnt
            cnt = 0
        if ans < cnt:
            ans = cnt
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 60004
import java.util.Scanner;

class Main {

  public static int min(int a, int b) {
    return a < b ? a : b;
  }

  public static int INF = Integer.MAX_VALUE / 4;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    scanner.close();
    int[] dp = new int[100010];
    dp[0] = 0;
    for (int n = 1; n < dp.length; n++) {
      dp[n] = INF;
      int power = 1;
      while (power <= n) {
        dp[n] = min(dp[n], 1 + dp[n - power]);
        power *= 6;
      }
      power = 1;
      while (power <= n) {
        dp[n] = min(dp[n], 1 + dp[n - power]);
        power *= 9;
      }
    }
    System.out.println(dp[N]);
  }

}


Measured memory_bytes: 23508
#include<iostream>
#define PI 3.141592653589
using namespace std;
 
int main(){
    int n;
    cin >>n;
    int a[100];
    for ( int i = 0; i < n; i++ ){
        cin>>a[i];
    }
 
     
    for ( int i = 0; i < n; i++ ){
        if (i!=0){cout << " ";}
        cout << a[n-i-1];
    }
    cout << endl;
     
    return 0;
}

Measured memory_bytes: 3072
while True:
    n,k = map(int,input().split())
    if (n,k) == (0,0):
        break
    a=[]
    for i in range(n):
        a.append(int(input()))
        c = 0
    for j in range(k):
        c += a[j]
        b = c
    for h in range(k,n):
        c += a[h]
        c -= a[h - k]
        b = max(b,c)
    print(b)


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long int n, d, cnt = 0;
	cin >> n >> d;
	for (int i = 0; i < n; ++i){
	long long int x, y;
	cin >> x >> y;
	if (x*x + y*y <= d*d) ++cnt;
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3672
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,a,b,x=0,y=0,z=0,p;
    scanf("%d%d%d",&n,&a,&b);
    for(int i=0;i<n;i++){
        scanf("%d",&p);
        if(p<=a){
            x++;
        }
        else if(p<=b){
            y++;
        }
        else{
            z++;
        }
    }
    int ans=min(x,y);
    printf("%d\n",min(ans,z));
}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int A,B;
	cin>>A>>B;
	int ans=0;
	if(A>B)
	{
		ans=ans+A;
		A--;
	}
	else
	{
		ans=ans+B;
		B--;
	}
	if(A>B)
	{
		ans=ans+A;
		A--;
	}
	else
	{
		ans=ans+B;
		B--;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0582
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0; int b = 0; int c = 0; int d = 0;
            while (true)
            {
                string s = Console.ReadLine();
                int[] x = s.Split().Select(int.Parse).ToArray();
                Array.Sort(x);
                if (x[0] + x[1] > x[2])
                {
                    a++;
                    int y = x[0] * x[0] + x[1] * x[1];
                    int z = x[2] * x[2];
                    if (y == z) b++;
                    else if (y > z) c++;
                    else d++;
                }
                else break;
            }
            Console.WriteLine(a + " " + b + " " + c + " " + d);
        }
    }
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
const int MOD=1e9+7;
signed main(){
	string s;
	cin>>s;
	int n=s.size();
	int k;
	cin>>k;
	set<string> so;
	rep(i,n){
		rep(j,k){
			if(i+j<n)so.insert(s.substr(i,j+1));
		}
	}
	auto itr=so.begin();
	rep(i,k-1)++itr;
	cout<<*itr<<endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int W, H, N;
	cin >> W >> H >> N;
	vector<int> x(N), y(N), a(N);
	int W1 = 0; int W2 = W;
	int H1 = 0; int H2 = H;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> a[i];
		if (a[i] == 1) {
			W1 = max(W1, x[i]);
		}
		else if (a[i] == 2) {
			W2 = min(W2, x[i]);
		}
		else if (a[i] == 3) {
			H1 = max(H1, y[i]);
		}
		else {
			H2 = min(H2, y[i]);
		}
	}
	int WW = 0; int HH = 0;
	if (W2 - W1 < 0) {
		WW = 0;
	}
	else {
		WW = W2 - W1;
	}
	if (H2 - H1 < 0) {
		HH = 0;
	}
	else {
		HH = H2 - H1;
	}
	cout << WW * HH << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
  public static void main(String arg[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String inps[] = br.readLine().split(" ");
    int n = Integer.parseInt(inps[0]);
    int m = Integer.parseInt(inps[1]);
    String grid[] = new String[n];
    for(int i=0;i<n;i++)
      grid[i] = br.readLine();
    int curr = 1;
    long dp[][] = new long[n][m];
    for(int i=0;i<n;i++){
      if(grid[i].charAt(0) == '#')
        curr = 0;
      dp[i][0] = curr;
    }
    curr = 1;
    for(int i=0;i<grid[0].length();i++){
      if(grid[0].charAt(i) == '#')
        curr = 0;
      dp[0][i] = curr;
    }
    long md = (long)1e9 + 7;
    for(int i=1;i<n;i++){
      for(int j=1;j<m;j++){
        if(grid[i].charAt(j)!='#')
          dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % md;
        else
          dp[i][j] = 0;
      }
    }
    System.out.println(dp[n-1][m-1]);
  }
}
      
    	

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

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

using ll = long long;

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

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

int main(){
  ll N,M;
  cin>>N>>M;
  vector<vector<ll>> v(8,vector<ll>(N));
  for(ll i = 0LL; i < N; i++) {
    vector<ll> x(3);
    cin>>x[0]>>x[1]>>x[2];
    rep(j,8){
      ll t = 0LL;
      rep(k,3){
        if(j&(1<<k))t-=x[k];
        else t+=x[k];
      }
      v[j][i]=t;
    }
  }
  ll ans = 0LL;
  rep(i,8){
    sort(v[i].begin(),v[i].end());
    reverse(v[i].begin(),v[i].end());
  }
  rep(i,8){
    ll t = 0LL;
    for(ll j = 0LL; j < M; j++){
      t+=v[i][j];
    }
    chmax(ans,t);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,r=map(int,input().split())
if n >=10:
  print(r)
else:
  print(r+100*(10-n))


Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong K = 0;
            ulong money = 100;

           K = ulong.Parse(Console.ReadLine());
            int i;
            for (i = 0; money<K; i++)
            {
                money = (ulong)(money * 1.01); 
            }
            Console.WriteLine("{0}", i);
        }            
    }
}


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

int main()
{
  int n;
  cin>>n;
  vector<int> v(n);
  for(auto &i:v) cin>>i;
  long long ansq=1e17;
  for(int x=0;x<2;x++)
  {
    int h=x;
    long long int sum=0,ans=0;
    for(int i=0;i<n;i++)
    {
      sum+=v[i];
      if(h)
      {
        if(sum<=0)
         { ans+= abs(1-sum); sum=1;}
          
      }
      else
      {
        if(sum>=0)
        {
          ans+=abs(sum+1);
          sum=-1;
        }
      }
      h = h^1;
    }
    ansq=min(ansq,ans);
  }
  cout<<ansq<<"\n";
  
  return 0;
}


Measured memory_bytes: 640
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  sort(all(A));

  vector<int> sum(N);
  rep(i, N) {
    sum[i] = (i == 0 ? 0 : sum[i - 1]) + A[i];
  }

  int ans = 1;
  repr(i, N - 2, 0) {
    if (sum[i] * 2 >= A[i + 1])
      ans++;
    else
      break;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  string s;
  cin >> s;

  string t = s.substr(N);
  s = s.substr(0, N);

  reverse(ALL(t));

  map<pair<string, string>, int> m1, m2;

  REP(bit, (1<<N)){
    string a, b, c, d;
    REP(i, N){
      if((bit >> i)&1){
        a += s[i];
        c += t[i];
      }
      else{
        b += s[i];
        d += t[i];
      }
    }
    m1[make_pair(a, b)]++;
    m2[make_pair(c, d)]++;
  }

  int ans = 0;
  for(auto p : m1){
    ans += m2[p.first]*p.second;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 108288
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,x=0,y=0,i,j,k,aa,bb,z;
    cin>>aa>>bb;
    if(aa==1)
    {
        x=x+300000;
    }
    else if(aa==2)
    {
        x=x+200000;
    }
    else if(aa==3)
    {

        x=x+100000;

    }

    if(bb==1)
    {
        x=x+300000;
    }
    else if(bb==2)
    {
        x=x+200000;
    }
    else if(bb==3)
    {

        x=x+100000;

    }
    if(aa==1 && bb==1)
    {
        x=x+400000;
    }
    cout<<x<<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int a[2010], b[2010];

int main(void)
{
	int N;
	cin >> N;
	ll x;
	cin >> x;

	ll ans = 1LL<<60;
	for (int i = 0; i < N; i++)
		cin >> a[i];
	for (int i = 0; i < N; i++)
		b[i] = a[i];
	for (int k = 0; k < N; k++) {
		ll num = k * x;
		for (int i = 0; i < N; i++) {
			b[i] = min(b[i], a[(i - k + N) % N]);
		}
		for (int i = 0; i < N; i++) {
			num += b[i];	
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstddef>

using ui32 = std::uint32_t;
using ui = ui32;
using ui64 = std::uint64_t;


int main(){

	ui32 n, m;
	std::cin >> n >> m;

	std::priority_queue<ui64> stuffs;
	for( ui32 i{}; i < n; ++i )
	{
		ui64 t;
		std::cin >> t;
		stuffs.push( t );
	}


	for( ui32 i{}; i < m; ++i )
	{
		const auto expensive = stuffs.top();
		stuffs.pop();

		stuffs.push( expensive / 2 );
	}

	ui64 ans{};
	while( !stuffs.empty() )
	{
		ans += stuffs.top(); stuffs.pop();
	}

	std::cout << ans << "\n";

	return 0;
}

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


int main() {
    int n; cin >> n;
    vector<int> divisors(n + 1);
    
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            divisors[j]++;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) ans += (ll)i * divisors[i];
    cout << ans;
    return 0;
}


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

int main() {
  int a = 0 ;
   string S ;
  cin >> S ;
    if(S=="SUN") a = 0  ;
    if(S=="MON") a = 1  ;
    if(S=="TUE") a = 2  ;
    if(S=="WED") a = 3  ;
    if(S=="THU") a = 4  ;
    if(S=="FRI") a = 5  ;
    if(S=="SAT") a = 6  ;
  
  cout << 7 - a << endl;
}



Measured memory_bytes: 256