akhauriyash/Code-Regression huggingface dataset:
/*

????????? ???????????? ????????????
?§???????????????¢????????¢???????????£??????(AiZu AnalyticS)???????\??§?????????????????§??????????
???????????????????????£?????????????????? N ????????????1 ?????? N ????????\????????????????????????
?????????AZAS ?????±?????\?????????????????§?????????????????????????????????????????????????????\??????
?????¶????°?????????¨?????????????????????????????°????????????????????¨????????????

??? ?????????????±???????????????????????????£???????????????????????????
??? ????????¢????±????????????????????????£???????????????????????????

??????
?????????????±???????????????????????????¢????±???????????????????????????£??????????????????????????????
??\???????????\?????¨???????????????????????¨???????????¶???????????????????????°???????????????????????°
?????????????????????????????????????????????????????¶???????????????????????????????????°???????????????
?????¨????????????

????£??¶????????¨?????????¶???????????????
	?????????????????§????????¶??°?????????????????????????????????????´??????????????????????????????¢???
	??£??¨??????????????¶???????????????????????°??????(A? ??? C) ??? (B ??? C??????????????????
	?????¨??? ) )????????????????´?????????°??§?????????????????????A?????????????????£?????????¨?????????

??\???
??\????????\????????¢?????§??????????????????

N
X a1 a2 ??? aX
Y b1 b2 ??? bY
Z c1 c2 ??? cZ

??\??????????????§?????????
	??????????????????????±?????????°N(1???N???100)?????????????????????
	????????????????????????????±?????????????????????°X(0???X???N)??¨???
		??????????¶????????????????????±????????????????????????\??????ai(1???ai???N)?????????????????????
	???????????????????????¢????±?????????????????????°Y(0???Y???N)??¨???
		??????????¶???????????????¢????±????????????????????????\??????bi(1???bi???N)?????????????????????
	???????????????????????£?????????????????????????????°Z(0???Z???N)??¨???
		??????????¶???????????????£????????????????????????????????\??????ci(1???ci???N)?????????????????????

??????
?????¶???????????????????????°???????????????????????????

*/

#include <stdio.h>

#define NUM 100

int main( void )
{
	int n;						// ??????????±?????????°N(1???N???100)
	int d[ 100 ][ 3 ];			// 2???4??????????????????
	int t = 0;					// ?????¶????????´???????????°
	int i, j;
	int w, m;

	scanf("%d ", &n );

	for ( i = 0 ; i < n ; i++) {
		d[ i ][ 0 ] = 0;
		d[ i ][ 1 ] = 0;
		d[ i ][ 2 ] = 0;
	}

	for ( j = 0 ; j < 3 ; j++) {
		scanf("%d ", &m );
		for ( i = 0 ; i < m ; i++) {
			scanf("%d ", &w );
			d[ w - 1 ][ j ] = 1;
		}
	}

	t = 0;
	for ( i = 0 ; i < n ; i++) {
		if ( ( ( d[ i ][ 0 ] == 0 ) && ( d[ i ][ 2 ] == 1 ) ) ||
			 ( ( d[ i ][ 1 ] == 1 ) && ( d[ i ][ 2 ] == 1 ) ) ) {
			t++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <math.h>
using namespace std;
double helon(double x1,double y1,double x2,double y2,double x3,double y3){
	double a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	double b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
	double c=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
	double z=(a+b+c)/2.0;
	double s=sqrt(z*(z-a)*(z-b)*(z-c));
	return s;
}
int main(){
	vector<double> x,y;
	double a,b,s,sum=0;
	while(scanf("%lf,%lf",&a,&b)!=EOF){
		x.push_back(a);
		y.push_back(b);
	}
	for(int i=1;i<x.size()-1;i++){
		s=helon(x[0],y[0],x[i],y[i],x[i+1],y[i+1]);
		sum+=s;
	}
	printf("%.6lf\n",sum);
	return 0;
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

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

    vector<int> A(S+1,0);
    rep(n,S+1) {
        if (n<3) A[n]=0;
        else if (n==3) A[n]=1;
        else {
            int tmp = 1;
            rep(j,n-3+1) {
                tmp += A[j];
                tmp %= MOD;
            }
            A[n] = tmp;
        }
    }
    cout << A[S] << endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  if (k == 1) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << n - k << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
set<string> s;
int main()
{
    int t;
    string cur;
    for (read(t); t--;)
    {
        cin >> cur;
        s.insert(cur);
    }
    printf("%d\n", SZ(s));
}

Measured memory_bytes: 19348
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200005
#define Pii pair<int, int>
#define fi first
#define se second
#define mk make_pair
using namespace std;
typedef long long ll;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

ll ans;
int n, pl[2][N], pr[2][N], sl[2][N], sr[2][N];
Pii p[N];

int main(){
	n = read();
	for(int i = 1; i <= n; i++){
		int x = read(), y = read();
		if(x > y) swap(x, y);
		p[i] = mk(x, y);
	}
	sort(p + 1, p + n + 1);
	pl[0][1] = pl[1][1] = p[1].fi;
	pr[0][1] = pr[1][1] = p[1].se;
	for(int i = 2; i <= n; i++)
		pl[0][i] = min(pl[0][i - 1], p[i].fi), pl[1][i] = max(pl[1][i - 1], p[i].fi),
		pr[0][i] = min(pr[0][i - 1], p[i].se), pr[1][i] = max(pr[1][i - 1], p[i].se);
	sl[0][n] = sl[1][n] = p[n].fi;
	sr[0][n] = sr[1][n] = p[n].se;
	for(int i = n - 1; i ; i--)
		sl[0][i] = min(sl[0][i + 1], p[i].fi), sl[1][i] = max(sl[1][i + 1], p[i].fi),
		sr[0][i] = min(sr[0][i + 1], p[i].se), sr[1][i] = max(sr[1][i + 1], p[i].se);
	ans = 1LL * (sl[1][1] - sl[0][1]) * (sr[1][1] - sr[0][1]);
	for(int i = 1; i < n; i++){
		int rmax = max(pl[1][i], sr[1][i + 1]);
		int rmin = min(pl[0][i], sr[0][i + 1]);
		int bmax = max(pr[1][i], sl[1][i + 1]);
		int bmin = min(pr[0][i], sl[0][i + 1]);
		ans = min(ans, 1LL * (rmax - rmin) * (bmax - bmin));
	}
	printf("%lld\n", ans);
}

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int L[2200];
int cnt[1100], imos[1100];
signed main() {
    cin >> N;
    rep(i, N) {
        cin >> L[i];
        cnt[L[i]]++;
    }
    for (int i = 1; i < 1100; i++) { imos[i] = cnt[i] + imos[i - 1]; }
    int ans = 0;
    rep(i, 1100) {
        rep(j, i) {
            if (i >= j + j) { continue; }
            ans += cnt[i] * cnt[j] * (imos[j - 1] - imos[i - j]);
            ans += max(0LL, cnt[i] * cnt[j] * (cnt[j] - 1) / 2);
        }
        dump(ans);
        ans += max(0LL, cnt[i] * (cnt[i] - 1) / 2 * imos[i - 1]) + max(0LL, cnt[i] * (cnt[i] - 1) * (cnt[i] - 2) / 6);
        dump(ans);
        cerr << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc080_a.cpp
 * time   : Wed Apr 29 22:56:37 2020
 * quest  : A - Parking
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << "\n";
  return 0;
}


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

using namespace std;

typedef long long ll;

const int mod = 998244353, N = 200010;

ll fac[N], p[N];
ll inv[N];

ll mod_mult(ll a,ll b,ll m){  //计算 a*b
    ll res = 0;
    ll exp = a % m;
    while(b){
        if (b&1){
            res += exp;
            if (res > m) res -= m;
        }
        exp<<=1;
        if (exp > m) exp -= m;
        b>>=1;
    }
    return res;
}


ll mod_exp(ll a,ll b,ll m){
    ll res = 1;
    ll exp = a % m;
    while(b){
        if (b & 1) res = mod_mult(res,exp,m);
        exp = mod_mult(exp,exp,m);
        b>>=1;
    }
    return res;
}

ll C(int x, int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int main(){
	long long n, m, k;
	scanf("%lld%lld%lld",&n,&m,&k);

	long long ans = 0;


	fac[0] = 1;
    for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
    inv[n] = mod_exp(fac[n], mod - 2, mod);
    for (int i = n ; i >= 0; i--) inv[i - 1] = 1ll * inv[i] * i % mod;
    p[0] = 1;
	for (int i = 1; i <= n; i++){
		p[i] = p[i - 1] * (m - 1) %mod;
	}
	for (int i = 0; i <= k; i++){
		long long num =  C(n-1,i) % mod * p[n - i - 1] % mod;
		ans = (ans + num) % mod;
	}
	
	printf("%lld\n",ans * m % mod);

	return 0;
}

Measured memory_bytes: 8444
def inv(x):
    return pow(x, mod - 2, mod)


N, A, B, C = map(int, input().split())
mod = 10 ** 9 + 7
comb = [(1, 1)]
for i in range(N - 1):
    comb.append((comb[i][0] * (N + i) % mod, comb[i][1] * (i + 1) % mod))
comb = [x * inv(y) for x, y in comb]

a = A * inv(A + B) % mod
b = B * inv(A + B) % mod
c = 100 * inv(100 - C)

an = [1, a]
bn = [1, b]
for i in range(N - 1):
    an.append(an[i + 1] * a % mod)
    bn.append(bn[i + 1] * b % mod)
    
ans = 0
for i in range(N):
    t = (i + N) * comb[i] * (an[-1] * bn[i] + bn[-1] * an[i]) % mod
    ans = (ans + t) % mod
ans = ans * c % mod
print(ans)


Measured memory_bytes: 20576
// ------------------------------------
// Date:2018/ 2/28
// Problem:ABC 054 OneStrokePath c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int N, M;
bool line[8][8];
int p[8];

int main()
{
  memset(line , false, sizeof(line));
  int s,t;
  cin >> N >> M;
  REP(i, M) {
    cin >> s >> t;
    --s;
    --t;
    line[s][t] = true;
    line[t][s] = true;
  }
  
  REP(i, N) p[i] = i;
  
  bool ok;
  int cnt = 0;
  do {
    ok = true;
    // 始点が0以外はスルーする
    if (p[0] != 0) continue;
    REP(i, N - 1) {
      if (!line[p[i]][p[i+1]]) ok = false;
      if (ok && i == N - 2) ++cnt;
    }
  } while(next_permutation(p, p+N)); // 辞書式配列に並べ換えるライブラリ関数
  cout << cnt << endl;
  
  return 0;
}



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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> A(N);

    int sum = 0;
    REP(i,N){
        cin >> A[i];
        sum += A[i];
    }

    vector<int> div;
    FOR(i,1,(int)sqrt(sum)+ 1){
        if (sum%i == 0){
            div.push_back(i);
            if(i != sum/i){
                div.push_back(sum/i);
            }
        }
    }
    sort(ALL(div), greater<int>());

    REP(i,div.size()){
        vector<int> a;
        int d = div[i];
        REP(j,N){
            if (A[j] % d != 0){
                a.push_back(A[j] % d);
            }
        }
        sort(ALL(a));


        vector<int> s(a.size()+1);
        vector<int> sr(a.size()+1);

        s[0] = 0;
        sr[a.size()] = 0;


        REP(x, a.size()){
            s[x+1] = s[x] + a[x];
        }

        REP(x, a.size()){
            sr[a.size()-x-1] = sr[a.size()-x] + a[a.size()-x-1] - d;
        }

        REP(x, a.size()+1){
            if(s[x] + sr[x] == 0 && s[x]<=K){
                cout << d << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, e = 0, o = 0, i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    if (i % 2)
      o++;
    else
      e++;
  }
  cout << (o * 1.0) / n << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int w[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
	int y,r,m,d;
	while(true){
	cin>>y>>m>>d;
	bool t=true,u=false;
	if(y<0||m<0||d<0)
		t=false;
	if(y%4==0){
		u=true;
		if(y%100==0)
			u=false;
		if(y%400==0)
			u=true;
	}
	int ans=-d;
	for(int i=0;i<m-1;i++){
		ans-=w[i];
		if(u==true&&i==1)
			ans--;
	}
	cin>>r>>m>>d;
	if(r<0||m<0||d<0)
		t=false;
	if(t==false)
		break;
    u=false;
	if(r%4==0){
		u=true;
		if(r%100==0)
			u=false;
		if(r%400==0)
			u=true;
	}
	ans+=d;
	for(int i=0;i<m-1;i++){
		ans+=w[i];
		if(u==true&&i==1)
			ans++;
	}
	for(int i=y;i<r;i++){
		u=false;
	    if(i%4==0)
		    u=true;
		if(i%100==0)
		    u=false;
		if(i%400==0)
		    u=true;
		ans+=365;
		if(u==true)
			ans++;
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>

int main()
{
  using namespace std;
  
  typedef uint64_t Long;
  Long N;
  
  cin >> N;
  
  Long i_, j_;
  
  for(Long i = (int)sqrt(N); i > 0; --i)
  {
    if(N % i == 0)
    {
      i_ = i;
      j_ = N / i;
      break;
    }
  }
  
  cout << i_ + j_ - 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define For(i,j,k) for(Rint i=(j),i##end=(k);i<=i##end;i++)
#define Fordown(i,j,k) for(Rint i=(j),i##end=(k);i>=i##end;i--)
#define Travel(i,u,v) for(Rint i=beg[u],v=to[i];i;i=nex[i],v=to[i])

using namespace std;
typedef long long LL;

template<typename T>inline void read(T &x){
	x=0;T w=1,ch=getchar();
	while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
	x=x*w;
}

#define pb push_back

const int N=1e5+10,M=N<<1;
int n,a[N],b[N];
int ta[N],tb[N];

int ls[M],tot;
int fa[M];
bool vis[M];

inline int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}

int main(){
//	File("duliu");
	read(n);n++;
	For(i,1,n-1)read(a[i]),a[n]^=a[i];
	For(i,1,n-1)read(b[i]),b[n]^=b[i];

	For(i,1,n)ta[i]=a[i],tb[i]=b[i];
	sort(ta+1,ta+n+1);sort(tb+1,tb+n+1);
	For(i,1,n)if(ta[i]!=tb[i]){printf("-1\n");return 0;}

	For(i,1,n)ls[++tot]=a[i],ls[++tot]=b[i];
	sort(ls+1,ls+tot+1);
	tot=unique(ls+1,ls+tot+1)-ls-1;
	For(i,1,tot)fa[i]=i;
	For(i,1,n){
		a[i]=lower_bound(ls+1,ls+tot+1,a[i])-ls;
		b[i]=lower_bound(ls+1,ls+tot+1,b[i])-ls;
		int x=find(a[i]),y=find(b[i]);
		if(x!=y)fa[x]=y;
	}

	int Ans=0,sum=0;
	For(i,1,n-1)if(a[i]!=b[i])Ans++,vis[a[i]]=vis[b[i]]=1;
        vis[a[n]]=vis[b[n]]=1;
	For(i,1,tot)if(vis[i]&&find(i)==i)sum++;
	if(sum>0)sum--;
	printf("%d\n",Ans+sum);
	return 0;
}

Measured memory_bytes: 3968
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
s = []
d = []
for i in range(0,n,2):
    s.append(a[i])
for j in range(1,n,2):
    d.append(a[j])
print(sum(s)-sum(d))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum = 0;
  int ans = 0;
  for(int i = 0;i < n; i++) {
    int x = (a[i] * (sum % Mod)) % Mod;
    ans += x;
    ans = ans % Mod;
    sum += a[i];
  }
  cout << ans << '\n';
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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; }

int main() {
  ll n, k;
  cin >> n >> k;
  n %= k;
  ll ans = n;
  n -= k;
  n *= -1;
  chmin(ans, n);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[10000],a[300000], b[300000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<vector<Edge>>vec;
vector<LL>v[100000];
map<Pll,LL>ma;
multiset<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	if (n == 2) {
		cout << abs(a[0] - a[1]) << endl;
		return 0;
	}
	sort(a, a + n);
	deque<LL>deq;
	deq.push_back(a[n-1]);
	deq.push_back(a[0]);
	deq.push_front(a[1]);
	LL bef = 2, aft = n - 2;
	while(1) {
		if (bef > aft)break;
		deq.push_back(a[aft]);
		aft--;
		if (bef> aft)break;
		deq.push_front(a[aft]);
		aft--;
		if (bef > aft)break;
		deq.push_back(a[bef]);
		bef++;
		if (bef > aft)break;
		deq.push_front(a[bef]);
		bef++;
	}
	LL cur = -1,mem=0;
	while (!deq.empty()) {
		if (cur != -1) {
			mem += abs(cur - deq.front());
		}
		cur = deq.front();
		deq.pop_front();
	}
	ans = mem;

	deq.push_back(a[0]);
	deq.push_front(a[n-1]);
	deq.push_back(a[n-2]);
	 bef = 1, aft = n - 3;
	while (1) {
		if (bef> aft)break;
		deq.push_back(a[bef]);
		bef++;
		if (bef > aft)break;
		deq.push_front(a[bef]);
		bef++;
		if (bef > aft)break;
		deq.push_front(a[aft]);
		aft--;
		if (bef > aft)break;
		deq.push_back(a[aft]);
		aft--;
	
	}
	cur = -1, mem = 0;
	while (!deq.empty()) {
		if (cur != -1) {
			mem += abs(cur - deq.front());
		}
		cur = deq.front();
		deq.pop_front();
	}
	ans = max(ans,mem);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7168
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
ll n,h;cin>>n>>h;
ll a[h];ll sum=0;
rep(i,h){
 cin>>a[i];
 sum+=a[i];
}
if(sum>=n)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
ll n,m,i,j,k,l,t,arr[sz],brr[sz];
map<ll,ll>mp,mp1;
int main()
{
    arr[1]=0;
    arr[2]=1;
    for(i=3;i<=200000;i++)
        arr[i]=(i*(i-1))/2;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&brr[i]);
        mp[brr[i]]++;
    }
    for(auto &it:mp)
    {
        ll x,y;
        x=it.first;
        y=it.second;
        j=arr[y];
        m+=j;
    }
    for(i=0;i<n;i++)
    {
        ll x=mp[brr[i]];
        ll y=arr[x-1];
        j=m-arr[x]+arr[x-1];
        printf("%lld\n",j);

    }
    return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}

const int maxn=1e6;
//const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int arr[maxn];
ll fac[maxn+1];
ll mul(ll a,ll b){
    ll ans=0;
    while(b){
        if(b&1) ans=(ans+a)%MAX;
        b/=2;
        a=(a+a)%MAX;
    }
    return(ans);
}
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=mul(ans,a);
        b/=2;
        a=mul(a,a);
    }
    return(ans);
}
ll inv(ll a){
    return(power(a,MAX-2));
}
void ini(){
    fac[0]=1;
    for(int i=1;i<=maxn;i++){
        fac[i]=(fac[i-1]*i)%MAX;
    }
    return;
}
ll ncr(ll n,ll r){
    ll ans=fac[n];
    ans=mul(ans,inv(fac[n-r]));
    ans=mul(ans,inv(fac[r]));
    return(ans);

}
void solve(){
    ll N;cin>>N;
    if(N<3){
        cout<<0;return;
    }
    ll ans=0;
    for(int term=1;term*3<=N;term++){
        ans=(ans+ncr(N-2*term-1,term-1))%MAX;

    }
    cout<<ans;


    return;

}

int main(){
    IO

    ini();
    //TEST
    solve();


}



Measured memory_bytes: 11452
#include<cstdio>
#include<map>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=100005;
int n,m;
struct Task {
	int a,b;
}p[N];
int vis[N];
long long ans;
bool cmp(Task x,Task y) {
	if(x.b==y.b)
		return x.a>y.a;
	return x.b>y.b;
}
int Find(int x) {
	if(x<0) return x;
	if(vis[x]==vis[N-1]) return x;
	return vis[x]=Find(vis[x]);
}
int main() {
	memset(vis,-0x3f,sizeof(vis));
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d %d",&p[i].a,&p[i].b);
	sort(p,p+n,cmp);
	for(int i=0,t=0;i<n;i++) {
		int tmp=Find(m-p[i].a);
		if(tmp>=0)
			vis[tmp]=tmp-1,ans+=p[i].b;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  char ch[4];
 
  cin>>ch;
  if(ch[0]==ch[1]||ch[1]==ch[2]||ch[2]==ch[3])
  cout<<"Bad"<<endl;
  else
  cout<<"Good"<<endl;
  }
 

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d, n, m, dist[100002], k[10000];
  while(scanf("%d", &d), d){
    scanf("%d", &n);
    scanf("%d", &m);

    dist[0] = 0;
    for(int i = 1; i < n; i++){
      scanf("%d", &dist[i]);
    }
    dist[n] = d;
    n++;
    sort( dist, dist + n);

    for(int i = 0; i < m; i++){
      scanf("%d", &k[i]);
    }

    int sum = 0;
    for(int i = 0; i < m; i++){
      int& check = k[i]; //チェックするやつ
      int* posA = lower_bound( dist, dist + n + 2, check); //どっちかでしょ(たぶん
      int* posB = posA - 1; 
      sum += min( *posA - check, check - *posB); 
    }
    cout << sum << endl;
  }
}

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

using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

struct TopKSum {
    vector<ll> v;
    int k;
    ll sum;

    TopKSum(vector<ll> &_v, int _k) : v(_v), k(_k) {
        sum = accumulate(v.begin(), v.end(), 0LL);
    }

    ll eval(ll x) const {
        if ((int) v.size() == k) {
            assert(!v.empty());
            return sum - x;
        }
        if (x <= v[k])
            return sum - v[k];
        return sum - x;
    }
};

struct TopKSumBuilder {
    vector<ll> v;
    int k;

    explicit TopKSumBuilder(int _k) : k(_k) {
        assert(k >= 0);
    }

    void insert(ll x) {
        v.push_back(x);
    }

    TopKSum build() {
        assert((int) v.size() >= k);
        sort(v.rbegin(), v.rend());
        if ((int) v.size() != k)
            v.resize(k + 1);
        return TopKSum(v, k);
    }
};

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

    int n;
    ll X;
    cin >> n >> X;
    vector<ll> b(n), l(n), u(n);

    const function<ll(int, ll)> eval = [&](const int i, const ll c) {
        assert(0 <= i && i < n);
        assert(0 <= c && c <= X);
        if (c <= b[i])
            return c * l[i];
        return b[i] * l[i] + (c - b[i]) * u[i];
    };

    ll hisScore = 0;
    for (int i = 0; i < n; ++i) {
        cin >> b[i] >> l[i] >> u[i];
        hisScore += eval(i, b[i]);
    }

    ll k = 0;

    {
        vector<ll> v(n);
        for (int i = 0; i < n; ++i)
            v[i] = eval(i, X);
        sort(v.rbegin(), v.rend());
        partial_sum(v.begin(), v.end(), v.begin());
        auto it = lower_bound(v.begin(), v.end(), hisScore);
        assert(it != v.end());
        k = it - v.begin();
    }

    const TopKSum topKSum = [&]() {
        TopKSumBuilder builder(k);
        for (int i = 0; i < n; ++i)
            builder.insert(eval(i, X));
        return builder.build();
    }();

    ll lo = 0;
    ll hi = X;
    while (lo < hi) {
        const ll mid = (lo + hi) / 2;

        ll mx = 0;
        for (int i = 0; i < n; ++i)
            mx = max(mx, topKSum.eval(eval(i, X)) + eval(i, mid));

        if (mx >= hisScore)
            hi = mid;
        else
            lo = mid + 1;
    }

    const ll mid = (lo + hi) / 2;

    ll mx = 0;
    for (int i = 0; i < n; ++i)
        mx = max(mx, topKSum.eval(eval(i, X)) + eval(i, mid));
    assert(mx >= hisScore);

    cout << k * X + lo;
    return 0;
}

Measured memory_bytes: 4464
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
string S,T;

bool is_rot(string S,string T){
    string temp;
    if(S==T) return true;
    for(int i=0;i<S.size();i++){
        for(int j=0;j<S.size();j++){
            temp=S.substr(S.size()-j,j)+S.substr(0,S.size()-j);
            if(temp==T) return true;
        }
    }
    return false;
}

int main(int argc, char const *argv[])
{
    cin>>S>>T;
    if(is_rot(S,T)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

return 0;
}


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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
  }
  vector<int> d(n+1);
  d.at(0)=0;
  for(int i=1;i<n+1;i++){
    d.at(i)=d.at(i-1)+l.at(i-1);
    if(d.at(i)>x){
      cout << i << endl;
      break;
    }
    if(i==n && d.at(i)<=x){
      cout << n+1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;


int keta(llong x){
    int ans = 0;
    while(x > 0){
        ans += 1;
        x /= 10;
    }
    return ans ;
}



int main(){
    llong x;
    cin >> x;
    llong ans = 0;
    int k = keta(x);
    ans = 9 * (k -1);
    llong d = 1;
    REP(i,k -1) d *=10;
    ans += x/d -1;

    llong ans2 = 0;
    while(x > 0){
        ans2+= x%10;
        x/=10;
    }
    cout << max(ans,ans2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int a[10000];
	int b[10000];
	
	int a_point, b_point;
	
	int i;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &a[i], &b[i]);
		}
		
		a_point = 0;
		b_point = 0;
		for (i = 0; i < n; i++){
			if (a[i] > b[i]){
				a_point += a[i] + b[i];
			}
			else if (a[i] < b[i]){
				b_point += a[i] + b[i];
			}
			else {
				a_point += a[i];
				b_point += b[i];
			}
		}
		
		printf("%d %d\n", a_point, b_point);
	}
	
	return 0;
}


Measured memory_bytes: 676
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	syc(a,1,100);
	syc(b,1,100);
	int m = min(a,b);
	int c[m];
	
	for(int i=0;m>0;){
		if(a%m == 0 && b%m == 0){
			c[i]=m;
			i++;
		}
		m--;
	}
	
	cout << c[k-1] << endl;
	return 0;
}


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

int main(void){
  int cost, amount;
  int sum=0;
  int i=0, temp=0;
  int ave;
  char canma;

  while(cin >> cost >> canma >> amount){
    sum += cost * amount;
    temp+=amount;
    i++;
  }

  ave = (float)temp/(float)i + 0.5;

  cout << sum << endl << ave << endl;

  return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/python
# coding: utf-8
import os
from sys import stdin, stdout

if(os.getenv('__LOCAL__')):
    __dirname = os.path.dirname(__file__)
    __basename = os.path.splitext(os.path.basename(__file__))[0]
    __inputname = './input/' + __basename + '.txt'
    __outputname = './output/' + __basename + '.txt'
    __input_path = os.path.join(__dirname, __inputname)
    __output_path = os.path.join(__dirname, __outputname)
    stdin = open(__input_path)
    # stdout = open(__output_path, "w")

def main():
    S = list(map(int,stdin.readline().rstrip().split('/')))
    if(S[0] < 2019):
        ans = "Heisei"
        stdout.write("{}\n".format(ans))
        return 0
    if(S[0] == 2019 and S[1] <= 4):
        ans = "Heisei"
        stdout.write("{}\n".format(ans))
        return 0
    ans = "TBD"
    stdout.write("{}\n".format(ans))
    return 0
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if(h == 1 || w == 1) {
				System.out.println(1);
				System.exit(0);
			}
			double h1 = Math.ceil(h / (double)2);
			double w1 = Math.ceil(w / (double)2);
			double h2 = Math.floor(h / (double)2);
			double w2 = Math.floor(w / (double)2);
			long ans = (long)w1 * (long)h1 + (long)w2 * (long)h2;
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 21716
#!python3

from bisect import bisect_left
from collections import defaultdict
from itertools import accumulate

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, K, L, R = iim()
    A = list(iim())

    n2 = N // 2

    def calc(a, b):
        d0 = [[] for i in range(K)]
        for i in range(a, b):
            x = A[i]
            for k in range(K-1, 0, -1):
                d1 = d0[k-1]
                d2 = d0[k]
                for v1 in d1:
                    v1 += x
                    if v1 > R: continue
                    d2.append(v1)
            d0[0].append(x)
        return d0

    da = calc(0, n2)
    db = calc(n2, N)

    for i in range(K-1):
        #da[i].sort(reverse=True)
        db[i].sort()

    ans = 0
    for k in range(1, K):
        j = K-k-1
        d1 = da[k-1]
        d2 = db[j]

        pos1 = 0
        for k1 in d1:
            #pos1 = bisect_left(d2, L-k1, pos1)
            pos1 = bisect_left(d2, L-k1)
            pos2 = bisect_left(d2, R+1-k1, pos1)
            #print(k, k1, num1, pos1, pos2)

            ans += pos2 - pos1

    for dx in [da[-1], db[-1]]:
        for val in dx:
            if L <= val <= R:
                ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()



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

int main(){
  int n,m;
  cin >> n >> m ;
  
  vector<long long> x(n),y(n),z(n);
  for (int i = 0; i < n; i++)
  {
    cin >> x[i] >> y[i] >> z[i];
  }

  long long xx,yy,zz;
  long long ans=0;
  for (int i = 0; i < 2; i++)
  {
    if(i) xx=1;
    else xx = -1;
    for (int j = 0; j < 2; j++)
    {
      if(j) yy=1;
      else yy = -1;
      for (int k = 0; k < 2; k++)
      {
        if(k) zz=1;
        else zz = -1;

        vector<long long> anslist(n);
        for (int w = 0; w < n; w++)
        {
          anslist[w]=x[w]*xx+y[w]*yy+z[w]*zz;
        }
        sort(anslist.begin(),anslist.end(),greater<long long>());
        long long anss=0;
        for (int v = 0; v < m; v++)
        {
          anss+=anslist[v];
        }
        ans=max(anss,ans);
      }
      
    }
    
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASheepAndWolves solver = new ASheepAndWolves();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASheepAndWolves {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int s = in.nextInt();
            int w = in.nextInt();

            if (w >= s) {
                out.println("unsafe");
            } else {
                out.println("safe");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32608
from collections import Counter
from itertools import combinations
N = int(input())
S = [input()[0]  for i in range(N)]
dic ={'M':S.count('M'),'A':S.count('A'),'R':S.count('R'),'C':S.count('C'),'H':S.count('H')}
cnt=0
for i,j,k in combinations(dic.values(),3):
    cnt+=i*j*k
print(cnt)

Measured memory_bytes: 4216
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      String a = scanner.next();
      String b = scanner.next();
      int n = a.length();
      int m = b.length();
      char s = a.charAt(0);
      char t = b.charAt(0);

      if (a.equals(b)) {
        System.out.println("EQUAL");
        return;
      }
      
      if (!show(n,m)) show(s,t);
    } finally {
      scanner.close();
    }
  }
  
  private static boolean show(int a, int b) {
    if (a > b) {
      System.out.println("GREATER");
      return true;
    } else if (a < b) {
      System.out.println("LESS");
      return true;
    } else {
      return false;
    }
  }
}

Measured memory_bytes: 24148
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
 
n, m = map(int, input().split())
ma = [[0]*n for _ in range(n)]
list_ABC = [ list(map(int,input().split(" "))) for i in range(m)]

for a, b, c in list_ABC:
  ma[a-1][b-1] = c
  ma[b-1][a-1] = c
  
y = dijkstra(ma, directed=False).astype(int)
 
ans = 0
 
for a, b, c in list_ABC:
  if y[a-1][b-1] != c:
    ans += 1
    
print(ans)

Measured memory_bytes: 14244
#include <bits/stdc++.h>
    using namespace std;
    #define LL long long
    #define Max(a,b) ((a)>(b)?(a):(b)) 
    #define Min(a,b) ((a)<(b)?(a):(b)) 
     
    //FILE *fp,*fp2;
    //fp=fopen("input.txt","r");
    //fp2=fopen("output.txt","w");
     
    int main()
    {
        LL int a,b,c,d,e,f;
    	cin>>a>>b>>c>>d>>e>>f;
    	a=100*a;
    	b=100*b;
    	LL int maxn=1,suger=0;
        for(int i=0;i*a<=f;i++)
            for(int j=0;i*a+j*b<=f;j++)
                for(int s=0;(i*a+j*b+s*c<=f)&&(s*c<=(i*a+j*b)*e/100);s++)
                    for(int k=0;(i*a+j*b+s*c+k*d<=f)&&(s*c+k*d<=(i*a+j*b)*e/100);k++)
                    {
                        if(i*a+j*b==0)
                        continue;
						if(maxn==1&&suger==0) 
                        {
                            maxn=(i*a+j*b+s*c+k*d);
                            suger=s*c+k*d;
                        }
                        if((s*c+k*d)*maxn>(i*a+j*b+s*c+k*d)*suger)
                        {
                            maxn=(i*a+j*b+s*c+k*d);
                            suger=s*c+k*d;
                        }
                        
                    }
        cout<<maxn<<" "<<suger;
        return 0;
    }

Measured memory_bytes: 384
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll n;
	cin>>n;
	int k;
	cin>>k;
	int p = 0;
	int m = 4;
	vint used(11);
	ll cnt = 0;
	if(n < 3){
		cout << 0 << endl;
		return;
	}
	n -= 2;
	rep(i,n){
		if(used[m]) break;
		used[m] = 1;
		rep(j,5){
			if((m+j*9)%11==k){
				cnt++;
				// cout << i+1 << " " << j+1 << endl;
			}
		}
		(m += 8) %= 11;
		p++;
	}
	// cout << p << " " << cnt << endl;
	ll t = 1;
	ll ans = 0;
	while(p * t <= n) t += t;
	while(t){
		if(p * t <= n){
			ans += cnt * t;
			n -= p*t;
		}
		t >>= 1LL;
	}
	t = 10000;
	while(p * t <= n){
		n -= p*t;
		ans += cnt * t;
	}
	while(p <= n){
		n -= p;
		ans += cnt;
	}
	rep(i,n){
		rep(j,5){
			if((m+j*9)%11==k){
				ans++;
			}
		}
		(m += 8) %= 11;
	}
	cout << ans << endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
h,w=100,100
a,b=map(int,input().split())
u=[['#']*w for i in range(h//2)]
d=[['.']*w for i in range(h//2)]


for i in range(a-1):
    u[1+((2*i)//w)*2][(2*i)%w]='.'

for i in range(b-1):
    d[1+((2*i)//w)*2][(2*i)%w]='#'
    
g=u+d
    
print(h,w)
for j in g:
    print(''.join(j))



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

int main() {
  string s;
  cin >> s;
  
  for (char c = 'a';c <= 'z';c++) {
    int count = 0;
    for (int i = 0;i < s.length();i++) {
      if (c == s[i])
        count++;
    }
    if (count % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <stack>
#include <map>
#include <unordered_map>
#include <queue>
#include <vector>
#include <unordered_set> 
#include <algorithm>
#include <iomanip>
#define LL long long
using namespace std;
int const N=305;
int a[N][N]; 
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
    cin>>a[i][j];
    LL ans=0;
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	{
		bool flag=true;
	    for(int k=1;k<=n;k++)
	    {
		    if(a[i][j]>a[i][k]+a[k][j])
	        {
	        	puts("-1");
	        	return 0;
			}
			else if(i!=k&&j!=k&&a[i][j]==a[i][k]+a[k][j]) flag=false;
	    }
	    if(flag)
	    {
	    	ans+=a[i][j];
		}
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#coding:utf-8
O = raw_input()
E = raw_input()

p = ""

if (len(O)+len(E)) % 2 == 0:
    for i in xrange(len(O)):
        p += O[i]
        p += E[i]
else:
    for i in xrange(len(O)-1):
        p += O[i]
        p += E[i]
    p += O[len(O)-1]

print(p)


Measured memory_bytes: 2568