akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int main() {
  int n,m,k;
  cin >> m >> n >> k;
  string r[m],t[n];
  rep(i,m) R r[i];
  rep(i,n) {
    rep(j,m) t[i]+=r[m-j-1][i];
  }
  bool ck=false;
  rep(i,n-1) {
    rep(j,m) {
      if(!check(n,m,i+1,j) || (t[i][j]=='.' && t[i+1][j]=='.')) continue;
      string s[n];
      rep(x,n) s[x]=t[x];
      swap(s[i][j],s[i+1][j]);
      rep(x,n) fill(remove(s[x].begin(),s[x].end(),'.'),s[x].end(),'.');
      while(1) {
	bool e[n][m],f=false;
	memset(e,0,sizeof(e));
	rep(x,n) {
	  rep(y,m) {
	    if(s[x][y]=='.') continue;
	    REP(l,1,3) {
	      int cnt=0;
	      int c=(l==1?m:n);
	      rep(p,c+1) {
		int nx=x+dx[l]*p,ny=y+dy[l]*p;
		if(!check(n,m,nx,ny) || s[nx][ny]!=s[x][y]) break;
		cnt++;
	      }
	      if(cnt>=k) {
		f=true;
		rep(p,c+1) {
		  int nx=x+dx[l]*p,ny=y+dy[l]*p;
		  if(!check(n,m,nx,ny) || s[nx][ny]!=s[x][y]) break;
		  e[nx][ny]=1;
		}
	      }
	    }
	  }
	}
	rep(x,n) rep(y,m) if(e[x][y]) s[x][y]='.';
	rep(x,n) fill(remove(s[x].begin(),s[x].end(),'.'),s[x].end(),'.');
	int c=0;
	rep(x,n) rep(y,m) if(s[x][y]!='.') c++;
	if(!c) {
	  ck=true;
	  break;
	}
	if(!f) break;
      }
      if(ck) break;
    }
    if(ck) break;
  }
  if(ck) pr("YES");
  else pr("NO");
  return 0;
}


Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int cun = 0;
	for (int i = min(a, b); i >= 0; i--) {
		if (a % i == 0 && b % i == 0) {
			cun++;
			// cout << i << endl;
		}
		if (cun == k) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    int mod=1e9+7;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]%=mod;
    }
    long long int sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        sum%=mod;
    }
    long long int ans=0;
    for(int i=0;i<n;i++){
        sum-=a[i];
        if(sum<=0){
            sum+=mod;
            //sum%=mod;
        }
        ans+=(a[i]*sum);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4044
H,W,N = map(int,input().split())

from collections import defaultdict
t =defaultdict(int)
L = defaultdict(int)

for i in range(N):
    a,b = map(int,input().split())
    t[(a-1,b-1)] = 1
    for p in [-1,0,1]:
        for q in [-1,0,1]:
            if a+p < 2 or b+q < 2 or a+p >H-1 or b+q >W-1:
                continue
            L[(a+p-1,b+q-1)] += 1
ans = [0]*10
for v in L.values():
    ans[v] += 1

ans[0] = (H-2)*(W-2) - sum(ans)
for i in range(10):
    print(ans[i])


Measured memory_bytes: 159348
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define vpush(v,x) v.push_back(x);
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,w,h;
    vint v;
    cin>>a>>b;
    cout<<(a<b ? 0 : 10);
    return(0);
}

Measured memory_bytes: 256
from math import sqrt

N, D = list(map(int, input().split()))
X = [[] for i in range(N)]
for i in range(N):
    X[i] = list(map(int,input().split()))

num = 0
for i in range(N):
    for j in range(i+1, N):
        diff = [(X[i][k] - X[j][k])**2 for k in range(D)]
        dist = sum(diff)**.5
        if dist == int(dist):
            num += 1

print(num)

Measured memory_bytes: 3188
import java.util.*;
import java.math.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		BigInteger ans = new BigInteger("1");
		final BigInteger TEN_EIGHTEEN = new BigInteger("1000000000000000000");
		final BigInteger ZERO = new BigInteger("0");
		final BigInteger OVER = new BigInteger("-1");
		String[] s = new String[N];
		Boolean flag_z = false;
		for (int i = 0; i < N; ++i) {
			s[i] = sc.next();
			if (s[i].equals("0")) {
				flag_z = true;
			}
		}
		if (flag_z) {
			ans = ZERO;
		} else {
			for (int i = 0; i < N; ++i) {
				BigInteger A = new BigInteger(s[i]);
				if (A.compareTo(ZERO) != 0) {
					if (ans.multiply(A).compareTo(TEN_EIGHTEEN) <= 0) {
						ans = ans.multiply(A);
					} else {
						ans = OVER;
						break;
					}
				} else {
					ans = ZERO;
					break;
				}
			}
		}
		// System.out.println(" "+ans.toString());
		sc.close();
		if (ans.compareTo(ZERO) == -1) {
			System.out.println("-1");
		}else{
			System.out.println(ans.toString());
		}
	}
}


Measured memory_bytes: 66620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e8+5);
void max_self(ll &a, ll b) {
    a = max(a, b);
}
void min_self(ll &a, ll b) {
    a = min(a, b);
}
void mul(ll &a, ll b) {
    a = (a * b) % mod;
}
void add_self(ll &a, ll b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
ll gcd(ll a, ll b){
    return b?gcd(b,a%b):a;
}

ll n,m;
pair<ll,ll> a[100005];

bool mycmp(pair<ll,ll> &x, pair<ll,ll> &y){
    return x.second<y.second;
}

ll run() {
    cin>>n>>m;

    for(int i=1;i<=n;i++){
        cin>>a[i].second>>a[i].first;
    }

    sort(a+1,a+n+1,mycmp);
//    for(int i=1;i<=n;i++){
//        cout<<a[i].first<<" "<<a[i].second<<"\n";
//    }



    ll ans = 0;
    ll sum = 0;
    int i=1;
    while(i<=n && sum+a[i].first<=m){
        sum += a[i].first;
        ans += (a[i].first)*(a[i].second);
        i++;
    }

    if(sum<m){
        ll x = m-(sum);
        ans += (a[i].second)*x;
        sum +=x;
    }
    cout<<ans;


}


















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

  int N  ;
  cin >> N  ;
  int count = 0 ;
  for(int i = 1 ; i + i < N ; i++ ) {
    if( i+i != N)count++ ;
  }
  cout  << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;
public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String n = s.next();
        int counter = 0;
        for(int i=0;i<n.length();i++){
            char c = n.charAt(i);
            if(c=='1')
                counter++;
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 21076
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define PI acos(-1)
#define eps 1e-10
#define mem(x) memset(x,0,sizeof(x))
#define _for(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define __for(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

const int INF=0x3f3f3f3f;
const int MAX=1e5+5;
const int MOD=1e9+7;

int n;
struct node{
	int x,y;
}red[105],blue[105];

int ans;
int cmp(node a,node b){
	if(a.x==b.x){
		return a.y<b.y;
	}
	return a.x<b.x;
}
bool check(int i,int j){
	if(blue[j].x>red[i].x&&blue[j].y>red[i].y) return true;
	return false;
}

vector<int>G[205];
int vis[205];
int link[205];

bool can(int t){
	int len=G[t].size();
	_for(i,0,len-1){
		int tmp=G[t][i];
		if(!vis[tmp]){
			vis[tmp]=1;
			if(link[tmp]==-1||can(link[tmp])){
				link[tmp]=t;
				return true;
			}
		}
	}
	return false;
}

int maxmatch(){
	int num=0;
	memset(link,-1,sizeof(link));
	_for(i,1,n){
		mem(vis);
		if(can(i)){
			num++;
		}
	}
	return num;
}

int main(){
	//最大二分匹配
    std::ios::sync_with_stdio(false);
    cin>>n;
    _for(i,1,n){
    	cin>>red[i].x>>red[i].y;
    }
    _for(i,1,n){
    	cin>>blue[i].x>>blue[i].y;
    }
    _for(i,1,n){
    	_for(j,1,n){
    		if(check(i,j)){
    			G[i].push_back(j+n);
    			G[j+n].push_back(i);
    		}
    	}
    }
    ans=maxmatch();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

vector<int> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = (ll)f0[i - 1] * i % P;
    }
    f1.resize(n + 1);
    f1[n] = inv(f0[n]);
    for (int i = n; i > 0; i--) {
        f1[i - 1] = (ll)f1[i] * i % P;
    }
}
ll fact(int k) {
    return f0[k];
}
ll comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return (ll)f0[n] * f1[k] % P * f1[n - k] % P;
}

int main() {
    string s;
    int k;
    cin >> s >> k;
    s = '0' + s;

    int n = s.size();
    for (int i = 0; i < n; i++) {
        s[i] -= '0';
    }
    s[n - 1] += 1;
    for (int i = n - 1; i > 0; i--) {
        if (s[i] >= 10) s[i] -= 10, s[i - 1]++;
    }

    init(n);

    int r = 0;
    for (int i = 0; i < n; i++) {
        int l = k;
        for (int j = 0; j < i; j++) {
            l -= s[j] > 0;
        }
        if (l < 0) continue;
        if (l == 0) {
            if (s[i] > 0) r++;
            continue;
        }

        int t = 1;
        for (int x = 0; x < l; x++) {
            t *= 9;
        }
        if (s[i] > 0) r += comb(n - 1 - i, l) * t;
        if (s[i] > 1) r += (s[i] - 1) * comb(n - 1 - i, l - 1) * t / 9;
    }

    cout << r << endl;

    //456なら、400未満と450未満と456未満

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int N,M,MM;long long K,A[MAXN];
bool check(long long v)
{
	long long sum=0;
	for (int i=1;i<=N;++i)
		if (A[i]<0)
		{
			int l=i,r=N,mid;
			while (l<r)
			{
				mid=(l+r)>>1;
				if (A[mid+1]*A[i]<=v) r=mid;
				else l=mid+1;
			}
			//printf("%d l=%d %lld\n",A[i],l,A[i]*A[l]);
			sum+=max(N-l,0);
		}
		else if (A[i]==0)
		{
			if (v>=0) sum+=N-i;
		}
		else
		{
			int l=i+1,r=N+1,mid;
			while (l<r)
			{
				mid=(l+r)>>1;
				if (A[mid]*A[i]<=v) l=mid+1;
				else r=mid;
			}
			--l;
			sum+=max(l-i,0);
		}
	/*
	if (v>=0)
	{
		for (int i=M+1;i<MM;++i) sum+=N-i;
	}
	for (int i=M,p=N;i>0;--i)
	{
		while (p && A[i]*A[p]<=v) --p;
		sum+=min(N-i,N-p);
	}
	for (int i=N,p=MM-1;i>=MM;--i)
	{
		while (p<N && A[i]*A[p+1]<=v) ++p;
		sum+=max(0,p-i);
	}
	*/
	//cout<<sum<<endl;
	return sum>=K;
}
int main()
{
	cin>>N>>K;
	for (int i=1;i<=N;++i) scanf("%lld",&A[i]);
	sort(A+1,A+1+N);
	M=lower_bound(A+1,A+1+N,0LL)-A-1;
	MM=upper_bound(A+1,A+1+N,0LL)-A;
	long long l=-1e18,r=1e18,mid;
	while (l<r)
	{
		mid=(l+r)>>1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
	return 0;
}

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

/*If you are going to try,keep going until the end ,or don't even try to start*/

/* Remember, Hope is a good thing... May be the best of things... And No Good thing ever Dies !!!*/

using namespace std;

#define ll long long
#define nada "\n"
#define st string
#define S  second
#define F  first
#define pb push_back
#define MP make_pair
#define isnttriangle(a,b,c)  (a+b<c||a+c<b||b+c<a)
#define todegree(rad) rad*(180.0/pi)
#define rrp(i, a, b)  for(ll i = a; i >= b; i--)
#define repp(i,a,b)   for (int i = int(a); i <=int(b); i++)
#define rep(i, n)     for (int i = 0; i <n; i++)
#define rep1(i,n)     for (int i = 1; i <=n; i++)
#define allr(v)       ((v).rbegin()), ((v).rend())
#define all(v)        ((v).begin()),((v).end())
#define fx(n)         cout<<fixed<<setprecision(n);
#define sz(v)         ((int)(v).size())
#define Test          ll t;cin>>t;while(t--)
#define mod           1000000009LL


const double ME = 2.71828;
const int    N  = 3e5 + 20;
const int   inf = 0x3f3f3f3f;
const double pi = 3.141592653;




void LOSER()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void file()
{
    freopen("records.in", "r", stdin);
    //freopen("text.out", "w", stdout);
}

ll gcd(ll a, ll b)
{
    //Eculidean Algorthim
    return (!b) ? a : gcd(b, a % b);
    //complixty=log(ab);
}

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

ll Fib_recur(ll n)
{
    vector<ll>v(n+5,0);
    //BaseCase
    v[1]=0;
    v[2]=1;
    repp(i,3,n)v[i]=v[i-1]+v[i-2];
    return v[n];
}

bool isprime(int n)
{
    for(int i = 2; i <= sqrt(n); i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}

void Solve()
{
 int n,cnt=0;
 cin>>n;
 vector<int>v(n);

 for(auto&i:v)cin>>i;
 rep(i,n)
 {
     if(i%2==0)
     {
         if(v[i]%2!=0)cnt++;
     }
 }
 cout<<cnt;

}





int main()
{
    // fx(7)
    //file();
    LOSER();
    //Test

    Solve();







}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main()
{
	int n, m, l;
     long int NM[128][128], ML[128][128], NL[128][128];
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			int a;
			cin >> a;
			NM[i][j] = a;
		}
	}
	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			int b;
			cin >> b;
			ML[i][j] = b;
		}
	}
			for (int i = 0; i < n; i++){
				for (int j = 0; j < l; j++){
				long c = 0;
			for (int k = 0; k < m; k++){
			c += NM[i][k] * ML[k][j];
			}
			if (j == l - 1)cout << c;
			else cout << c << " ";
		}
		cout << endl;
	}
	return 0;
}


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

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("gymnastics.in","r",stdin );
#define outF freopen("gymnastics.out" , "w" , stdout ) ;
#define sum(a)a * (a + 1 ) / 2
#define ll long long

const double eps = 1e-9 , PI = acos(-1) ;
const int N = 101, oo = 1e17 , M = 1e5 + 5, mod = 1<<30 , K = 12;
int n , val[N] , wt[N];
ll dp[N][M];
ll knapsack(int idx , int w){
    if(w < 0)
        return -oo;
    if(idx == n)
        return 0 ;
    ll &ret = dp[idx][w] ;

    if(~ret)
        return ret ;

   ll first = knapsack(idx + 1 , w);
   ll second = knapsack(idx + 1 , w - wt[idx]) + val[idx];
   ret = max(first , second);
   return ret ;


}
int32_t main(){

    //inF;
    // Dont Forget memset
    memset(dp , -1 , sizeof dp);

    //calculate constraints please!!!
    int W ;
    cin >> n >> W ;
    for(int i = 0 ; i < n ; i++)
        cin >> wt[i] >> val[i];
    cout << knapsack(0 , W);
    fastio;

     return 0 ;
}



Measured memory_bytes: 82568
building = [[[0]*10 for i in range(3)] for j in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    building[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {0}' .format(building[i][j][k]), end='')
        print()
    if i < 3:
        print('#'*20)


Measured memory_bytes: 5624
using System;

public class hello
{
    public static void Main()
    {
        var count = 0;
        var sum = 0;
        var btotal = 0m;
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            count++;
            string[] s = line.Trim().Split(',');
            var a = int.Parse(s[0]);
            var b = int.Parse(s[1]);
            btotal += b;
            sum += a * b;
        }
        decimal res = btotal / count;
        var result = Math.Round(res, 0, MidpointRounding.AwayFromZero);
        Console.WriteLine(sum);
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 9232
from collections import deque
k = int(input())
dis = [float("inf") for _ in range(k)]

def bfs(start, goal):
	que = deque([[start, 1]])
	while que:
		label = que.pop()
		l, c = label[0], label[1]
		if l == goal:
			return c
		if dis[l] > c:
			dis[l] = c
			que.append([(l*10)%k, c])
			que.appendleft([(l+1)%k, c+1])

print(bfs(1, 0))

Measured memory_bytes: 19568
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int n,m,x,y;
        cin >> n >> m >> x >> y;
        int a[n],b[m];
        for(int i=0;i<n;i++)cin >> a[i];
        for(int j=0;j<m;j++)cin >> b[j];
        sort(a,a+n);
        sort(b,b+m);
        int flag=0;
        if(b[0]>a[n-1]){
            for(int i=a[n-1]+1;i<=b[0];i++){
                if(i>x && i<=y)flag++;
            }
            if(flag>0)cout << "No War" << endl;
            else cout << "War" << endl;
        }
        else cout << "War" << endl;
    }

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));
	b = 0;
	ans = n;
	for(i=1;i<=n;i++) {
		a = i;
		c = 0;
		while(a%2 == 0) {
			a /= 2;
			c++;
		}
		if (b < c) {
			b = c;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
    string L;cin>>L;
    int N = L.size();
    vector<vector<ll>> dp(N+1,vector<ll>(2,0));
    dp[0][1] = 1;
    rep(i,N) {
        //1 to 1
        if(L[i]=='1') {
            dp[i+1][1] = 2 * dp[i][1] % MOD;
        } else {
            dp[i+1][1] = dp[i][1];
        } 

        // 1 to 0
        if(L[i]=='1') {
            dp[i+1][0] = (dp[i+1][0] + dp[i][1]) % MOD;
        }

        // 0 to 0
        dp[i+1][0] = (dp[i+1][0] + 3 * dp[i][0]) % MOD;
    }
    cout<<(dp[N][0] + dp[N][1])%MOD<<endl; 
}

Measured memory_bytes: 8776
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

/*ll merge(vector<ll> &v,ll l,ll m,ll r)
{
	ll n1=m-l+1;
	ll n2=r-m;
	ll inv=0;
	vector<ll> a(n1),b(n2);
	for(ll i=0;i<n1;i++)
	a[i]=v[l+i];
	for(ll i=0;i<n2;i++)
	b[i]=v[m+1+i];
	ll i=0,j=0,k=l;
	while(i<n1&&j<n2)
	{
		if(a[i]<=b[j])
		{
			v[k]=a[i];
			i++;
		}
		else
		{   inv+=(m-i+1);
			v[k]=b[j];
			j++;
		}
		k++;
	}
	while(i<n1)
	{
		v[k]=a[i];
		i++;
		k++;
	}
	while(j<n2)
	{
		v[k]=b[j];
		j++;
		k++;
	}
	return inv;
}
ll mergesort(vector<ll> &v,ll l,ll r)
{  ll inv=0;
	if(l<r)
	{
		ll m=l+(r-l)/2;
		inv=mergesort(v,l,m);
		inv+=mergesort(v,m+1,r);
		inv+=merge(v,l,m,r);
	}
	return inv;
}*/
void solve()
{ll t,n,k,ans,z,d=0,p,q,l=INT_MIN,mini=0,prev;
  cin>>t>>n;
  z=max(t+n,t-n);
  ans=max(z,t*n);
  cout<<ans;
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int a[n], b[n], c[n];

  int m = 0;
  for(int i = 0; i < n; i++)  cin >> a[i];
  for(int i = 0; i < n; i++){
    cin >> b[i];
    m += b[i];
  }
  for(int i = 0; i < n-1; i++){
    cin >> c[i];
  }  

  for(int i = 0; i < n-1; i++){
    if(a[i]+1 == a[i+1]){
      m += c[a[i]-1];
    }
  }


  cout << m << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import deque
D=int(input())
def f(d,k):
  if 0<=k<=1:
    if d!=0:
      return "Unko"
    if k==1:
      return deque([0])
    else:
      return deque([])
  if d>=0:
    s=10-(d%10)
  else:
    s=-(d%10)
  if s==10:
    A=f(d//10,k-2)
    s=0
  #print(d,s,d-s*(10**(k-1))+s)
  else:
    A=f((d-s*(10**(k-1))+s)//10,k-2)
    
  if A=="Unko":
    return "Unko"
  A.appendleft(s)
  A.append(-s)

  return A
ans=0
for k in range(1,50):
  A=f(D,k)
  if A=="Unko":
    continue
 # print(A)
  res=1
  for j in range((k+1)//2):
    if j==0:
      res*=9-abs(A[j])
    else:
      if A[j]==0:
        res*=10
      else:
        res*=10-abs(A[j])
  ans+=res
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cassert>
#define INF 100000000
using namespace std;
int d, g;
int p[101];
int c[101];
int dps[10][500001];
int dp(int index, int rem) {
	if (rem <= 0)
		return 0;
	else if (index >= d)
		return INF;
	if (dps[index][rem] == -1) {
		dps[index][rem] = INF;
		for (int i = 0; i < p[index]; i++) {
			dps[index][rem] = min(dps[index][rem], dp(index + 1, rem - (index + 1) * i) + i);
		}
		dps[index][rem] = min(dps[index][rem], dp(index + 1, rem - c[index] - (index + 1) * p[index]) + p[index]);
		assert(dps[index][rem] != -1);
	} 
	return dps[index][rem];
}
int main() {
	cin >> d >> g;
	g /= 100;
	for (int i = 0; i < d; i++) {
		cin >> p[i] >> c[i];
		c[i] /= 100;
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j <= 500000; j++) {
			dps[i][j] = -1;
		}
	}
	cout << dp(0, g) << endl;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T) {
    if (S.size() + 1 != T.size()) {
        cout << NO << endl;
    } if (T.substr(0, S.size()) == S) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
    
}

int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int MAX=1e5;
int n,k;
vector<int> stone(MAX);
vector<int> dp(MAX);
int calc(int ind){
    if(ind>=n-1){
        return 0;
    }
    if(dp[ind]!=-1){
        return dp[ind];
    }
    int ans=INT_MAX;
    int next=ind+1;
    for(int i=next;i<min(n,next+k);i++){
        ans=min(ans,abs(stone[ind]-stone[i])+calc(i));
    }
    return dp[ind]=ans;
}
void solve(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>stone[i];
        dp[i]=-1;
    }
    int min_cost=calc(0);
    cout<<min_cost<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 7296
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.print(a*b);
        System.out.print(" ");
        System.out.println(a*2 + b*2);
    }
}


Measured memory_bytes: 26112
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M), C(M);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    for(int i = 0; i < M; ++i){
        cin >> B[i] >> C[i];
    }
    vector<P> BC(M);      // (C, B)
    for(int i = 0; i < M; ++i){
        BC[i] = P(C[i], B[i]);
    }
    sort(A.begin(), A.end());                   // 昇順ソート
    sort(BC.begin(), BC.end(), greater<P>());   // 降順ソート

    ll ans = 0;
    int now = 0;
    for(int i = 0; i < M; ++i){
        int value = BC[i].first;
        if(A[now] >= value)     break;
        int cnt = BC[i].second;

        while(now < N && A[now] < value && cnt > 0){
            A[now++] = value;
            cnt--;
        }
        
        if(now >= N)    break;
    }
    
    for(int i = 0; i < N; ++i){
        ans += A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <limits.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1e18;
const ll mod = 1e9+7;
//const ll LLMAX = LLONG_MAX;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		if(a[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	ll answer =1;

	//a.sort(a.begin(), a.end());
	rep(i,n){
		if(a[i] > INF / answer){
			answer = INF+1;
		}
		else
			answer *= a[i];
	}
	if(answer > INF ) cout << -1 << endl;
	else cout << answer << endl;

	return 0;
}

Measured memory_bytes: 3952
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    char now = 'A';
    for(char c:s){
        if(c==now){

        }else{
            ans++;
            now = c;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1000000007;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> cards(N);
    for( ll i = 0; i < N; ++ i ){
        cin >> cards[i];
    }
    sort(cards.rbegin(), cards.rend());

    vector<ll> sums(2,0);
    for ( ll i = 0; i < cards.size(); ++ i ){
        sums[i%2] += cards[i];
    }
    cout << sums[0]-sums[1] << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<algorithm>
#include<math.h>
int n;
double x[100],y[100];

double Square(double a){return a*a;}
double Distance2(double x1, double y1, double x2, double y2)
{
	return Square(x2-x1)+Square(y2-y1);
}

int CountOverlap(double px, double py)
{
	int res = 0;
	for(int i=0; i<n; ++i)
	{
		if(Distance2(x[i],y[i],px,py)<=1+1e-9)
			++res;
	}
	return res;
}

int main()
{
	const double pi = 4*atan(1.);
	while(scanf("%d",&n),n)
	{
		int i,j,k;
		int res = 0;
		for(i=0; i<n; ++i)
			scanf("%lf,%lf",x+i,y+i);

		for(i=0; i<n; ++i)
		{
			for(j=0; j<10000; ++j)
				res = std::max(res,CountOverlap(x[i]+cos(2*pi/j),y[i]+sin(2*pi/j)));
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1072
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

int main() {
    int K, X;
    cin >> K >> X;
    if (500 * K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int n;
  int ans = 0;
  int a[20];
  int b[20];
  int c[20];
  std::cin >> n;
  for (int x=0; x < n; ++x){
    std::cin >> a[x];
  }
  for (int x=0; x < n; ++x){
    std::cin >> b[x];
  }
  for (int x=0; x < n-1; ++x){
    std::cin >> c[x];
  }

  for (int x=0; x < n; ++x){
     ans += b[x];
  }

  for (int x=1; x < n; ++x){
    if ((a[x-1] + 1) == a[x]){
      int i = a[x-1] - 1;
       ans += c[i];
    }

  }

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


Measured memory_bytes: 256
A,B,C,X = [int(input()) for _ in range(4)]

# 全部やる
answer = 0
for a in range(0,A+1):
  for b in range(0,B+1):
    for c in range(0,C+1):
      x = a*500 + b*100 + c*50
      if X == x:
        answer += 1

print(answer)

Measured memory_bytes: 3060
def main():
    n, m = map(int, input().split())
    xyz = [list(map(int, input().split())) for i in range(n)]

    ans = 0
    for a in [-1, 1]:
        for b in [-1, 1]:
            for c in [-1, 1]:
                temp = []
                for x, y, z in xyz:
                    temp.append(a * x + b * y + c * z)
                temp.sort(reverse=True)
                t = sum(temp[:m])
                if ans < t:
                    ans = t
    print(ans)


main()


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


int main(){
    int n;
    cin >> n;
    vector<P> pos(n);
    rep(i,n){
        int x,y;
        cin >> x >> y;
        pos[i] = make_pair(x,y);
    }
    map<P,int> mp;
    rep(i,n){
        for(int j = 0;j<n;j++){
            if(i==j) continue;
            P p = make_pair(pos[i].first-pos[j].first,pos[i].second-pos[j].second);
            mp[p]+=1;
        }
    }

    int ans = n;
    int cnt = 0;
    for(auto p:mp){
        cnt = max(cnt,p.second);
    }
    ans -= cnt;
    cout << ans << endl;

 }

Measured memory_bytes: 3724
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import defaultdict
from collections import deque
import bisect
from decimal import *
def main():
    a, b, c, d = MI()
    print(max(a * c, b * d, a * d, b * c))
if __name__ == "__main__":
    main()



Measured memory_bytes: 72712
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int a, b, c, d;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c >> d;
	for(int i = 0; i <= d; i++)
		for(int j = 0; j <= d - i; j++)
			for(int k = 0; k <= d - i - j; k++)
				if(a * (1 << i) < b * (1 << j) && b * (1 << j) < c * (1 << k)){
					cout << "Yes\n";
					return 0;
				}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
typedef long long ll;

int N;
string S;
ll dp[3010][3010] = {},inf = 1e9+7;

int main(){
	cin >> N >> S;
	dp[1][1] = 1;
	for(int i=2;i<=N;i++){
		for(int j=1;j<=i;j++){
			if(S[i-2]=='<'){
				if(j!=1) dp[i][j] = dp[i-1][j-1];
			}else{
				if(j!=i) dp[i][j] = (dp[i-1][i-1]-dp[i-1][j-1]+inf)%inf;		
			}
		}
		for(int j=1;j<=i;j++){
			(dp[i][j] += dp[i][j-1])%=inf;
		}
	}
	cout << dp[N][N] << endl;
}

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

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


	int k, s, cnt = 0;
	cin >> k >> s;

	for(int i=0; i<=k; i++) {
		for(int j=0; j<=k; j++) {
			int l = s - i - j;
			if(0 <= l && l <= k) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<pair<int, int>> b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i].second >> b[i].first;
	}

	sort(a.begin(), a.end());
	sort(b.rbegin(), b.rend());

	int j = 0;
	int k = 0;
	for (int i = 0; i < n; i++) {
		if (j == m) {
			break;
		}
		
		if (a[i] >= b[j].first) {
			break;
		}
		else {
			a[i] = b[j].first;
			k++;
			if (k == b[j].second) {
				k = 0;
				j++;
			}
		}
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
a = int(input())
j=0
mass=1000000000000
for i in range(round(a**(1/2))):
    j = j+1
    h=a/j
    if (h.is_integer()):    
        mass2=j+h-2
        if(mass>mass2):
            mass=mass2
        

    

print(int(mass))


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

using namespace std;

#define MAX 25

int main()
{
    int H, W;
    while (cin >> W >> H, W) {
        vector<vector<int>> a(H, vector<int>(W));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> a[i][j];
            }
        }
        int dp[MAX][MAX] = {{}};
        for (int i = 0; i < W; i++) {
            dp[0][i] = (a[0][i] == 0);
        }

        for (int i = 0; i < H - 1; i++) {
            for (int j = 0; j < W; j++) {
                if (dp[i][j] <= 0 || a[i][j] == 1) continue;
                if (a[i][j] == 2) {
                    int ni = min(i + 2, H - 1);
                    if (i + 2 < H && a[i+2][j] == 1) continue;
                    dp[ni][j] += dp[i][j];
                } else {
                    for (int k = -1; k <= 1; k++) {
                        int ni = i + 1;
                        int nj = j + k;
                        if (nj < 0 || nj >= W || ni >= H) continue;
                        if (a[ni][nj] == 1) continue;
                        if (a[ni][nj] == 2 && j != nj) continue;
                        dp[ni][nj] += dp[i][j];
                    }
                }
            }
        }
        int res = 0;
        for (int i = 0; i < W; i++) {
            res += dp[H-1][i];
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<ctime>
#define MOD 1000000007
using namespace std;

int n, a,b,c;
string s;
typedef pair<int, int> P;

inline long long mod(const long long &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
int mod(const int &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
inline long long fact(long long a) {//階乗
	long long ret = 1;
	for (int i = 1; i <= a; i++)
	{
		ret = mod(ret*i);
	}
	return ret;
}
inline long long modpow(long long a, long long b) {//mod(a^b)を求める
	if (!b)
	{
		return 1;
	}
	if (b < 0) {
		long long ret = 1;
		b = mod(-b);
		ret = modpow(a, MOD - 1 - b);
		return ret;
	}
	long long ret = 1;
	vector<long long> mem(100);//a^(2^k)をメモる
	mem[0] = a;
	for (int i = 1; i < 100; i++)
	{
		mem[i] = mod(mem[i - 1] * mem[i - 1]);
	}
	int now = 0;
	while (b) {
		if (b & 1)
		{
			ret = mod(ret*mem[now]);
		}
		b >>= 1;
		now++;
	}
	return ret;
}
inline long long combi(long long a, long long b) {//a C bをmodの条件下で求める
	long long ret = fact(a);
	ret = mod(ret*modpow(fact(b)*(a-b), MOD - 2));
	return ret;
}



int main() {
	cin >> n >> a >> b >> c;
	vector<long long>apow(2 * n);
	vector<long long>bpow(2 * n);
	vector<long long>mnspow(n+2);
	vector<long long>fct(2*n);
	vector<long long>mnsfct(2 * n + 1);
	fct[0] = 1;
	mnsfct[2 * n] = modpow(fact(2 * n),-1);
	mnspow[n + 1] = modpow(100 - c, -n - 1);
	for (int i = 1; i < 2*n; i++)
	{
		fct[i] = mod(fct[i - 1] * i);
		mnsfct[2 * n - i] = mod(mnsfct[2 * n - i + 1] * (2 * n - i + 1));
	}
	mnsfct[0] = 1;
	for (int i = 0; i < n+1; i++)
	{
		mnspow[n - i] = mod(mnspow[n + 1 - i] * (100 - c));
	}
	apow[0] = bpow[0] = 1;
	for (int i = 0; i < 2*n-1; i++)
	{
		apow[i + 1] = mod(apow[i] * a);
		bpow[i + 1] = mod(bpow[i] * b);
	}
	long long ret = 0;
	for (int k = n; k <= 2*n-1; k++)
	{
		long long bnb = mnspow[k-n];
		long long temp = mod(fct[k - 1] * mod(mnsfct[k - n] * mnsfct[n - 1]));
		//combi=(m-1)!/(m-n)!*(n-1)!
		temp = mod(mod((mod(mod(apow[n]*bpow[k-n])+mod(apow[k-n]*bpow[n])))* temp) * k * 100);
		temp = mod(temp * bnb);
		ret = mod(temp + ret);
	}
	ret = mod(ret*mnspow[n+1]);
	cout << ret << endl;
}

Measured memory_bytes: 7296
n, m, x = map(int, input().split())
A = [int(i) for i in input().split()]
###nはマス目の数、mは料金所の数、xは自分がいるマス目
count_l = 0
count_r = 0

for a in A:
    if a < x:
        count_l += 1
    else:
        count_r += 1

print(min(count_l, count_r))


Measured memory_bytes: 2940
//https://beta.atcoder.jp/contests/abc100/submissions/2670489
#include <bits/stdc++.h>
using namespace std;

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main() {
  cin >> N >> M;
  for (int i = 1; i <= N; i++){
    for (int j = 0; j < 3; j++) cin >> a[i][j];
  }
  for (int i = 0; i < 8; i++) {
    vector<long long> vec;
    for (int j = 1; j <= N; j++) {
      long long S = 0;
      for (int k = 0; k < 3; k++) {
        if((i/(1 << k))%2 == 0) S += a[j][k];
        else S -= a[j][k];
      }
      vec.push_back(S);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    long long ans = 0;
    for (int j = 0; j < M; j++) ans += vec[j];
    maxn = max(maxn, ans);
  }
  cout << maxn << endl;
  return 0;
}
      

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


ll gcd(ll a, ll b) {
  if (b > a) {
    swap(a, b);
  }
  ll r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

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



signed main() {
  ll n;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  n /= 2;

  ll ans = 0;
  ll mask = 5;
  ll num = 1;
  while (mask <= n) {
    ans += n / mask;
    mask *= 5;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define inf 1000000000

int n,ary[N][N];

int prim(){
  int i,u,v,mincost,sum=0;
  int pary[N],eary[N],color[N];

  for(i=0;i<n;i++){
    color[i]=WHITE;
    pary[i]=inf;
  }
  pary[0]=0;
  eary[0]=-1;

  while(1){
    mincost=inf;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && pary[i]<mincost){
	mincost=pary[i];
	u=i;
      }
    }
    if(mincost==inf)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && ary[u][v]!=inf){
	if(ary[u][v]<pary[v]){
	  pary[v]=ary[u][v];
	  eary[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(eary[i]!=-1)sum+=ary[i][eary[i]];
  }
  return sum;
}

int main(){

  int i,j,e;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e==-1){
	ary[i][j]=inf;
      }
      else{
	ary[i][j]=e;
      }
    }
  }
  printf("%d\n",prim());
}



Measured memory_bytes: 2052
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e6+5;
int a[N][26];
int cnt[N],idx,ans;
void ins(char str[]){
int p=0;
for(int i=0;str[i];i++){
int u=str[i]-'a';
if(!a[p][u])a[p][u]=++idx;
p=a[p][u];
}
cnt[p]++;
if(cnt[p]==1)ans++;
}
int main(){
int t;
cin>>t;
while(t--){
    char str[12];
    scanf("%s",str);
    ins(str);
}
cout<<ans;
return 0;
}


Measured memory_bytes: 148192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

int main(){
	int N, T;
	cin >> N >> T;
	vector<P> AB;
	rep(i,N){
		int A, B;
		cin >> A >> B;
		AB.push_back(make_pair(A,B));
	}
	sort(AB.begin(),AB.end());
	int Amax=AB[N-1].first;
	int dp[3010][6010];
    rep(i,N){
      rep(j,T+Amax) dp[i][j]=0;
    }
	rep(i,N){
		rep(j,T+Amax){
			if(j<AB[i].first||j-AB[i].first>=T) dp[i+1][j]=dp[i][j];
			else dp[i+1][j]=max(dp[i][j],dp[i][j-AB[i].first]+AB[i].second);
		}
	}
	int ans=0;
	for(int i=T; i<T+Amax; i++){
		ans=max(ans,dp[N][i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 70784
#include <iostream>

using namespace std;

int main(){
	int N, A, B, C, X;
	while(cin>>N>>A>>B>>C>>X, N|A|B|C|X){
		int Y, f=0, fir=1;
		for(int i=0; i<N; i++){
			cin >> Y;
			for(;(X!=Y||!fir) && f<=10000 ;f++, fir++){
				X = (A*X+B) % C;
			}
			fir=0;
		}
		if( f<=10000 ) cout << f << endl;
		else cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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(){
    int x; cin >> x;
    if (x>=1200) cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

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

using namespace std;
long long ll;

int main(void){
    long double a,b,c;
    cin >> a >> b >> c;
    
    long double eps = 1.0e-14;
    
    if(sqrt(a) + sqrt(b) + eps < sqrt(c)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
/*(^(^(^(^(^o^)^)^)^)^) &#9602;&#9605;&#9607;&#9608;&#9619;&#9618;&#9617;('ω')&#9617;&#9618;&#9619;&#9608;&#9607;&#9605;&#9602; */
  int main(){
	  int x[102][102]={};
	  int y[102][102]={};
	  int w,h,i,j,sum=0;
	  scanf("%d %d",&w,&h);
	  for(i=1;i<=h;i++){
		  for(j=1;j<=w;j++){
			  scanf("%d",&x[j][i]);
		  }}
	  for(i=0;i<=h+1;i++){
		  y[0][i]=1;
		  y[w+1][i]=1;
	  }
	   for(i=0;i<=w+1;i++){
		  y[i][0]=1;
		  y[i][h+1]=1;
	  }
	   for(int q=0;q<10000;q++){
	  for(i=1;i<=w;i++){
		  for(j=1;j<=h;j++){
			  if(x[i][j]==0){
			  if(j%2==0){
				  if(y[i-1][j-1]==1){y[i][j]=1;}
				  if(y[i][j-1]==1){y[i][j]=1;}
				  if(y[i+1][j]==1){y[i][j]=1;}
				  if(y[i][j+1]==1){y[i][j]=1;}
				  if(y[i-1][j+1]==1){y[i][j]=1;}
				  if(y[i-1][j]==1){y[i][j]=1;}
			  }else{
				  if(y[i+1][j]==1){y[i][j]=1;}
				  if(y[i+1][j+1]==1){y[i][j]=1;}
				  if(y[i+1][j-1]==1){y[i][j]=1;}
				  if(y[i][j-1]==1){y[i][j]=1;}
				  if(y[i][j+1]==1){y[i][j]=1;}
				  if(y[i-1][j]==1){y[i][j]=1;}
			  }}
		  }}}
	  for(i=0;i<=w+1;i++){
		  for(j=0;j<=h+1;j++){
			  if(y[i][j]==0){
			  if(j%2==0){
				  if(y[i-1][j-1]==1){sum++;}
				  if(y[i][j-1]==1){sum++;}
				  if(y[i+1][j]==1){sum++;}
				  if(y[i][j+1]==1){sum++;}
				  if(y[i-1][j+1]==1){sum++;}
				  if(y[i-1][j]==1){sum++;}
			  }else{
				  if(y[i+1][j]==1){sum++;}
				  if(y[i+1][j+1]==1){sum++;}
				  if(y[i+1][j-1]==1){sum++;}
				  if(y[i][j-1]==1){sum++;}
				  if(y[i][j+1]==1){sum++;}
				  if(y[i-1][j]==1){sum++;}
			  }
			  }}}
	  printf("%d\n",sum);
	  return 0;
  }

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n&&n!=-1){
        int sum=3130,num[3]={125,140,160};
        for(int i=0,j=n-10;i<3;i++,j-=10){
            if(j>10&&i!=2)sum-=num[i]*10;
            else if(j>0)sum-=num[i]*j;
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 1160
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!
 
const gcdArr = function(arr) {
  let gcdres = gcd(arr[0], arr[1])
  for (let i=2; i<arr.length; i++) {
    gcdres = gcd(gcdres, arr[i])
  }
  return gcdres
}
 
function gcd_impl(n,m) {
        for( let i = 0; i < 10; ++i ) {
                let t = n - m;
                let q = m > t;
                n = q ? m : t;
                m = q ? t : m;
                if( m == 0 ) { return n; }
        }
        return gcd_impl( m, n % m );
}
 
function gcd( n, m ) {
        return n > m ? gcd_impl( n, m ) : gcd_impl( m, n );
}
 
const Main = (p)=>{
	// 1行目がinput[0], 2行目がinput[1], …に入る
	p = p.split("\n");
	let N = parseInt(p[0].split(" ")[0]);
	let M = parseInt(p[0].split(" ")[1]);
	let A = p[1].split(" ").map(Number);
	//文字列から10進数に変換するときはparseIntを使います
	//出力
	let sum=0;
	A.map(e=>sum+=e);
	console.log(N-sum<0?-1:N-sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30960