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

#define forn(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define MAX(a,b,c) max(max(a,b),c)
#define SumInRange(a,b) ((b*(b+1))/2)-(((a-1)*(a))/2)
#define Different_Random srand(time(NULL))
#define Random(a,b) (rand()%((b+1)-a))+a
#define __delete(v,n) v.erase(remove(v.begin(),v.end(),n),v.end())

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define newline cout << "\n";

#define read(x)    freopen(#x, "r", stdin)
#define write(x)   freopen(#x, "w", stdout)

#define all(x)     x.begin(), x.end()
#define dbg(args...)    {string sss(#args);sss+=',';cerr<<"-->";debugger::call(all(sss), args);cerr<<"\n";}
#define dbgA(A, n)      {cerr<<"-->"<<#A<<"=(";forn(i, n)cerr<<A[i]<<" ";cerr<<")\n";}
#define dbgA2(A, n, m)  {cerr<<"-->"<<#A<<"=\n";forn(i, n){forn(j, m){cerr<<setw(4)<<A[i][j]<<" ";}cerr<<"\n";}cerr<<"\n";}

struct debugger{
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest) {
        string b;
        for(; *it!=','; ++it) if(*it!=' ')b+=*it;
        cerr << b << " = " << a << " ";
        call(++it, ed, rest...);
    }
};

template<typename T>
T Max(T a) {return a;}

template<typename T, typename... Args>
T Max(T a, Args... args){ return a > Max(args...)? a : Max(args...);}

template<typename T>
T Min(T a) {return a;}

template<typename T, typename... Args>
T Min(T a, Args... args){ return a < Min(args...)? a : Min(args...);}


//int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
//int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//int knight_x[] = {2, 2, -2, -2, 1, 1, -1, -1};
//int knight_y[] = {1, -1, 1, -1, 2, -2, 2, -2};

/*
cout.precision(x);
cout << fixed;
*/

typedef long long int ll;
typedef unsigned long long int ull;
const double GOLD = (1.0 + sqrt(5.0))/2.0;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = 3.141592653589793;
const double E = 2.718281828459045;

ll expo(ll a, ll n)
{
    ll result = 1;
    while(n)
    {
        if(n%2) result*=a;
        a*=a; n/=2;
    }
    return result;
}

ll mod_expo(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    #ifdef TarekHasan
        read(input.txt);
    #endif // TarekHasan
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    string str; cin >> str;
    int counter = 0;
    int max_counter = 0;
    for(char c : str)
    {
        if(c=='S')
        {
            max_counter = max(max_counter,counter);
            counter=0;
        }
        else
            counter++;
    }
    cout << max(max_counter,counter) << endl;

    cerr << "time = " << clock() << " ms" << '\n';
    return 0;
}



Measured memory_bytes: 3676
R = [0 for i in xrange(0,200000)] 
n = int(raw_input())
for i in xrange(n):
	R[i] = int(input())
maxv = -2000000000
minv = R[0]
for j in xrange(1, n):
	maxv = max(maxv, R[j]-minv)
	minv = min(minv, R[j])
print maxv 

Measured memory_bytes: 10404
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  ll n;
  bool B=true;
  if(b<10) n=10*a+b;
  else if(b<100) n=100*a+b;
  else n=1000*a+b;
  FOR(i,0,1000){
    if(n==i*i){
      co("Yes")
      B=false;
      break;
    }
  }
  if(B) co("No")
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
 
//const int MOD=998244353;
 
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long n,sum=0;
    cin>>n;
    
    vector<long long> v(n), l(n);
    
    for(long long &i:v)cin>>i,sum+=i;
    
    long long g=n*(n+1)/2;
    
    if(sum%g){
        cout<<"NO";
        return 0;
    }
    long long op=sum/g;
    
    long long lds=0;
    for(int i=0; i<n; i++){
        l[i]=v[i]-v[i?i-1:n-1];
    }
    
    long long o2=0;
    for(int i=0; i<n; i++){
        if(op-l[i]<0 || (op-l[i])%n){
            cout<<"NO";
            return 0;
        }
        o2+=(op-l[i])/n;
        
    }
    cout<<(o2==op?"YES":"NO");
    return 0;
    
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    cout << "2018" <<'/' << S[5] << S[6] << S[7] << S[8] << S[9];
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	static Scanner s=new Scanner(System.in);

	static int mod=998244353;

	public static void main(String[] $){
		int n=s.nextInt();
		long a=s.nextInt(),b=s.nextInt(),k=s.nextLong(),r=0,nCa[]=new long[n+1];
		
		nCa[0]=1;
		for(int i=1;i<=n;++i)
			nCa[i]=nCa[i-1]*(n-i+1)%mod*pow(i,mod-2)%mod;

		for(int i=0;i<=n;++i) {
			int l=(int)((k-a*i)/b);
			if((k-a*i)%b==0&&0<=l&&l<=n) {
				r+=nCa[i]*nCa[l];
				r%=mod;
			}
		}
		
		System.out.println(r);
	}
	static long pow(long n,long a){
		if(a==1)
			return n;
		if(a%2==0){
			long d=pow(n,a/2);
			return d*d%mod;
		}
		return n*pow(n,a-1)%mod;
	}
}

Measured memory_bytes: 25300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.Petrozavodsk
{
    class TwoArray
    {
        public static void Main()
        {
            var n = int.Parse(ReadLine().Trim());
            var a = ReadLine().Trim().Split(' ').Select(_ => long.Parse(_));
            var b = ReadLine().Trim().Split(' ').Select(_ => long.Parse(_));
            var diff = a.Zip(b, (x, y) => x - y);
            var add = diff.Where(_ => _ <= 0).Select(_ => -_ / 2).Sum();
            var sub = diff.Where(_ => _ >= 0).Sum();
            if (diff.Sum() <= 0 && add >= sub)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }
}


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

int main() {
   string s, t;
   cin >> s >> t;
  for(int i=s.size()-t.size(); i>=0; --i){
   bool ok=true;
        for(int j=0; j< t.size(); ++j){
            if(s[i+j]!=t[j]&&s[i+j]!='?')ok=false;
        }
        if(ok){
            for(int j=0; j< t.size(); ++j){
                s[i+j]=t[j];
            }
          for(int i = 0; i < s.size(); i++){
            if(s.at(i) == '?') s.at(i) = 'a';
      }
     cout << s << endl;
     return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;


int main(void){
int num=1,tmp=1;
char camma;
map<int,int> mp;
map<int,int> mp2;

vector<int>v;
set<int>st;
vector<int>id;

for(;num!=0 || tmp!=0;){
	cin>>num;cin>>camma;cin>>tmp;
	if(num==0 && tmp==0)break;
	mp[num]=tmp;st.insert(tmp);
}
string s;
getline(cin,s);//read "\n"
while(getline(cin,s) && s.length()!=0){
	int integ=atoi(s.c_str());
	id.push_back(integ);
}

	size_t N=st.size();
	
	auto itr=st.begin();
	int cnt=N+1;mp2[*itr]=cnt;
	for(;itr!=st.end();itr++){
		mp2[*itr]=--cnt;
	}
	
	for(int i=0;i<id.size();i++){
		cout<<mp2[mp[id[i]]]<<endl;
	}

	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; ++i){
        if(i % d == 0)  ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> edge(N), edge_rev(N);
    for (ll i = 0; i < M; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        edge[u].push_back(v);
        edge_rev[v].push_back(u);
    }
    ll S, T;
    cin >> S >> T;
    S--; T--;
    constexpr ll INF = INT_MAX;

    vector<vector<ll>> edge_rev3(N);
    for (ll i = 0; i < N; i++) {

    }

    vector<ll> dist2cost(2 * M + 1, INF);
    dist2cost[0] = 0;
    for (ll i = 3; i <= 2 * M; i++) {
        for (ll j = 1; j <= 3; j++) {
            dist2cost[i] = min(dist2cost[i], dist2cost[i - j] + 1);
        }
    }

    vector<vector<ll>> cost(N, vector<ll>(3, INF));
    struct Element {
        ll node, cost;
        bool operator<(const Element& rhs) const {
            return cost < rhs.cost;
        }
        bool operator>(const Element& rhs) const {
            return cost > rhs.cost;
        }
    };
    priority_queue<Element, vector<Element>, greater<Element>> pq;

    cost[T][0] = 0;
    pq.push({ T, 0 });
    while (!pq.empty()) {
        Element t = pq.top();
        pq.pop();
        if (t.cost > cost[t.node][t.cost % 3]) {
            continue;
        }

        for (ll next : edge_rev[t.node]) {
            ll new_cost = t.cost + 1;

            if (new_cost < cost[next][new_cost % 3]) {
                cost[next][new_cost % 3] = new_cost;
                pq.push({ next, new_cost });
            }
        }
    }

    cout << (cost[S][0] == INF ? -1 : cost[S][0] / 3) << endl;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll INF = LLONG_MAX;
ll memo[100001],h[100001],n,k;

ll dp(ll i){
	if(i == 1) return 0;
	if(i< 1) return INF;
	if(memo[i]!=-1) return memo[i];
	/*
	memo[i] = min( (i-1>=1) ? dp(i-1)+abs(h[i]-h[i-1]) : INF,
				(i-2>=1) ? dp(i-2)+abs(h[i]-h[i-2]) : INF);
	*/
	memo[i] = LLONG_MAX;
	for(int j=1;j<=k;j++){
		if(i-j < 1) break;
		memo[i] = min(memo[i],dp(i-j)+abs(h[i]-h[i-j]));
	}
	return memo[i];
}

int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		memo[i] = -1;
	}
	ll ans = dp(n);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

void output(int x)
{
    int v = x;
    int count = 0;
    while (v) { v /= 10; count++;}
    for (int i = count; i < 6; i++) cout << 0;
    cout << x;
}

struct city
{
    int p, y, n, x;
};

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<city> C(M);
    for (int i = 0; i < M; i++)
    {
        cin >> C[i].p >> C[i].y;
        C[i].n = i;
    }
    sort(C.begin(), C.end(), [](city p, city q){ return ((p.p != q.p) ? (p.p < q.p) : (p.y < q.y)); });
    C[0].x = 1;
    for (int i = 1; i < M; i++) C[i].x = ((C[i].p == C[i - 1].p) ? C[i - 1].x + 1 : 1);
    sort(C.begin(), C.end(), [](city p, city q){ return (p.n < q.n); });
    for (auto i: C)
    {
        output(i.p);
        output(i.x);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  double result = 0;
  int n, k;
  cin >> n >> k;

  FOR(i, 1, n + 1)
  {
    double tmp = (double)1 / n;
    int score = i;
    while (score < k)
    {
      tmp *= (double)1 / 2;
      score *= 2;
    }
    result += tmp;
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>x(n);
	vector<int>y(n);
	vector<int>z(n);
	int p1=0;
	double p2=0;
	double p3=0;
	int p4=0;
	for (int i = 0;i < n;i++) { cin >> x[i]; }
	for (int i = 0;i < n;i++) { cin >> y[i]; }
	for (int i = 0;i < n;i++) { 
		if(x[i]>y[i])z[i]=x[i]-y[i];
		else z[i] = y[i] - x[i];
	}
	sort(z.begin(), z.end());
	p4 = z[n - 1];
	for (int i = 0;i < n;i++) {
		p1 = p1 + z[i];
		p2 = p2 + z[i] * z[i];
		p3 = p3 + z[i] * z[i] * z[i];
	}
	p2 = sqrt(p2);
	p3 = cbrt(p3);

	cout<<fixed<<setprecision(15) << p1 << endl;
	cout << fixed << setprecision(15) << p2 << endl;
	cout << fixed << setprecision(15) << p3 << endl;
	cout << fixed << setprecision(15) << p4 << endl;
	

	return 0;
}


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

int main() {
	long long a,b,v,w,t;
	cin >> a >> v >> b >> w >> t;
	long long f=abs(a-b),
	          m=t * (v-w);
	string k = "YES";
	if(f>m)
	{
		k = "NO";
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const double inf = 1000000007.0;
using namespace std;
int n, fa[33000][16], e, d[33000];
double cost[33000], f[33000];
struct poi { double x, y, z; } a[20];
struct edge { int u, v; double cst; } b[300];
struct epoch { int x, y; } opt[33000];
double sqr(double x) { return x * x; }
double getdis(int i, int j) {
	return sqrt(sqr(a[i].x - a[j].x) + sqr(a[i].y - a[j].y));
}
int getfa(int c, int x) { 
	if (fa[c][x] == x) return x;
	return fa[c][x] = getfa(c, fa[c][x]);
}
int count(int ave) {
	int ret = 0;
	for ( ; ave; ave /= 2) ret += ave & 1;
	return ret;
}
void dfs(int p, int st, int sum) {
	if (p > n) {
		d[++ d[0]] = sum;
		return ;
	}
	dfs(p + 1, st, sum);
	if ((st >> (p - 1)) & 1) return; 
	dfs(p + 1, st, sum + (1 << (p - 1)));
}
bool cmp(edge a, edge b) { return a.cst < b.cst; }
bool _cmp(epoch a, epoch b) { return a.x < b.x; }
int main() {
	scanf("%d", &n);
	rep(i, 1, n) scanf("%lf%lf%lf", &a[i].x, &a[i].y, &a[i].z);
	rep(i, 0, (1 << n) - 1) rep(j, 1, n) fa[i][j] = j;
	rep(i, 0, (1 << n) - 1) cost[i] = 0;
	rep(i, 1, n) rep(j, i + 1, n) 
		++ e, b[e].u = i, b[e].v = j, 
		b[e].cst = getdis(i, j);
	sort(b + 1, b + e + 1, cmp);
	rep(j, 1, e) rep(i, 1, (1 << n) - 1) 
		if (((i >> (b[j].u - 1)) & 1) && ((i >> (b[j].v - 1)) & 1)) {
			int x = getfa(i, b[j].u), y = getfa(i, b[j].v);
			if (x != y) cost[i] += b[j].cst, fa[i][x] = y;
		}
	rep(i, 1, (1 << n) - 1) {
		double ret = 0; int k = 0;
		rep(j, 1, n) if ((i >> (j - 1)) & 1) ret += a[j].z, ++ k;
		cost[i] = (ret - cost[i]) / k;
	}
	f[0] = inf; int tot = 0;
	rep(i, 1, (1 << n) - 1) ++ tot, opt[tot].x = count(i), opt[tot].y = i;
	sort(opt + 1, opt + tot + 1, _cmp);
	rep(i, 1, tot) {
		d[0] = 0, dfs(1, opt[i].y, 0);
		rep(j, 1, d[0]) f[d[j] | opt[i].y] = max(f[d[j] | opt[i].y], min(f[d[j]], cost[opt[i].y]));
	}
	printf("%.12lf\n", f[(1 << n) - 1]);
	return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define ABS(x) ((x) > 0 ? (x) : -(x))
#define MAX_N (1000)
#define INF (1000000000)

using namespace std;

int main(int argc, char *argv[]) {
  int N, T, A, H[MAX_N];
  scanf("%d %d %d", &N, &T, &A);
  for (int i = 0; i < N; i++) {
    scanf("%d", &H[i]);
  }

  int i_min = -1;
  double min_diff = INF;
  for (int i = 0; i < N; i++) {
    double temp = T - 0.006 * H[i];
    double diff = ABS(temp - A);
    if (diff < min_diff) {
      min_diff = diff;
      i_min = i;
    }
  }
  printf("%d\n", i_min + 1);
  
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f;
const double eps = 1e-9;

int n;
int a[maxn];

int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n);
        int ans1=-1,ans2=-1;
        for(int i=n-2;i>=0;i--)
        {
            if(a[i]==a[i+1]&&ans1==-1)
            {
                ans1=a[i];
                i--;
            }
            else if(a[i]==a[i+1]&&ans2==-1)
            {
                ans2=a[i];
                i--;
            }
        }
        if(ans1==-1||ans2==-1) puts("0");
        else
        {
            ll ans=(ll)ans1*ans2;
            printf("%lld\n",ans);
        }
    }
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int st = sc.nextInt();
        int ed = sc.nextInt();
        int x = sc.nextInt();
        int yakusu = 0;
        
        for(int i=st; i<=ed; i++){
            if(x%i == 0){
                yakusu++;
            }
        }
        
        System.out.println(yakusu);
            
    }
}


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

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(x) x.begin(),x.end()

struct team {
    int id, pro, tm;
    team(int id, int pro, int tm) : id(id), pro(pro), tm(tm) {}
    bool operator < (const team& a) const {
	if (pro != a.pro) { return pro < a.pro; }
	if (tm != a.tm) { return tm > a.tm; }
	if (id != a.id) { return id < a.id; }
    }
};

vector<team> vec;

int M, T, P, R;
int pn[50][10];
int ac[50][10];

int main() {
    while (scanf("%d %d %d %d", &M, &T, &P, &R), M) {
	vec.clear();
	memset(pn, 0, sizeof(pn));
	memset(ac, -1, sizeof(ac));

	rep(i, R) {
	    int m, t, p, j;
	    scanf("%d %d %d %d", &m, &t, &p, &j);
	    --t; --p;
	    if (j) ++pn[t][p];
	    else ac[t][p] = m;
	}

	rep(i, T) {
	    int sol = 0, tm = 0;
	    rep(j, P) {
		if (ac[i][j] == -1) continue;
		++sol;
		tm += ac[i][j] + pn[i][j] * 20;
	    }
	    vec.push_back(team(i + 1, sol, tm));

	    //cout << i + 1 << " " << sol << " " << tm << endl;
	}

	sort(ALL(vec));
	reverse(ALL(vec));

	int i;
	for (i = 0; i < T; ++i) {
	    if (i) printf(",");
	    team &tt = vec[i];
	    int j = i;

	    while (j + 1 < T && vec[j + 1].pro == vec[i].pro && vec[j + 1].tm == vec[i].tm) ++j;

	    for (int k = i; k <= j; ++k) {
		if (k != i) printf("=");
		printf("%d", vec[k].id);
	    }
	    i = j;
	}
	puts("");
    }
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

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

typedef long long ll;

using namespace std;

int main() {
    
    int n;
    cin >> n;
    
    if(n%2==0){
        cout << n << endl;
    }else{
        cout << n * 2 <<  endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;


public class Main{
	public static void main(String args[]) throws IOException{
		Scanner bf = new Scanner(System.in);
		while(true){
			int num = Integer.parseInt(bf.next());
			int sum = Integer.parseInt(bf.next());
			if(num == 0 && sum == 0) break;
			int min = 0;
			System.out.println(count(num,sum,min));
		}
	}

	static int count(int num, int sum, int min){
		if(min > 9) return 0;
		if(sum == min){
			if(num == 1) return 1;
			else return 0;
		}
		if(sum < min) return 0;
		return count(num-1, sum-min, min+1)+count(num, sum, min+1);
	}
}

Measured memory_bytes: 17940
n = gets.to_i
m = gets.to_i

E = Hash.new {|h,k|
	h[k] = Array.new
}

m.times {
	a,b = gets.split.map(&:to_i)
	E[a] << b
}


L = []
def visit(node,visited)
	unless visited[node]
		visited[node] = true
		E[node].each {|n|
			visit(n,visited)
		}
		L << node
	end
end

t = {}
(1..n).each {|x|
	visit(x,t)
}
L.reverse!
b = L.each_cons(2).all? {|a,b|
	E[a].include? b
}
puts L * "\n"
puts b ? 0 : 1

Measured memory_bytes: 11852
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;
    string s[112];
    for (int i = 0; i < n;i++){
        cin >> s[i];
    }
    sort(s, s + n);
    for (int i = 0; i < n;i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define	fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(n,arr)  for(int i=0;i<n;i++)cin>>arr[i]; // 0 => n
#define	pi 3.14159265358979323846
#define	endl "\n"
#define f first
#define s second

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5+5 , oo=0x3f3f3f3f , mod=1e9+7;

int main(){
	int a,b;
	cin>>a>>b;
	if(a<=9 && b<=9)
		cout<<a*b;
	else
		cout<<-1;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL n, q, a[100010], x[100010];
vector<LL> bound;
LL sum[100010], sumHalf[100010];

void init() {

}

void input() {
  cin >> n >> q;
  REP(i, n) cin >> a[i];
  REP(i, q) cin >> x[i];
}

void solve() {
  bound.clear();
  bound.push_back((1LL<<50)*-1);
  for(LL i = 1; ; i++) {
    LL r = n-1-i;
    LL l = n-1-i*2;
    if (l < 0) break;
    bound.push_back((a[l]+a[r])/2*-1);
  }
  sum[0] = 0;
  sumHalf[0] = 0;
  FOR(i, 1, n+1) {
    sum[i] = sum[i-1] + a[i-1];
    if (i==1) sumHalf[i] = a[i-1];
    else sumHalf[i] = sumHalf[i-2] + a[i-1];
  }
  REP(i, q) {
    LL b = upper_bound(bound.begin(), bound.end(), -x[i]) - bound.begin();
    // cout << b << endl;
    LL s = sum[n] - sum[n-b];
    LL remain = n-b*2;
    if (remain > 0) s += sumHalf[remain];
    cout << s << endl;
  }
}

int main() {
	init();
	input();
	solve();
	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 3e5 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

ll n, a[N], s[61][N];
ll ans;

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));
                
	scanf("%lld", &n);

    for(int i = 1; i <= n; i++)           
		scanf("%lld", &a[i]);

	reverse(a + 1, a + n + 1);

	for(int i = 1; i <= n; i++) {
		ll res = 0;
		for(int j = 0; j < 60; j++) {
		    ll cur = (1ll<<j);
		    cur %= mod;
			if(a[i] & (1ll<<j)) {
				cur = (cur * (i - 1 - s[j][i - 1])) % mod;
			} else {
				cur = (cur * s[j][i - 1]) % mod;
			}
			res = (res + cur) % mod;
		}

     	ans = (ans + res) % mod;

		for(int j = 0; j < 60; j++)
			if(a[i] & (1ll<<j)) {
				s[j][i] = s[j][i - 1] + 1;
			} else {
				s[j][i] = s[j][i - 1];
			}
	}		

	cout << ans;
		
    return 0;
}

Measured memory_bytes: 145664
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B=map(int,input().split())
    ans=[['#']*100 for _ in range(50)]+[['.']*100 for _ in range(50)]
    A-=1
    B-=1
    y,x=1,1
    for _ in range(A):
        ans[y][x]='.'
        x+=2
        if x>=100:
            if x%2:
                y+=1
                x=2
            else:
                y+=2
                x=1
    y,x=51,1
    for _ in range(B):
        ans[y][x]='#'
        x+=2
        if x>=100:
            if x%2:
                y+=1
                x=2
            else:
                y+=2
                x=1
    print(100,100)
    for row in ans:
        print(''.join(row))
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int MAXN=3e5+5;
int n,m;
int ans[MAXN];
namespace Seg
{
	#define ls (x<<1)
	#define rs (x<<1|1)
	int add[MAXN<<2],sum[MAXN<<2];
	void down(int x,int l,int r)
	{
		if(!add[x]) return;
		int mid=l+r>>1;
		add[ls]+=add[x];
		add[rs]+=add[x];
		sum[ls]+=add[x]*(mid-l+1);
		sum[rs]+=add[x]*(r-mid);
		add[x]=0;
	}
	void up(int x)
	{
		sum[x]=sum[ls]+sum[rs];
	}
	void fix(int x,int l,int r,int ql,int qr)
	{
		if(ql<=l&&r<=qr)
		{
			add[x]++;
			sum[x]+=(r-l+1);
			return;
		}
		int mid=l+r>>1;
		down(x,l,r);
		if(ql<=mid) fix(ls,l,mid,ql,qr);
		if(qr>mid) fix(rs,mid+1,r,ql,qr);
		up(x);
	}
	int query(int x,int l,int r,int pos)
	{
		if(l==r) return sum[x];
		down(x,l,r);
		int mid=l+r>>1;
		if(pos<=mid) return query(ls,l,mid,pos);
		else return query(rs,mid+1,r,pos);
	}
}
pair<int,int>p[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,l,r;i<=n;i++)
		scanf("%d%d",&l,&r),p[i]=make_pair(r-l+1,l);
	sort(p+1,p+n+1);
	int cnt=1;
	for(int i=1;i<=m;i++)
	{
		while(cnt<=n&&p[cnt].first<i)
		{
			Seg::fix(1,1,m,p[cnt].second,p[cnt].first+p[cnt].second-1);
			cnt++;
		}
		int ans=n-cnt+1;
		for(int j=i;j<=m;j+=i)
			ans+=Seg::query(1,1,m,j);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
  int n;
  cin>>n;

  int a[n];
  rep(i,n){
     cin>>a[i];
  }
  int ans=100000000;
  for(int i=1;i<=100;i++){
     int sum=0;
     rep(j,n){
        
        sum+=pow((a[j]-i),2);
     }
     
     ans=min(sum,ans);
  }
  cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    string s;
    cin>>s;
    cout<<s.substr(0,4)+" "+s.substr(4)<<endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [list(map(str, input())) for i in range(h)]
ans = s

di = [1, 0, -1, 0, 1, -1, -1, 1]
dj = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        cnt = 0
        for d in range(8):
            if i + di[d] <0 or i + di[d] > h - 1 or j + dj[d] < 0 or j + dj[d] > w - 1:
                continue
            if s[i + di[d]][j +dj[d]] == '#':
                cnt += 1
        ans[i][j] = cnt

for i in range(h):
    print(''.join(map(str, ans[i])))


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        private static Dictionary<string,int> dic = new Dictionary<string, int>();

        static void Solve()
        {

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

Measured memory_bytes: 13152
using System;

public class Program
{
    private long N;

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        string s = sc.Next();
        string t = sc.Next();
        
        char[] ans = new char[2*n];
        for (int i = 0; i < n; i++)
        {
            ans[i * 2] = s[i];
            ans[i * 2 + 1] = t[i];
        }
        
        Console.WriteLine(new string(ans));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

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

constexpr ll MOD = 1e9 + 7;

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    std::unordered_map<ll, ll> umap;

    auto func = [&](ll n) -> void {
        for (ll i = 2; n > 1; i++) {
            if (n % i != 0) continue;
            ll j = 0; for (; n % i == 0; n /= i) j++;
            umap[i] += j;
        }
    };

    for (ll i = 1; i <= n; i++)
        func(i);

    ll ans = 1;
    for (auto i : umap)
        (ans *= i.second + 1) %= MOD;

    std::cout << ans << '\n';
}


Measured memory_bytes: 3604
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(I, LIM) for (int I = 0; I < (LIM); I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;

constexpr int MOD = 10000007;
constexpr long INF = LONG_MAX;

vector<long> divisor(long n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

struct init {
  init() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // cout<<fixed<<setprecision(20);
  }
} init;

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

int main() {
  string s;
  cin>>s;

  int ans=0;
  if(s[0] == 'R' or s[1] == 'R' or s[2] == 'R'){
    ans=1;
  }
  if(s[0] == 'R' and s[1] == 'R'){
    ans =2;
  }
  if(s[1] == 'R' and s[2]=='R'){
    ans=2;
  }
  if(s[0] == 'R' and s[1] == 'R' and s[2] == 'R'){
    ans=3;
  }
  cout<<ans<<endl;
}


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

int main(){
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	// cout << d << " " << r << " " << f << endl;
	printf("%d %d %0.5lf\n", d, r, f);
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rt register int
#define all(it) it.begin(), it.end()
#define rep(it, f, e) for (rt it = f; it <= e; ++it)
#define per(it, f, e) for (rt it = f; it >= e; --it)
const int MAXN = 1e5;
int a[MAXN][3];
int dp[MAXN][3];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	rep (i, 1, n) {
		rep (j, 0, 2) {
			cin >> a[i][j];
		}
	}
	rep (i, 1, n + 1) {
		rep (j, 0, 2) {
			rep (k, 0, 2) {
				if (j == k) continue;
				dp[i][j] = max(dp[i - 1][k] + a[i][j], dp[i][j]);
			}
		}
	}
	cout << max(dp[n + 1][0], dp[n + 1][1]) << endl;
	return 0;
}

Measured memory_bytes: 2560
int main(void){
	int p[10*10*10*10*10];
	int N, K, i, m;
	
	
	
	do{
		scanf("%d", &N);
	}while(N < 1 || N > 10*10*10*10*10);
	do{
	scanf("%d", &K);
}while(K < 1|| K > 500);
for(i = 0; i < N; i++){
	do{
		scanf("%d", &p[i]);
	}while(p[i]<1||p[i]>500);
}
m = 0;
for(i=0; i<N; i++){
	if(p[i]>=K){
		m += 1;
	}
}
printf("%d", m);

return 0;
}
		

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  VI a(4);
  VI x = {1, 9, 7, 4};
  VI y(4);
  REP (i, 4) {
    int a; cin >> a;
    REP (k, 4) {
      if (a == x[k]) y[k] = 1;
    }
  }
  REP (i, 4) {
    if (y[i] == 0) {
      cout << "NO" << endl; return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), m = in.nextInt();
			long[][] num = new long[n][8];
			for (int i = 0; i < n; i++) {
				long x = in.nextLong();
				long y = in.nextLong();
				long z = in.nextLong();
				num[i] = new long[]{x+y+z, x+y-z, x-y+z, x-y-z, -x+y+z, -x+y-z, -x-y+z, -x-y-z};
			}
			long ans = -INF;

			for (int i = 0; i < 8; i++) {
				long tmp = 0;
				List<Long> tmpList = new ArrayList<>();
				for (int j = 0; j < n; j++) {
					tmpList.add(num[j][i]);
				}

				Collections.sort(tmpList, Comparator.reverseOrder());
				for (int j = 0; j < m; j++) {
					tmp += tmpList.get(j);
				}

				ans = Math.max(ans, tmp);
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 23084
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	s = String[]
	p = Int[]
	for i in 1:n
		a,b = readline() |> split
		push!(s,a)
		push!(p,parseInt(b))
	end
	t = String[]
	for i in 1:n
		if !(s[i] in t)
			push!(t,s[i])
		end
	end
	t = sort(t)
	d = Dict{String,Int}()
	for i in 1:length(t)
		d[t[i]] = i
	end
	a = Array{Int}(3,n)
	for i in 1:n
		a[1,i] = i
		a[2,i] = d[s[i]]
		a[3,i] = p[i]
	end
	a = sortcols(a,by=x->x[3],rev=true)
	a = sortcols(a,by=x->x[2])
	for i in 1:n
		println(a[1,i])
	end
end

main()


Measured memory_bytes: 127748
N=int(input())
A=[1,6,36,6**3,6**4,6**5,6**6,9,81,9**3,9**4,9**5]
B=[0]+[N]*N
i=0
while i<=N:
    for a in A:
        if a+i<=N:
            B[a+i]=min(B[a+i],B[i]+1)
    i+=1
print(B[N])

Measured memory_bytes: 10436
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    for (int i = 0; i < N; i++)
    {
        
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans <<" \n";
}

Measured memory_bytes: 3984