akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

double maxv[50000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> t(n);
    int T = 0;
    for(int i = 0; i < n; ++i){
        cin >> t[i];
        T += t[i];
    }
    int now = 0;
    for(int i = 0; i < n; ++i){
        double v;
        cin >> v;
        
        maxv[now] = min(maxv[now], v);
        for(int j = now + 1; j <= now + 2 * t[i]; ++j){
            maxv[j] = v;
        }
        now += 2 * t[i];
    }
    maxv[0] = 0, maxv[2 * T] = 0;
    for(int i = 0; i < 2 * T; ++i){
        maxv[i + 1] = min(maxv[i + 1], maxv[i] + 0.5);
    }
    for(int i = 2 * T - 1; i >= 0; --i){
        maxv[i] = min(maxv[i], maxv[i + 1] + 0.5);
    }
    
    double res = 0;
    for(int i = 0; i < 2 * T; ++i){
        res += (maxv[i] + maxv[i + 1]) * 0.25;
    }
    
    cout << fixed << setprecision(15);
    cout << res << endl;
}

Measured memory_bytes: 512
//In the name of God:)
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long int
#define fast  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;

int main(){

    ll ans = 0 , n , k;
    scanf("%lld%lld" , &n , &k);
    for(ll i = k ; i <= n+1 ; i++){
        ans = (ans + 1 +((i * (2*n-i+1) / 2) - ((i-1) * i / 2 ))) % MOD;
        // cout<<i<<' '<<i * (2*n-i+1) / 2<<endl;
    }
    printf("%lld\n" , ans);
}


Measured memory_bytes: 3756
#define R(i,n)for(int i=0;i<=n;i++)
a,c[10][10];main(H,A,W){scanf("%d%d",&H,&W);R(i,9)R(j,9)scanf("%d",&c[i][j]);R(k,9)R(i,9)R(j,9)if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];R(i,H-1)R(j,W-1){scanf("%d",&A);a+=c[A>=0?A:1][1];}printf("%d",a);}

Measured memory_bytes: 128
#include <stdio.h>

int main(int argc,char* argv[]){
  
  int a,b;
  int count;
  int num;

  while(scanf("%d %d",&a,&b) != EOF){
    count = 1;
    num = 10;
    while(((a+b) / num) != 0){
      ++count;
      num *= 10;
    }

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

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

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

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    vector<int> smap(26);
    vector<int> tmap(26);
    for(int i=0;i<n;i++){
        smap[s[i]-'a']++;
        tmap[t[i]-'a']++;
    }
    sort(smap.begin(),smap.end());
    sort(tmap.begin(),tmap.end());
    for(int i=0;i<smap.size();i++){
        if(smap[i]!=tmap[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=1e5+5;
int a[mxn];
ll dp[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n,m; 
	cin >> n >> m;
	for(int i=0; i<n; i++)cin >> a[i];
	sort(a,a+n);
	int le = -1, ri = 2e5+1;
	ll happiness=0LL;
	while(le+1<ri){
		int mid = (le+ri)/2;
		ll cnt=0;
		for(int i=0; i<n; i++)
			cnt += ll(a+n-lower_bound(a,a+n,mid-a[i]));
		if(cnt>=m)le=mid;
		else ri=mid;
	}
	for(int i=0; i<n; i++){
		dp[i+1]=dp[i]+(ll)a[i];
	}
	ll cnt = 0;
	for(int i=0; i<n; i++){
		ll ptr = a+n-lower_bound(a,a+n,le-a[i]);
		cnt += ptr;
		happiness += dp[n]-dp[n-ptr]+ptr*a[i];
	}
	cnt = cnt-m;
	happiness -= cnt*le;
	cout << happiness << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 1408
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int main(){
int k=read(),s=read(),ans=0;
for (int i=0;i<=k;++i){
  for (int j=0;j<=k;++j){
    int now=i+j;
    if (s-now<=k&&s-now>=0) ++ans;
    }
  }
write(ans);
}

Measured memory_bytes: 256
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj2002().doIt();
    }
    class aoj2002{
    	char map[][] = new char[51][51];
    	Size size[] = new Size[128];
    	ArrayList<Character> array = new ArrayList<Character>();
    	void set(int H,int W){
    		for(int i = 0;i < H;i++){
    			String str = sc.next();
    			char ctr[] = str.toCharArray();
    			for(int j = 0;j < W;j++){
    				map[i][j] = ctr[j];
//    				System.out.print(map[i][j]+" ");
    				if(map[i][j] != '.'){
    					Size s = size[map[i][j]];
    					size[map[i][j]] = new Size(Math.min(s.minx,j),Math.max(s.maxx,j+1),Math.min(s.miny,i),Math.max(s.maxy,i+1));
    				}
    			}
//    			System.out.println();
    		}
    		
    	}
    	void clear(){
    		for(char c = 'A';c <= 'Z';c++){
    			size[c] = new Size(100,0,100,0);
    		}
    		array.clear();
    	}
    	boolean alf(char c){
    		for(int i = size[c].miny;i < size[c].maxy;i++){
				for(int j = size[c].minx;j < size[c].maxx;j++){
					if(map[i][j] == '.')return false;
				}
			}
    		return true;
    	}
    	boolean alf_check(char c){
    		for(int i = size[c].miny;i < size[c].maxy;i++){
				for(int j = size[c].minx;j < size[c].maxx;j++){
					if(map[i][j] != c){
						if(map[i][j] != '1')return false;
					}
				}
			}
    		return true;
    	}
    	void same(char c){
    		for(int i = size[c].miny;i < size[c].maxy;i++){
				for(int j = size[c].minx;j < size[c].maxx;j++){
					map[i][j] = '1';
				}
			}
    	}
    	String check(){
    		for(char c = 'A';c <= 'Z';c++){
    			if(size[c].maxx - size[c].minx < 0 || size[c].maxy - size[c].miny < 0)continue;
    			if(!alf(c))return "SUSPICIOUS";
    			array.add(c);
//    			System.out.println(c+" "+size[c].minx+" "+size[c].maxx+" "+size[c].miny+" "+size[c].maxy);
    		}
//    		System.out.println(array.toString());
    		int cnt = array.size();
    		while(cnt > 0){
//    			System.out.println(array.toString());
    			for(int i = 0;i < array.size();i++){
    				if(alf_check(array.get(i))){
    					same(array.get(i));
    					array.remove(i);
    					break;
    				}
    			}
    			if(cnt == array.size())return "SUSPICIOUS";
    			cnt = array.size();
    		}
//    		for(int i = 0;i < array.size();i++){
//    			System.out.print(array.get(i)+" ");
//    		}
//    		System.out.println();
    		return "SAFE";
    	}
        void doIt(){
        	int n = sc.nextInt();
        	for(int i = 0;i < n;i++){
        		int h = sc.nextInt();
        		int w = sc.nextInt();
        		clear();
        		set(h,w);
        		System.out.println(check());
        	}
        }
        class Size{
            int minx,maxx,miny,maxy;
            public Size(int minx,int maxx,int miny,int maxy) {
                this.minx = minx;
                this.maxx = maxx;
                this.miny = miny;
                this.maxy = maxy;
            }
        }
     }
}

Measured memory_bytes: 55432
{
  const run = (input: string) => {
    const list = 'abcdefghijklmnopqrstuvwxyz'.split("")
    let n = parseInt(input.trim())

    let result = []
    while (n > 0) {
      const tmp = n % 26
      const key = tmp === 0 ? 25 : tmp - 1
      result.push(list[key])

      if (n <= 26) break
      n = tmp === 0 ? n / 26 - 1 : Math.floor(n / 26)
    }

    return result.reverse().join('')
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 29640
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      double[] v = new double[n];

      for(int i=0;i<n;i++){
        v[i] = sc.nextDouble();
      }

      Arrays.sort(v);

      double ans = v[0];

      for(int i=1;i<n;i++){
        ans = (ans+v[i])/2;
      }

        System.out.print(ans);





    }
}


Measured memory_bytes: 27092
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
#include <bits/stdc++.h>
int main() {
    int a , b , c;
    cin >> a >> b >> c;
    cout << min({a + b , b + c , a + c}) << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    int count=0;
    if(n<3)
    {
        cout<<count<<endl;
    }
    else
    {
        for(int i=0;i<v.size()-2;i++)
        {
            for(int j=i+1;j<v.size()-1;j++)
            {
                for(int k=j+1;k<v.size();k++)
                {
                    if(v[i]!=v[j] && v[j]!=v[k] && v[k]!=v[i] && v[i]+v[j]>v[k] && v[i]+v[k]>v[j] && v[j]+v[k]>v[i] && i<j && j<k)
                    {
                        count+=1;
                    }
                }
            }
        }
        cout<<count<<endl;
    }
} 

Measured memory_bytes: 3600
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
long long N;
long long M;
long long Q;
ll ans = 0;
vector<ll> a,b,c,d;

void dfs(vector<ll> A){
  if(A.size() == N){
    ll n = 0;
    for (int i = 0; i < Q; i++) {
      if(A[b[i]-1] - A[a[i]-1] == c[i])n += d[i];
    }
    ans = max(ans , n);
    return;
  }  

  A.pb(A.back());
  while(A.back() <= M){
    dfs(A);
    A.back()++;
  }
}

void solve(){
  dfs(vector<ll>(1,1));
  cout << ans << endl;
}

int main(){
	scanf("%lld",&N);
	scanf("%lld",&M);
	scanf("%lld",&Q);
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
	for(int i = 0 ; i < Q ; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
  solve();
}


Measured memory_bytes: 3676
#include <algorithm>
#include <climits>
#include <iostream>
#include <utility>

using namespace std;

pair<int, int> cards[100];
int dp[100][100];

int rec(int begin, int end) {
  if (!(dp[begin][end] == -1))
    return dp[begin][end];
  if (begin == end) {
    return dp[begin][end] = 0;
  }
  int m = INT_MAX;
  for (int i = begin; i < end; i++)
    m = min(m, cards[begin].first * cards[i].second
             * cards[i+1].first * cards[end].second
             + rec(begin, i) + rec(i+1, end));
  return dp[begin][end] = m;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> cards[i].first >> cards[i].second;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      dp[i][j] = -1;
  cout << rec(0, n-1) << endl;
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int a, b, n;
  char* s[7];
  scanf("%d %d", &a, &b);
  sprintf(s, "%d%d", a, b);
  n = atoi(s);
  if ((int)sqrt(n) * (int)sqrt(n) == n) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}





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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}


int main()
{
	int n;
	cin>>n;
	vl A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	for(int i=1;i<n;i++)
	{
		A[i]+=A[i-1];
	}
	ll cost=INT_MAX;
	for(int i=0;i<n-1;i++)
	{
		cost=min(cost,abs(A[n-1]-2*A[i]));
	}
	cout<<cost<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}


//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int experiment(){
    int ans = 0;
    int A[5];
    cin>>A[0]>>A[1]>>A[2]>>A[3]>>A[4];
    int MaxOfDigitOfOne=10;
    FOR(i, 0,5){
        if(A[i]%10>0)MaxOfDigitOfOne=min(MaxOfDigitOfOne,A[i]%10);
    }
    //if(MaxOfDigitOfOne==10)MaxOfDigitOfOne=0;
    FOR(i, 0, 5){
        A[i]=(A[i]/10)*10+(A[i]%10 >0)*10;
    
    }
    //cout<<A[0]<<A[1]<<A[2]<<A[3]<<A[4]<<MaxOfDigitOfOne;
    ans=A[0]+A[1]+A[2]+A[3]+A[4]-10+MaxOfDigitOfOne;
    OutputAndReturn0(ans);
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    int W[100];
    int left[100];
    int right[100];
    cin >> N;
    int sum = 0;
    for(int i=0;i<N;i++){
        cin >> W[i];
        sum += W[i];
        left[i] = sum;
    }
    sum = 0;
    for(int i=0; i<N; i++){
        sum += W[N-1-i];
        right[N-1-i] = sum;
    }
    int m = 9999999;
    for(int i=0; i< N-1; i++){
        m = min(m, abs(left[i]-right[i+1]));
    }
    
    cout << m << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A_list = list(map(int, input().split()))

import heapq, math
A_list = [-x for x in A_list]
heapq.heapify(A_list)

for _ in range(M):
    A_min = heapq.heappop(A_list)
    heapq.heappush(A_list, math.ceil(A_min/2))

print(-sum(A_list))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 998244353,N = 1e5+7;
vector<ll> vec[N], top;
ll visit[N]={0};

void dfs(ll a)
{
    for(int i=0;i<vec[a].size();i++){
        if(visit[vec[a][i]])
            continue;
        visit[vec[a][i]]++;
        dfs(vec[a][i]);
    }
    top.push_back(a);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        vec[a].push_back(b);
    }
    for(int i=0;i<n;i++){
        if(visit[i])
            continue;
        visit[i]++;
        dfs(i);
    }
    reverse(top.begin(),top.end());
    ll ans = 0,dist[n]={0};
    for(int i=0;i<top.size();i++){
        for(int j=0;j<vec[top[i]].size();j++){
            dist[vec[top[i]][j]] = max(dist[vec[top[i]][j]],dist[top[i]]+1);
            ans = max(ans,dist[vec[top[i]][j]]);
        }
    }
    /*for(int i=0;i<n;i++)
        cout<<dist[i]<<endl;*/
    cout<<ans<<endl;
}


Measured memory_bytes: 9080
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  char c;

  while (scanf("%d", &n), n){
    scanf("%c", &c);
    int field = 0;
    vector<int> pt(n, 0);
    for (int i = 0;;i++){
      scanf("%c", &c);
      if (c == '\n') break;
      if (c == 'M'){
        pt[i % n]++;
      }
      else if (c == 'S'){
        field += pt[i % n] + 1;
        pt[i % n] = 0;
      }
      else if (c == 'L'){
        pt[i % n] += field + 1;
        field = 0;
      }
    }
    sort(pt.begin(), pt.end());
    for (int i = 0; i < n; i++){
      cout << pt[i] << " ";
    }
    cout << field << endl;
  }
  
  return (0);
}

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  
  bool x = false;
  for (int i=a; i<=b; i++) {
    if (i%k==0) {
      x = true;
      break;
    }
  }
  
  if (x)
    cout << "OK" << endl;
  else 
    cout << "NG" << endl;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a > k) cout << k << endl;
  else if (a + b > k) cout << a << endl;
  else cout << 2 * a - k + b << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll GCD(ll a, ll b)
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return GCD(b, a % b);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> left_rui(n + 1, 0);  //左側からの累積GCD
    vector<ll> right_rui(n + 1, 0); //右側からの累積GCD
    for (ll i = 0; i < n; i++)
    {
        left_rui[i + 1] = GCD(left_rui[i], a[i]);
    }
    for (ll i = n - 1; i >= 0; i--)
    {
        right_rui[i] = GCD(right_rui[i + 1], a[i]);
    }

    ll ans = -INF;

    for (ll i = 0; i < n; i++)
    {   
        ans = max(ans, GCD(left_rui[i], right_rui[i+1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int x = sc.nextInt();
		
		int []a = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			a[i] = sc.nextInt();
		}
		
		long sum = 0;
		
		if(a[0] > x) {
			sum += a[0] - x;
			a[0] = x;
		}
		
		for (int i = 0; i < n - 1; i++) {
			if(a[i] + a[i+1] > x) {
				sum += (long) a[i] + a[i+1] - x;
				a[i+1] = x - a[i];
			}
		}
		
		System.out.println(sum);
		
	}

}


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

int main() {
	int n, a;
	cin >> n >> a;
	int c = n / 500 * 500;
	n -= c;
	if (n <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
#include<ctype.h>
int main(){
  int i, cnt[26] = {0};
  char c; 
  while ((c = getchar()) != EOF) {
    c = tolower(c);
    cnt[c - 'a']++;
  }
  for(i = 0; i < 26; i++) {
    printf("%c : %d\n", 'a' + i, cnt[i]);
  }
  return 0;
}

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

class Node
{
    public:
        int key;
        Node* left;
        Node* right;
        Node* parent;
        Node( int k = 0 );
};

Node::Node( int k )
{
    key = k;
    parent = NULL;
    left = NULL;
    right = NULL;
}

class Tree
{
    private:
        Node* root;
    public:
        Tree();
        void Insert( Tree& t, int k );
        void PrintInorder( Tree t, Node* target );
        void PrintPreorder( Tree t, Node* target );
        bool Find( Tree t, int k );
};

Tree::Tree()
{
    root = NULL;
}

void Tree::Insert( Tree& t, int k )
{
    Node* y = NULL;
    Node* x = t.root;

    while( x != NULL )
    {
        y = x;
        if( k < x -> key )
            x = x -> left;
        else
            x = x -> right;
    }

    Node* n = new Node(k);
    n -> parent = y;

    if( y == NULL )
        t.root = n;
    else if( n -> key < y -> key )
        y -> left = n;
    else
        y -> right = n;
}

void Tree::PrintInorder( Tree t, Node* target )
{
    if( target == NULL )
        target = t.root;

    if( target -> left != NULL )
        PrintInorder( t, target -> left );
    
    cout << " " << target -> key;

    if( target -> right != NULL )
        PrintInorder( t, target -> right );
}

void Tree::PrintPreorder( Tree t, Node* target )
{
    if( target == NULL )
        target = t.root;

    cout << " " << target -> key;

    if( target -> left != NULL )
        PrintPreorder( t, target -> left );

    if( target -> right != NULL )
        PrintPreorder( t, target -> right );
}

bool Tree::Find( Tree t, int k )
{
    Node* target = t.root;

    bool judge = false;
    while( target != NULL )
    {
        if( target -> key < k )
            target = target -> right;
        else if( target -> key > k )
            target = target -> left;
        else
        {
            judge = true;
            break;
        }
    }
    return judge;
}

int main()
{
    int n, k;
    string s;
    Tree tree;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> s;
        if( s == "insert" )
        {
            cin >> k;
            tree.Insert( tree, k );
        }
        else if( s == "find" )
        {
            cin >> k;
            if( tree.Find( tree, k ) )
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
        else
        {
            tree.PrintInorder( tree, NULL );
            cout << endl;
            tree.PrintPreorder( tree, NULL );
            cout << endl;
        }
    }



    return 0;
}


Measured memory_bytes: 21904
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
int c[3][3];

int main() {
  rep(i, 0, 3) {
    rep(j, 0, 3) { cin >> c[i][j]; }
  }
  rep(i, 0, 2) {
    int diff = c[i + 1][0] - c[i][0];
    rep(j, 1, 3) {
      if (c[i + 1][j] - c[i][j] != diff) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  rep(j, 0, 2) {
    int diff = c[0][j + 1] - c[0][j];
    rep(i, 1, 3) {
      if (c[i][j + 1] - c[i][j] != diff) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}

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

using namespace std;
typedef long long ll;

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


const int MOD = 1e9 + 7;
const int MAX=10000000;
long long fac[MAX], finv[MAX], inv[MAX];



long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){

    ll X,Y;
    scanf("%lld %lld",&X,&Y);

 
    int a,b;
    bool flag=true;

    b=(2*X-Y)/3;
    a=X-2*b;

    if((2*X-Y)%3==0&&b>=0&&a>=0){
        b=(2*X-Y)/3;
        
        a=X-2*b;

        //cout<<"a:"<<a<<" b:"<<b<<endl;
    }else{
        flag=false;
    }

    COMinit();

    if(flag){
        cout<<COM(a+b,a)%MOD<<endl;
    }else{
        cout<<0<<endl;
    }



}

Measured memory_bytes: 238116
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        H: usize,
        W: usize,
        h: usize,
        w: usize,
    }
    println!("{}", (H-h)*(W-w));

}




Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= n; ++i)
#define arep(x,n) for (int x: n)
using namespace std;

int gcd(int a, int b) {

    if(a % b == 0) return b;

    return gcd(b, a%b);
}

int main()
{
    int k; cin >> k;
    int ans = 0;
    int tmp;
    rep(i,k) rep(j,k) rep(l,k) {
        tmp = gcd(l,gcd(i,j));
        ans += tmp;

    }

    cout << ans << endl;
}

Measured memory_bytes: 3548
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0

for a in range(n):
    for b in range(a):
        over_c = l[a] + l[b]
        over_c_index = bisect.bisect_left(l,over_c)
        quantity = over_c_index - a - 1
        ans += max(quantity,0)
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd
#include <limits> // std::numeric_limits<long int>::max()

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 

template<typename T>
T powint (const T& x, const T& y) {
  T ret = 1;
  for(int i=0; i<y; ++i) ret *= x;
  return ret;
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<double> p(N);
  for (int i=0; i<N; ++i) cin >> p[i];

  vector<double> exp(N);
  for (int i=0; i<N; ++i) {
    exp[i] = (p[i] + 1.0) / 2.0; // (p[i] + 1) * p[i] / 2 / p[i]
  }

  double sum = 0.0;
  for (int i=0; i<K; ++i) sum += exp[i];
  double maximum = sum;
  for (int i=0; i<N-K; ++i) {
    sum -= exp[i];
    sum += exp[i+K];
    maximum = max(sum, maximum);
  }
  cout << fixed << setprecision(6) << maximum << endl;
  return 0;
}

Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	static Scanner scan = new Scanner(System.in);
	static HashMap<String, Integer> map = new HashMap<String, Integer>();
	
	
	public static void main(String[] args) {
		int n  = scan.nextInt();
		for(int i=0; i<n; i++) {
			String s = scan.next();
			char[] ca = s.toCharArray();
			
			Arrays.sort(ca);
			
			s = new String(ca);
			
			
			if(map.containsKey(s)) {
				map.put(s, map.get(s)+1);
			}
			else {
				map.put(s, 1);
			}
		}
		
		long sum = 0;
		
		
		for(long k : map.values()) {
			k--;
			sum += (k*k+k)/2;
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 55572
#include<stdio.h>
#include<math.h>
int main(void){
        int a[10][10],n,d,i,j,k,l=0,p=0;
        double s[50],b[10][10];
        scanf("%d%d",&n,&d);
        for(i=0;i<n;i++){
            for(j=0;j<d;j++){
                scanf("%d",&a[i][j]);
                b[i][j]=a[i][j];
            }
        }
       for(i=0;i<n-1;i++){
            for(k=i+1;k<n;k++){
                for(j=0;j<d;j++){
                    s[p]=s[p]+(pow((b[i][j]-b[k][j]),2));
                }
                s[p]=sqrt(s[p]);
                if(round(s[p])-(s[p])==0){
                    l++;
                }
                p++;
            }
       }
       printf("%d",l);
       return 0;
}


Measured memory_bytes: 2080
s=input()
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll a[n],s[n][n],dp[n][n]={0};
    rep(i,0,n)
    cin>>a[i];
    rep(i,0,n)
    {
    	rep(j,i,n)
    	{
    		if(i==j)
    			s[i][j]=a[j];
    		else
    			s[i][j]=a[j]+s[i][j-1];
    	}
    }
    rep(l,2,n+1)
    {
    	rep(i,0,n)
    	{
    		ll j=i+l-1;
    		dp[i][j]=LLONG_MAX;
    		rep(k,i,j)
    			dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s[i][j]);
    	}
    }
    cout<<dp[0][n-1];
}


Measured memory_bytes: 2816
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0 for i in range(9)]
red = 0
for i in a:
	if i < 400:
		b[0] += 1
	elif i < 800:
		b[1] += 1
	elif i < 1200:
		b[2] += 1
	elif i < 1600:
		b[3] += 1
	elif i < 2000:
		b[4] += 1
	elif i < 2400:
		b[5] += 1
	elif i < 2800:
		b[6] += 1
	elif i < 3200:
		b[7] += 1
	else:
		red += 1
c = 0
for i in b:
	if i > 0:
		c += 1
if c == 0:
	mn = 1
else:
	mn = c
mx = c + red
print (mn, mx)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>
 
const ll inf = 1e15;
const int MAXM = 1e5+4;
const int MAXN = 1e4+10;

vector<int> v;
int arr[MAXM];
int n;
int dp[MAXM];

int solve(int idx) 
{
	if (idx == n)	return 0;
	if (dp[idx] != -1)	return dp[idx];
	int ret = INT_MAX;
	if (idx + 1 <= n) {
		ret = min(ret, abs(arr[idx+1] - arr[idx]) + solve(idx+1));
	}
	if (idx + 2 <= n) {
		ret = min(ret, abs(arr[idx+2] - arr[idx]) + solve(idx+2));
	}
	return dp[idx] = ret;
}

int main() 
{
	cin>>n;
	for (int i=1;i<=n;i++) {
		dp[i] = -1;
		cin>>arr[i];
	}
	cout << solve(1) << endl;
	return 0;
}

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


void build_tree(int index,int s,int e,vector<int>&tree,vector<int>&points)
{
    //cout<<"build index="<<index<<" s="<<s<<" e="<<e<<endl;
    if(e-s==1)
    {
        tree[index]=abs(points[e]-points[s]);
        return;
    }
    int left,right,mid;
    mid=(s+e)/2;
    left=2*index;
    right=2*index+1;
    build_tree(left,s,mid,tree,points);
    build_tree(right,mid,e,tree,points);
    tree[index]=tree[left]+tree[right];
    return;
}


void update(int index,int s,int e,int q,vector<int>&tree,vector<int>&points)
{
    //cout<<"index="<<index<<" s="<<s<<" e="<<e<<endl;
    if(q<s || q>e)
    {
        return;
    }
    if(e-s==1 && (s==q || e==q))
    {
        tree[index]=abs(points[e]-points[s]);
        return;
    }
    int left,right,mid;
    mid=(s+e)/2;
    left=2*index;
    right=2*index+1;
    update(left,s,mid,q,tree,points);
    update(right,mid,e,q,tree,points);
    tree[index]=tree[left]+tree[right];
    return;
}

int main()
{
    int n,i,j,res;
    scanf("%d",&n);
    vector<int>tree(4*n+1);
    vector<int>points(n+1,0);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&j);
        points[i]=j;
    }
    build_tree(1,0,n,tree,points);
    for(i=1;i<=n;i++)
    {
        int pre;
        if(i==1)
        {
            pre=points[i];
            points[i]=points[i+1];
        }
        else
        {
            pre=points[i];
            points[i]=points[i-1];
        }
        update(1,0,n,i,tree,points);
        res=tree[1];
        if(i==n)
        {
            res+=abs(points[n-1]);
        }
        else
            res+=abs(points[n]);
        points[i]=pre;
        update(1,0,n,i,tree,points);
        printf("%d\n",res);
    }
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
ll const mxn = 1e5+1;
ll n;
ll dp[mxn];
ll arr[mxn];
 
ll solve(int pos){
    if(pos==0)return 0;
    if(pos==1)return abs(arr[1]-arr[0]);
    if(dp[pos]>-1){
        return dp[pos];
    }
    ll dif = solve(pos-2)+(abs(arr[pos]-arr[pos-2]));
    ll dif1 = solve(pos-1)+(abs(arr[pos]-arr[pos-1]));
    dp[pos] = min(dif,dif1);
    return dp[pos];
}
 
int main() {FIN;
 
    cin>>n;arr[n];
    fore(i,0,n)cin>>arr[i];
    fill(dp,-1);
    cout<<solve(n-1)<<"\n";
 
 
    return 0;
}

Measured memory_bytes: 7540
#include <bits/stdc++.h>
using namespace std;
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;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    int N;
    cin >> N;
    vector<ll> x(N), y(N);
    for(int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        x[i] = a - b;
        y[i] = a + b;
    }
    sort(ALL(x));
    sort(ALL(y));
    ll diffx = x.back() - x.front();
    ll diffy = y.back() - y.front();
    cout << max(diffx, diffy) << endl;
}

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

function main()
	s = readline() |> chomp
	t = readline() |> chomp
	l = length(s)
	f = 0
	for i in 1:l
		if s[i]!=t[i]
			f=1
		end
	end
	println(f==0 ? "Yes" : "No")
end

main()

Measured memory_bytes: 155024
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let h: u64 = read();
    let w: u64 = read();

    let ans = if h == 1 || w == 1 { 1 } else { (h * w + 1) / 2 };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String[] line = in.nextLine().split(" ");
        final int a = Integer.parseInt(line[0]);
        final int b = Integer.parseInt(line[1]);
        if (Math.max(a, b) > 8) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}


Measured memory_bytes: 35804
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
    writeln(scanString.count!"a=='1'");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int n;
int ans = 0;
void dfs(int i, string s, bool thr, bool fiv, bool sev) {
  if (i && stol(s) > n)
    return;
  else {
    if (thr && fiv && sev)
      ans++;
  }

  ll res = 0;
  if (stol(s + "3") <= n)
    dfs(i + 1, s + "3", true, fiv, sev);
  if (stol(s + "5") <= n)
    dfs(i + 1, s + "5", thr, true, sev);
  if (stol(s + "7") <= n)
    dfs(i + 1, s + "7", thr, fiv, true);
}

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

  cin >> n;
  dfs(0, "", false, false, false);
  cout << ans << endl;
}


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

typedef long long ll;
const int INF = 1e8;

int main() {
	int h, w;
	pair<int, int> c, d;
	cin >> h >> w >> c.first >> c.second >> d.first >> d.second;
	c.first -= 1; c.second -= 1;
	d.first -= 1; d.second -= 1;
	vector<string> s(h);
	for (int i = 0; i < h; ++i) {
		string ss; cin >> ss; s[i] = ss;
	}

	vector<vector<int>> ans(h);
	for (int i = 0; i < h; ++i) ans[i] = vector<int>(w, INF);

	priority_queue<pair<int, pair<int, int>>> q;
	q.push(make_pair(0, c));

	while (!q.empty()) {
		int dd = -q.top().first;
		pair<int, int> xy = q.top().second;
		q.pop();

		if (ans[xy.first][xy.second] < INF) continue;
		ans[xy.first][xy.second] = dd;
		//cout << xy.first + 1 << ',' << xy.second + 1 << ' ' << dd << endl;
		
		for (int dx = -1; dx <= 1; ++dx)
			for (int dy = -1; dy <= 1; ++dy) 
				if (dx * dx + dy * dy == 1) {
					int xx = xy.first + dx;
					int yy = xy.second + dy;
					if (xx < 0 || xx >= h) continue;
					if (yy < 0 || yy >= w) continue;
					if (s[xx][yy] == '#') continue;
					q.push(make_pair(-dd, make_pair(xx, yy)));
				}
		for (int dx = -2; dx <= 2; ++dx)
			for (int dy = -2; dy <= 2; ++dy)
				if (dx * dx + dy * dy > 0) {
					int xx = xy.first + dx;
					int yy = xy.second + dy;
					if (xx < 0 || xx >= h) continue;
					if (yy < 0 || yy >= w) continue;
					if (s[xx][yy] == '#') continue;
					q.push(make_pair(-(dd + 1), make_pair(xx, yy)));
				}
	}

	int a = ans[d.first][d.second];
	if (a < INF) cout << a << endl;
	else cout << -1 << endl;

	return 0;
}


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

using namespace std;
using ll = long long;
using lll = __int128;
using pll = pair <ll, ll>;
using plll = tuple <ll, ll, ll>;

map <pll, ll> M;
vector <plll> V;
char S[22];
ll n, s;

bool can(ll p1, ll q1, ll p2, ll q2)
{
	return ((lll)p1 * p2) % ((lll)q1 * q2) == 0;
}

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

	ll i, j, p, q, g, t;

	cin >> n;

	for(i = 1; i <= n; i ++){
		cin >> S; p = 0;
		for(j = 0, q = 0; S[j]; j ++){
			if(S[j] == '.'){
				q = 1; continue;
			}
			p = p * 10 + S[j] - '0';
			q *= 10;
		}
		if(q == 0) q = 1;
		g = gcd(p, q);
		p /= g; q /= g;

		t = p; p = 1;
		for(; t % 2 == 0; t /= 2) p *= 2;
		for(; t % 5 == 0; t /= 5) p *= 5;

		M[pll(p, q)] ++;
	}

	for(auto [x, y]: M){
		V.emplace_back(x.first, x.second, y);
	}
	for(i = 0; i < V.size(); i ++){
		auto [p1, q1, r1] = V[i];
		if(can(p1, q1, p1, q1)) s += r1 * (r1 - 1) / 2;
		for(j = i + 1; j < V.size(); j ++){
			auto [p2, q2, r2] = V[j];
			if(can(p1, q1, p2, q2)) s += r1 * r2;
		}
	}

	cout << s << "\n";

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
    int n, d, num=0;
    
    cin >> n >> d;
    
    float arr[n], arr1[n];
    
    for(int i=0; i<n; i++)
        cin >> arr[i] >> arr1[i];
    
    for(int i=0; i<n; i++)
    {
        if(pow(arr[i],2.0)+pow(arr1[i],2.0) <= pow(d,2))
            num++;
        
    }
    cout << num;

}


Measured memory_bytes: 4700
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()

x = int(input())

p = 100
year = 0
while p<x:
  p = p*(1.01)
  p //= 1
  year += 1
print(year)


Measured memory_bytes: 64936
import numpy as np

# n = int(input())

"""
directly out
agc*
*agc_
indirectly

*gac
gac*
*acg
acg*
a*gc
ag*c

a =0
c =1
g = 2
t = 3
"""
# l = ["a","g","c","t"]
# d = {}
#
# for i in range(4):
#     for j in range(4):
#         for k in range(4):
#             temp = l[i]+l[j]+l[k]
#             d[temp] = 0
#
#
# for i in range(1,n):
#     for key in d.keys():


h,w = map(int,input().split())
a,b = map(int,input().split())

print(h*w-a*w-b*(h-a))







Measured memory_bytes: 19488