akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,k;
    while(cin >> n >> k, n){
        vi a(k);
        rep(i,k)cin >> a[i];
        sort(all(a));
        int cnt = 1;
        vp v;
        loop(i,1+!a[0],k){
            if(a[i-1]+1 == a[i])cnt++;
            else{
                v.push_back(pii(a[i-1]-cnt+1,cnt));
                cnt = 1;
            }
        }
        v.push_back(pii(a.back()-cnt+1,cnt));
        //rep(i,v.size())cout << v[i].first << " " << v[i].second << endl;
        int ans = 0;
        if(a[0]){
            rep(i,v.size())ans = max(ans, v[i].second);
        }else{
            rep(i,v.size())ans = max(ans, v[i].second+1);
            rep(i,v.size()-1){
                if(v[i].first+v[i].second + 1 == v[i+1].first){
                    ans = max(ans, v[i].second+v[i+1].second+1);
                }
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 100001
#define mod 1000000007
int main() {
        ll n, a;
        cin >> n>> a;
        ll ho =  a / 1000;
        ll x = 0, y = 0;
        bool b = 0;
        for (ll i = 0; i <= ho; i++) {
                for (ll j = 0; j <= ho; j++) {
                        if (i*9 + j*4 == ho-n && (n - i - j >= 0)) {
                                x = i;
                                y = j;
                                b = 1;
                                break;
                        }
                }
                if (b)
                        break;
        }
        if (!b) {
                cout << "-1 -1 -1";
        }else
                cout << x << " "<< y<< " " << n-x-y;
        return 0;
}


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

using namespace std;

#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 fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	int n;
	while (cin >> n, n) {
		int cnt[7] = {};
		REP(i, n) {
			int a;
			scanf("%d", &a);
			
			a /= 10;
			if (a >= 6) cnt[6]++;
			else cnt[a]++;
		}
		
		REP(i, 7) cout << cnt[i] << endl;
	}
	return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    for (int i=0;i<N;i++) cin >> A[i];
    for (int i=0;i<N;i++) cin >> B[i];
    for (int i=0;i<N;i++) cin >> C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    ll ans = 0;
    for (int i=0;i<N;i++){
        auto iA = lower_bound(A.begin(),A.end(),B[i]);
        if (iA == A.begin()) continue;
        auto iC = upper_bound(C.begin(),C.end(),B[i]);
        if (iC == C.end()) continue;
        ans += (iA - A.begin())*(N - (iC - C.begin()));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4488
def main():
    buf = input()
    buflist = buf.split()
    sx = int(buflist[0])
    sy = int(buflist[1])
    tx = int(buflist[2])
    ty = int(buflist[3])
    xdiff = tx - sx
    ydiff = ty - sy
    movement = ""
    movement += "R" * xdiff
    movement += "U" * ydiff
    movement += "L" * xdiff
    movement += "D" * ydiff
    movement += "D"
    movement += "R" * (xdiff+1)
    movement += "U" * (ydiff+1)
    movement += "L"
    movement += "U"
    movement += "L" * (xdiff+1)
    movement += "D" * (ydiff+1)
    movement += "R"
    print(movement)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace  std;
#define f(i,n) 		for(i=0;i<n;i++)
#define fr(i,n,a) 	for(i=n;i>=a;i--)
#define fa(i,a,n) 	for(i=a;i<n;i++)
#define deb(x)		cout<<#x<<" "<<x<<endl;
#define deb2(x,y)	cout<<#x<<","<<#y<<" "<<x<<","<<y<<endl;
#define buf(x)		cout<<"Check"<<x<<endl;
#define ll			long long int 
#define ft			first
#define s			second
#define pb			push_back
#define mp			make_pair
#define d			double
#define all(v)		v.begin(),v.end()	
#define et(v)		for(auto itr:v)
inline void p(int x[],int n)	{	int i;f(i,n)cout<<x[i]<<" ";cout<<endl; }


 


void solve()
{  	
	ll N,K,i,j,k,a=0,b=0;
	cin>>N;
	vector<ll> arr(N);
	//set<ll> s;
	f(i,N)
	{
		cin>>arr[i];

	}
	sort(all(arr));

	f(i,N)
	{
		fa(j,i+1,N)
		{
			fa(k,j+1,N)
			{
				if((arr[i]+arr[j]>arr[k])&&(arr[i]!=arr[j]&&arr[j]!=arr[k]))
					++a;
			}
		}
	}
	cout<<a;
}
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1,c=1;
	//cin>>t;
	while(t--)
	{
		

		//cout<<"Case #"<<c++<<": "<<endl;
		solve();
		cout<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int solve(int n, int x) {
  int ans = 0;
  for (int i = 1; i <= n - 2; i++) {
    for (int j = i + 1; j <= n - 1; j++) {
      for (int k = j + 1; k <= n; k++) {
        if (i + j + k == x) {
          ans++;
        }
      }
    }
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n, x;
  cin >> n >> x;
  while (n != 0 || x != 0) {
    cout << solve(n, x) << '\n';
    cin >> n >> x;
  }

  return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;

	int nums[5] = {A, B, C, D, E};

	for (size_t i = 0; i < sizeof(nums); i++)
	{
		if (nums[i] == 0)
		{
			cout << (i + 1) << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3136
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int a[maxn];
int main()
{
    int n;
    cin >> n;
    map<int , int > mp;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        mp[a[i]+i]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(mp.count(-(a[i]-i)))
        ans+=(1ll*mp[-(a[i]-i)]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll x;
int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0),cout.tie(0);
	cin>>x;
	ll now=100;
	for(int i=1; i<=10000; i++) {
		now=now+now/100;
		if(now>=x) {
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int skara[100010];
int sdone[100010];
int tkara[100010];
int tdone[100010];
vector<int> edge[100010];
queue<int> q1, q2;

void bfss(int v)
{
	sdone[v]=1;
	q1.push(v);
	while(!q1.empty())
	{
		int u=q1.front();
		q1.pop();
		rep(i, edge[u].size())
		{
			if(sdone[edge[u][i]]==0)
			{
				skara[edge[u][i]]=skara[u]+1;
				sdone[edge[u][i]]=1;
				q1.push(edge[u][i]);
			}
		}
	}
}

void bfst(int v)
{
	tdone[v]=1;
	q2.push(v);
	while(!q2.empty())
	{
		int u=q2.front();
		q2.pop();
		rep(i, edge[u].size())
		{
			if(tdone[edge[u][i]]==0)
			{
				tkara[edge[u][i]]=tkara[u]+1;
				tdone[edge[u][i]]=1;
				q2.push(edge[u][i]);
			}
		}
	}
}

int main()
{
	int n, m, s, t, x, y;
	cin >> n >> m >> s >> t;
	rep(i, m)
	{
		cin >> x >> y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	bfss(s);
	bfst(t);
	int kyori=skara[t];
	kyori-=2;
	int ss[100010]={}, tt[100010]={};
	reps(i, n)
	{
		ss[skara[i]]++;
		tt[tkara[i]]++;
	}
	ll ans=0;
	if(skara[t]>2)
	{
		ans+=(ss[kyori]+tt[kyori]);
		reps(j, kyori-1) ans+=((ll)ss[j])*((ll)tt[kyori-j]);
	}
	else if(skara[t]==2) ans=1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11760
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int A,B,K,p=0;
	cin>>A>>B>>K;
	for(int i=min(A,B);i>=1;i--)
	{
		if(A%i==0&&B%i==0)
		{
			p++;
			if(p==K)
			{
				cout<<i<<endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
import numpy as np
from sys import stdin


def get_result(data):
    A = sorted(data[1])
    ans = 1
    for val in A:
        ans = ans * val
        if ans > 10**18:
            ans = -1
            break
        elif ans == 0:
            ans = 0
            break
    return ans


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 41932
<?php

fscanf(STDIN,"%d %d",$height, $width);

$max = $height + $width -1;
$map[] = array_fill(0,$width+2,"#");
for($i=0;$i<$height;$i++){

    $map[] = str_split("#".trim(fgets(STDIN))."#");

}
$map[] = array_fill(0,$width+2,"#");

$for_h = array_fill(1,$width,[0,0]);
$ans = 0;
for($h=1;$h <= $height; $h++){
    $for_w = [0,0];

    for($w=1;$w<=$width;$w++){
        if($map[$h][$w] == "#"){
            continue;
        }elseif($for_w[0] < $w){
            $w_temp=$w;
            $w_count = 0;
            while($map[$h][$w_temp] == "."){
                $w_count++;
                $w_temp++;
            }
            $for_w = [$w_temp - 1, $w_count];
        }else{
            $w_count = $for_w[1];
        }
        if($for_h[$w][0] < $h){
            $h_temp = $h;
            $h_count = 0;
            while($map[$h_temp][$w] == "."){
                $h_count++;
                $h_temp++;
            }
            $for_h[$w] = [$h_temp - 1,$h_count];
        }else{
            $h_count = $for_h[$w][1];
        }
        $ans = max($ans, ($w_count + $h_count -1));
        if($ans == $max){
            echo $max;
            exit;
        }
    }
}
echo $ans;

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

int main(){
    string s;
    cin >> s;
    int a = 0;
    for(int i = 0;i < s.size();i++) if(s[i] == 'p') a--;
    cout << a+s.size()/2 << endl;
}

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

int main() {
  char b;
  cin >> b;
  switch (b) {
    case 'A':
      b = 'T';
      break;
    case 'T':
      b = 'A';
      break;
    case 'C':
      b = 'G';
      break;
    case 'G':
      b = 'C';
      break;
  }

  cout << b << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
				using namespace std;
				#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
				#define ll long long int
				#define pb push_back
				#define fe first
				#define se second
				#define endl "\n"
				#define pii pair<int, int>

				#define PI 3.14159265358979323846
				const int N = 1e5 + 10;
				int a,b,k,cnt;	   
               
               vector<int> v;
				void solve() {
					
					cin>>a>>b>>k;
					for(int i=1;i<=100;i++) {
						  if(a%i==0 && b%i==0) {					  
							 
								     v.pb(i);							   						      
							  }						     
						}
						
					cout<<v[v.size()-k];
						
				}	  
					
				
					   

				int main() {
				  cool;
				  int t = 1;
				  while (t--)
					solve();

				  return 0;
				}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

cnt = 0
color = [False] * 8
for v in a:
    if v >= 3200:
        cnt += 1
    else:
        color[v//400] = True

num = color.count(True)
print(max(num, 1), num + cnt)

Measured memory_bytes: 61504
// Cats and Dogs

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> x_0(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    x_0 = x;
    sort(x_0.begin(), x_0.end());
    int n1 = x_0[x_0.size()/2 - 1];
    int n2 = x_0[x_0.size()/2];

    for (int i = 0; i < n; i++) {
        if (n1 == n2) {
            cout << n1 << endl;
            continue;
        }
        if (x[i] <= n1) {
            cout << n2 << endl;
            continue;
        }
        if (n2 <= x[i]) {
            cout << n1 << endl;
            continue;
        }
    }

    return 0;
}


Measured memory_bytes: 3712
s = str(input())
ans = 0
i = 0
cnt = 0
while i < len(s) - 1:
    if s[i] == 'A':
        cnt += 1
        i += 1
    elif s[i] == 'B':
        if s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
    else:
        cnt = 0
        i += 1
print(ans)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9+7;
int N, K;
vector<int> G[100005];

int ans[100005];

void dfs(int x, int px, int pre2, int pre1){
  
  ans[x] = K - (pre2 + pre1);
  
  int s = 0;
  
  for(int nx : G[x]){
    
    if(nx==px) continue;
    
    dfs( nx, x, s + pre1, 1 );
    
    s++;
    
  }
  
}

signed main(){
  
  cin>>N>>K;
 
  for(int i=0;i<N-1;i++){
    int a, b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  
  dfs( 0, 0, 0, 0 );
  
  int A = 1;

  for(int i=0;i<N;i++){
    if( ans[i] < 0 ){
      cout<<0<<endl;
      return 0;
    }
    A = A*ans[i] %mod;
  }
  cout<<A<<endl;
  
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> vec;
  for (int i = min(a, b); i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      k--;
    }
    if (k == 0) {
      cout << i << endl;
      return 0;
    }
  }
  assert(false);
}



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

using namespace std;

int main() {
	char a, b;
	cin>>a>>b;
    int va=(a>='0' && a<='9')?a-'0':a-'A'+10;
    int vb=(b>='0' && b<='9')?b-'0':b-'A'+10;
    if (va<vb) cout<<"<"<<endl;
    else if (va>vb) cout<<">"<<endl;
    else cout<<"="<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

long long dp[5003];

bool compare(const pair<int,int>& a, const pair<int,int>& b){
  return (a.first + a.second < b.first + b.second and a.first < b.first) or a.first + a.second < b.first + b.second;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<pair<int,int> > a(N);
  REP(i,N){
    cin >> a[i].second >> a[i].first;
  }
  sort(a.begin(), a.end(),compare);
  fill(dp, dp + 5003, -1);
  dp[0] = 0;
  REP(i,N){
    int p = a[i].first;
    int h = a[i].second;
    for(int j = i; j >= 0; j--){
      if(dp[j] >= 0 && h >= dp[j]){
        if(dp[j + 1] == -1){
          dp[j + 1] = dp[j] + p;
        }else{
          dp[j + 1] = min(dp[j] + p, dp[j + 1]);
        }
      }
    }
  }
  for(int i = N; i >= 0; i--){
    if(dp[i] != -1){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 384
'use strict';
const inputRaw = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
const INPUT_LIST_LENGTH_INDEX = 0;
const INPUT_LIST_INDEX = 1;
const INPUT_LIST_DELIMITER = " ";
const inputListLength = parseInt(inputRaw[INPUT_LIST_LENGTH_INDEX]);
const inputList = inputRaw[INPUT_LIST_INDEX].split(INPUT_LIST_DELIMITER);

const process = (inputList, inputListLength) => {
  // pattern: min(b) in (sum(A-b)) === median of sorted A

  // sum(A - (b + i)) === sum ((A - i) - b)
  // convert list to A-i
  for (let i=0;i<inputListLength;i++) {
    inputList[i] = parseInt(inputList[i])-i;
  }

  inputList.sort((prev,next) => prev-next);

  const median = inputList[Math.floor(inputListLength/2)];

  return inputList.reduce((acc, currentItem) => acc + Math.abs(currentItem-median), 0);
}

console.log(process(inputList, inputListLength));

Measured memory_bytes: 33116
import sys
input = sys.stdin.readline
def main():
    K = int(input())
    A,B = map(int,input().split())
    l = A//K
    if K*l == A:
        print('OK')
    else:
        if K*(l+1)<=B:
            print('OK')
        else:
            print('NG')
if __name__ == "__main__":
    main()

Measured memory_bytes: 9184
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//Bismillahirrahmanirrahim
#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k;
pair<lo,lo> p[li];
string s;
vector<int> v;

int main(){
	scanf("%lld %lld",&n,&m);
	FOR{
		scanf("%lld %lld",&p[i].fi,&p[i].se);
	}
	sort(p+1,p+n+1);
	FOR{
		if(b==m) break;
		cev+=min(p[i].se,m-b)*p[i].fi;
		b+=min(p[i].se,m-b);
	}
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
    long long int N,M,i,sum;
    scanf("%lld %lld", &N, &M);
    long long int arr[M];
    sum = 0;
    for(i=0;i<M;i++){
        scanf("%lld", &arr[i]);
        sum = sum + arr[i];
    }
    if(sum <= N){
        printf("%lld\n", N-sum);
    }
    else if(sum > N){
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 100005;
const LL INF = 0x3f3f3f3f3f3f3f3f;

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

template <typename T> inline void cmin(T &x, T y) {
	if (x > y) x = y;
}
 
int n, m, a[MAXN], b[MAXN], d[MAXN];
int p[MAXN], f[MAXN];
vector<int> e[MAXN], t[MAXN];
LL siz[MAXN], dp[MAXN];

inline bool dcmp(int x, int y) {
	return (d[x] == d[y])? (x < y) : (d[x] < d[y]);
}

int getf(int u) {
	return (f[u] == u)? u : f[u] = getf(f[u]);
}

void DFS(int u) {
	for (auto v : t[u]) {
		DFS(v);
		siz[u] += siz[v];
	}
	if (t[u].size() == 0) {
		dp[u] = b[u] + d[u];
	} else {
		dp[u] = INF;
		for (auto v : t[u]) {
			cmin(dp[u], max(dp[v] + b[u], (LL)a[u]) + siz[u] - siz[v]);
		}
	}
	siz[u] += b[u];
}

void init() {
	read(n); read(m);
	for (int i = 1; i <= n; ++i) {
		read(a[i]); read(b[i]);
	}
	for (int i = 1, u, v; i <= m; ++i) {
		read(u); read(v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
}

void solve() {
	for (int i = 1; i <= n; ++i) {
		d[i] = max(0, a[i] - b[i]);
		p[i] = f[i] = i;
	}
	sort(p + 1, p + n + 1, dcmp);
	for (int i = 1; i <= n; ++i) {
		int u = p[i];
		for (auto v : e[u]) {
			int fv = getf(v);
			if (u == fv || dcmp(u, fv)) continue;
			t[u].push_back(fv);
			f[fv] = u;
		}
	}
	DFS(p[n]);
	printf("%lld\n", dp[p[n]]);
}

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


Measured memory_bytes: 17916
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=200005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    ll n,k;
    cin >> n >> k;
    ll a[n+1];
    rep(i,0,n+1) a[i]=0;
    rep(i,0,k) {
    	ll x;
    	cin >> x;
    	rep(i,0,x) {
    		ll y;
    		cin >> y;
    		a[y]++;
    	}
    }
    ll c=0;
    rep(i,1,n+1) if(a[i]==0) c++;
    ret(c);
}

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

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

int main()
{
    // operation A and B: greedy, enumerate no touch zone
    // operation C and D: if started, means no operation A and B anymore

    int n, k;
    scanf("%d %d", &n, &k);

    int inp[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &inp[i]);

    int mx = 0;
    // no touch zone size
    for (int i = max(0, n - k); i < n; i++) {
        // enumerate the left bound
        for (int l = 0; l < n && l + i <= n; l++) {
            vector<int> in;
            int sum = 0;
            for (int x = 0; x < n; x++) {
                if (l <= x && x < l + i)
                    continue;
                in.push_back(inp[x]);
                sum += inp[x];
            }

            sort(in.begin(), in.end());

            int rem = k - (n - i);
            for (int x = 0; x < rem && x < (int)in.size(); x++) {
                if (in[x] < 0)
                    sum -= in[x];
                else
                    break;
            }

            // printf("%d %d %d\n", l, i, sum);
            mx = max(mx, sum);
        }
    }

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

    return 0;
}


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

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

Node* find(Node *u,int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    } else {
        if(z->key < y->key){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        cin >> com;
        if(com=="find"){
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        } else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        } else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 21932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {

	string S;

	cin >> S;

	int c = 0;
	for (int i = 0; i < (int)S.size(); i++) {
		if (S[i] == 'x') { c++; }
	}

	if (c <= 7) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	int b1,b2,b3;
	cin>>b1>>b2>>b3;
	if((b1 == 1 && b2 == 1)||b3 == 1){
	cout<<"Open"<<endl;
	}
	else{
		cout<<"Close"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
struct SegTree {
	std::vector<int> d;
	int sz;
	int base;
	const int e = 0;
	int merge(const int& i, const int& j){return i+j;}
	SegTree(int size): sz(size) {
		int k = 1;
		while(sz > k) k <<= 1;
		d = std::vector<int>(2 * k - 1, e);
		base = k - 1;
	}
	void update_upper(int i) {
		while(i > 0) {
			i = (i-1)/2;
			d[i] = merge(d[i*2+1], d[i*2+2]);
		}
	}
	void add(int i, int x) {
		assert(0 <= i && i < sz);
		int t = base + i;
		d[t] += x;
		update_upper(t);
	}
	void set(int i, int x) {
		assert(0 <= i && i < sz);
		int t = base + i;
		d[t] = x;
		update_upper(t);
	}
	int sum(int a, int b) {
		assert(0 <= a && a <= b && b <= sz);
		// sum up data in [a, b)
		return sum_sub(a, b, 0, 0, base+1);
	}
	int sum(int b) {return sum(0, b);}
	int sum_sub(int a, int b, int k, int l, int r) {
		if (b <= l || r <= a) return e;
		if (a <= l && r <= b) return d[k];
		int c = (l + r) / 2;
		return merge(
			sum_sub(a, b, 2*k+1, l, c),
			sum_sub(a, b, 2*k+2, c, r)
		);
	}
	int operator[](int i) {return d[base+i];}
};
int main() {
    int n;
    string s;
    cin >> n >> s;
    SegTree e(n), w(n);
    rep(i, n) {
        if (s[i] == 'E') e.set(i, 1);
        else w.set(i, 1);
    }
    int ans = 1e9;
    rep(i, n) chmin(ans, w.sum(i) + e.sum(i + 1, n));
    cout << ans << endl;
}


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

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

    vector<vector<char>> s(H + 2, vector<char>(W + 2));
    for (int i = 0; i < H + 2; i++) {
        for (int j = 0; j < W + 2; j++) {
            s[i][j] = '.';
        }
    }
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            cin >> s[i][j];
        }
    }

    bool flag = true;
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            if (s[i][j] == '#') {
                if (s[i][j - 1] == '.' && s[i][j + 1] == '.' && s[i - 1][j] == '.' && s[i + 1][j] == '.') {
                    flag = false;
                }
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else if (!flag) {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long a, b, x, ans;
	cin >> a >> b >> x;
	if (a == 0) ans = b / x + 1;
	else ans = b / x - (a - 1) / x;
	cout << ans;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, ans=0;
    cin >> N;
    vector<int> a(N);
    
    for(int i=0; i<N; i++){
	cin >>a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    for(int i=0; i<N; i++){
	if(i%2==0)
	    ans+=a[i];
	else
	    ans-=a[i];
    }

    cout << ans << endl;    
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int D;

  scanf("%d",&D);

  switch(D)
    {
    case 25:
        printf("Christmas\n");
      break;
    case 24:
	printf("Christmas Eve\n");
      break;
    case 23:
	printf("Christmas Eve Eve\n");
      break;
    case 22:
	printf("Christmas Eve Eve Eve\n");
      break;
    default:
      break;
    }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    
    if (s < t){
        Yes;
    }else{
        No;
    }
    return 0;
}


Measured memory_bytes: 256
# input
# ---
# N
# A[1] A[2] A[3] ...
# ---
N = int(input())
A = list(map(int, input().split()))

# 操作の回数をカウント
count = 0
# 奇数が1つもなければ exist_odd=0
exist_odd = 0

# Trueの間ずっと続ける
while True:
    for i in range(N):
        if A[i] % 2 == 1:
            exist_odd = 1
        else:
            A[i] /= 2

    if exist_odd == 1:
        break
    else:
        count += 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cxxabi.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define TYPEVS(x) typeid(x).name()
#define TYPEGC(x) abi::__cxa_demangle(typeid(x).name(), 0, 0, 0)
#define Y1 "YES"
#define N1 "NO"
#define ENDL '\n'
#define count2(x) _builtin_popcount(x)
ll l[300000],r[300000];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
	cin>>l[i]>>r[i];
	sort(l,l+n);
	sort(r,r+n);
	if(n%2==1){
		cout<<r[n/2]-l[n/2]+1;
	}
	else{
		ll x1=(r[n/2]+r[n/2-1]);
		ll x2=(l[n/2]+l[n/2-1]);
		cout<<x1-x2+1;
	}
}


Measured memory_bytes: 6760
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

int n;
vector<P> d[15];

bool list[15]={};

int ans(int level){
	if(level!=n){
		int ma = 0;
		LOOP(i,2){
			list[level]=i;
			ma = max(ma, ans(level+1));
		}
		return ma;
	}
	// LOOP(i,n)cout << list[i];
	// cerr << endl;
	LOOP(i,n){
		// cout << list[i];
		if(list[i]){
			LOOP(j,d[i].size()){
				if(list[d[i][j].first]!=d[i][j].second)return 0;
			}
		}
		// cout << endl;
	}
	int an = 0;
	LOOP(i,n)an += list[i];
	return an;
}

signed main(){
	cin >> n;
	LOOP(i,n){
		int a;
		cin >> a;
		LOOP(j,a){
			int x,y;
			cin >> x >> y;
			d[i].push_back(P(x-1,y));
		}
	}
	cout << ans(0) << endl;
}


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

int main(){
    int N;  cin >> N;
    vector<ll> A(N), B(N), D(N);
    ll sumA = 0, sumB = 0;
    for(int i=0; i<N; i++){ cin >> A[i]; sumA += A[i]; }
    for(int i=0; i<N; i++){ cin >> B[i]; sumB += B[i]; }
    if(sumA < sumB){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    ll lack = 0;
    for(int i=0; i<N; i++){
        D[i] = A[i] - B[i];
        if(D[i]<0){
            lack -= D[i];
            ans++;
        }
    }
    if(ans == 0){
        cout << 0 << endl;
        return 0;
    }

    sort(D.begin(), D.end());
    for(int i=N-1; i>=0; i--){
        if(lack > D[i]){
            ans++;
            lack -= D[i];
        }else{
            ans++;
            break;
        }
    }
    cout << ans << endl;
}

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

int main()
{
	ios_base::sync_with_stdio(false);

	int N, W;
	cin >> N >> W;
	vector<int> v(N + 1), w(N + 1);
	for (int i = 1; i <= N; i++)
		cin >> w[i] >> v[i];
	vector<vector<ll>> dp(N + 1, vector<ll> (W + 1, 0));
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			dp[i][j] = dp[i - 1][j];
			if (j < w[i])
				continue;
			dp[i][j] = max(dp[i][j], v[i] + dp[i - 1][j - w[i]]);
		}
	}
	cout << dp[N][W];

	return 0;
}

Measured memory_bytes: 83160
#include<bits/stdc++.h>
using namespace std;
vector<int>g[100005];
int vis[100005];
int bfs() {
    memset(vis, -1, sizeof(vis));
    int ret=0;
    queue<int>q;
    q.push(1);
    vis[1]=0;
    while(!q.empty()) {
        int s=q.front();
        q.pop();
        for(auto d: g[s]) {
            if(vis[d]==-1) {
                ret++;
                vis[d]=s;
                q.push(d);
            }
        }
    }
    return ret;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m, a, b;
    cin>>n>>m;
    for(int i=0; i<m; i++) {
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if(bfs()==n-1) {
        cout<<"Yes\n";
        for(int i=2; i<=n; i++) {
            cout<<vis[i]<<"\n";
        }
    } else cout<<"No\n";
    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S, T; cin >> S >> T;
  ll N = S.size();
  for (ll st = 0; st < N; st++) {
    bool ok = true;
    for (ll i = 0; i < N; i++) {
      if (S.at(i) == T.at((st + i) % N)) continue;
      ok = false;
      break;
    }
    if (ok) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int S[10000],S2[5000];
  int n,n2,i,j,cou = 0;
  
  scanf("%d",&n);

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



  scanf("%d",&n2);

  for(i = 0; i < n2; i++){
  scanf("%d", &S2[i]);
  }

  for(i = 0; i < n2; i++){
    for(j = 0; j < n; j++){
      if(S[j] == S2[i]){
	cou++;
	break;
      }
    }
  }

  printf("%d\n",cou);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long

using namespace std;

void solve()
{
	
	ll n,m;
	cin>>n>>m;
	for (int i = 0; i <= 1000000; ++i)
	{
		if((ll)(i*0.08)==n &&(ll)(i*0.1)==m){cout<<i;return;}
	}
	cout<<-1<<endl;
	 // if(n>b)n-=b;
// cout<<ans<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	 // cin>>T;
	while(T--)
	{
    		solve();
	}
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
#define mp make_pair
#define pb push_back
using namespace std;

const lli mod = 998244353;

lli power(lli x, lli y) {
    // x %= mod;
    if (y == 0) return 1;
    // return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2)) % mod;
    return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2));
}

vector <long long int> primeNumbers;

void SieveOfEratosthenes(int n){
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++){
      if (prime[p]){
        primeNumbers.push_back(p);
      }
    }        
}

#define MAXN 305
// vector < vector < int >  > v(MAXN);
// vector < vector < int >  > vnew(MAXN);
// int visit[MAXN];

int mat[MAXN][MAXN];

// void dfs(int index, int parent){
//   visit[index] = 1;
//   for(int i = 0;i<v[parent].size();i++){
//     int node = v[parent][i];
//     if(visit[node]) continue;
//     else if (!binary_search(v[index].begin(),v[index].end(),node)){
//       visit[node] = 1;
//       dfs(node,index);
//     }
//   }
// }
long long int preval[16];
void pre(){
  preval[0] = 1;
  preval[1] = 10;
  for(int i = 2;i<=15;i++){
    long long int val = (long long int)pow(10,i-1) - 1 + preval[i-1] + 10;
    preval[i] = val;
  }

  // for(int i = 0;i<=14;i++) cout<<preval[i]<<' ';
}

void solve(){
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  for(int i = 0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }

  int dp[n][3];
  memset(dp,0,sizeof(dp));
  
  //0 is a once
  //1 is a twice
  //2 is b once
  //3 is b twice
  //4 is c once
  //5 is c twice

  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  // dp[0][3] = 0;
  // dp[0][4] = c[0];
  // dp[0][5] = 0;

  for(int i = 1;i<n;i++){
    dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);

    dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);

    dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);

  }

  // for(int i = 0;i<n;i++){
  //   for(int j = 0;j<3;j++){
  //     cout<<dp[i][j]<<' ';
  //   }
  //   cout<<endl;
  // }

  int ans = 0;
  for(int i = 0;i<3;i++){
    ans = max(ans,dp[n-1][i]);
  }
  cout<<ans;

}
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 
  int t;
  // cin>>t;
  // scanf("%d",&t);
  t = 1;
  pre();
  while(t--){
    // cout<<
    solve();
 
    if(t>0){
      cout<<endl;
      // printf("\n");
    } 
  }
 
 
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
  return 0;
}


Measured memory_bytes: 6536
//#undef DEBUG
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
const char lf = '\n', splf[] = " \n";
#define all(x) begin(x), end(x)
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
#define TCC template<class C
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
#define ENI typename enable_if<
#define DTOR , Dbg&>::type operator<<
#define RIS return *this
TCC> static auto o(C *x)->decltype(os << *x, 0);
TCC> static char o(...);
TCC> ENI sizeof o<C>(0)!=1 DTOR(const C &x) {os<<x; RIS;}
TCC> Dbg &dump(C b, C e) {
    int ii = 0;
    for(C i = (os << "\n[", b); i!=e and ii<26; i++, ii++) *this << ", "+2*(i==b) << *i;
    RIS << ']';
}
TCC> ENI sizeof o<C>(0)==1 DTOR(const C &x) {
    return dump(all(x));
}
TCC, size_t X> ENI !is_same<C, const char>::value DTOR(C (&x)[X]) {
    return dump(all(x));
}
TCC, class D> Dbg &operator<<(const pair<C, D> &x) {RIS<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(ostream&)) { os << x; RIS; }
} dbg;
void err(istringstream *iss) { delete iss; }
TCC, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#ifdef DEBUG
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#else
#define bug(args...) void()
#define cbug(a, args...)
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
int T = 1, Q, cn;
const int inf = 1000000007, mxn = -1;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    //cin >> T;
    auto kase = [&]()->void {   // if T>1, inputAll + resetAll -> solution
        //cout << "Case " << cn << ":";
        string s,t;
        cin>>s>>t;
        int sl=sz(s),tl=sz(t),ans=sl;
        for(int si=0;si<=sl-tl;++si){
            int cnt=0;
            for(int ti=0;ti<tl;++ti)cnt+=s[si+ti]!=t[ti];
            ans=min(ans,cnt);
        }
        cout<<ans<<lf;
    };
    while (cn++!=T) kase();
}


Measured memory_bytes: 3612
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]
w0 = wv[0][0]
weights = [wv[0][0],wv[0][0]+1,wv[0][0]+2,wv[0][0]+3]
wdict = {}
cnt = 0
for w in weights:
    wdict[w] = cnt
    cnt += 1
values = [[] for _ in range(4)]

for w,v in wv:
    values[wdict[w]].append(v)

sums = 0
for i in range(4):
    values[i].sort(reverse = True)
    sums += sum(values[i])
    
ruisekiwa = [[0]*(N+1) for _ in range(4)]
for i in range(4):
    ruisekiwa[i][0] = 0
    for j in range(1,len(values[i])+1):
        ruisekiwa[i][j] = ruisekiwa[i][j-1] + values[i][j-1] 
    
ans = 0
for i in range(len(values[0])+1):
    for j in range(len(values[1])+1):
        for k in range(len(values[2])+1):
            for l in range(len(values[3])+1):
                w_tmp = w0*i + (w0+1)*j + (w0+2)*k + (w0+3) * l

                if w_tmp <= W:
                    val = ruisekiwa[0][i] + ruisekiwa[1][j] + ruisekiwa[2][k] + ruisekiwa[3][l]
                    ans = max(ans,val)
                    
print(ans)
                
                    
                
    


Measured memory_bytes: 3064
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	ans := min(N, M/2) // Sを使ってできるだけ作る
	M -= ans * 2
	if M >= 4 { // cの残りでできるだけ作る (c4個でScc1個)
		ans += M / 4
	}
	fmt.Println(ans)
}


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

int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D ;

  if ( A + B > C + D ) {
  cout << "Left" << endl;
  }
  else if ( A + B == C + D ) {
  cout << "Balanced" << endl;
  }
  else {
  cout << "Right" << endl;
  }
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
n,x,m = MI()
li = [x]
ans = 0
b = 0
for i in range(1,n):
    k =  pow(x,2,m)
    if k in li:
        b = 1
        ind = li.index(k)
        break
    li.append(k)
    x = k
    ##周期はlen(li)-ind
if b == 0:
    ans = sum(li)
else:
  ##print(li)
  ##print(ind)
  T = len(li) - ind
  ans += sum(li[:ind])##n個のうちind+1個足したからあとn-(ind+1)個足す
  ##print(ans)
  n = n-ind
  q = n//T
  S = sum(li[ind:])
  r = n%T
  ans += q*S + sum(li[ind:ind+r])
print(ans)
    


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

double maxSum(double a[], int k, int n) {
	double result = 0;
	for(int i = 0; i < k; i++) {
		result = result + a[i];
	}
	
	double current = result;
	for(int i = k; i < n; i++) {
		current = current + a[i] - a[i-k];
		result = max(result, current);
	}
	
	return result;
}

int main() {
	int n, k;
	cin >> n >> k;
	double a[200001];
	for(int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		a[i] = (temp+1.0)/2.0;
		//printf("%.2f ", a[i]);
	}
	printf("%0.11f", maxSum(a, k, n));
	return 0;
}

Measured memory_bytes: 1792