akhauriyash/Code-Regression huggingface dataset:
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

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

    int n,k;
    cin >> n >> k;

    int res = 0;
    while(n){
        n /= k;
        ++res;
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int same(char*x,char*y){
  if(strlen(x)!=strlen(y)){
    return 0;
  }
  int i;
  for(i=0;i<strlen(x);i++){
    if(x[i]!=y[i]){
      return 0;
    }
  }
  return 1;
}
    
    

int main(){
  int N;
  scanf("%d",&N);
  char si[N][100];
  int i,j;
  for(i=0;i<N;i++){
    scanf("%s",si[i]);
  }
  int len[N];
  for(i=0;i<N;i++){
    len[i]=strlen(si[i]);
  }
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      if(same(si[i],si[j])==1){
	printf("No");
	return 0;
      }
    }
  }

  for(i=1;i<N;i++){
    if(si[i-1][len[i-1]-1]!=si[i][0]){
      printf("No");
      return 0;
    }
  }

  printf("Yes");
  return 0;
}

    
  
  


Measured memory_bytes: 128
m=gets.split.map(&:to_i)
a,b=gets.split.map(&:to_i),gets.split.map(&:to_i)
m[2].times{($l||=[])<<a[(i=gets.split.map(&:to_i))[0]-1]+b[i[1]-1]-i[2]}
p [$l.min,a.min+b.min].min

Measured memory_bytes: 19244
def f(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
        table[i] *= i
    
    return table

def main():
    N = int(input())
    ans = 0
    print(sum(f(N)))


if __name__ == "__main__":
    main()


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

int MOD;
li l, a, b;

bool read () {
	if (scanf("%lld%lld%lld%d", &l, &a, &b, &MOD) != 4)
		return false;
	return true;
}

int add(int a, int b){
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int sub(int a, int b){
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

int mul(int a, int b){
	return a * li(b) % MOD;
}

struct mat{
	int a[3][3];
	mat(){
		memset(a, 0, sizeof(a));
	};
	int* operator [](int x){
		return a[x];
	}
};

int cnt0;

mat mul(mat a, mat b){
	mat c;
	forn(i, 3) forn(j, 3) forn(k, 3)
		c[i][j] = add(c[i][j], mul(a[i][k], b[k][j]));
	return c;
}

mat binpow(mat a, li b){
	mat res;
	forn(i, 3) res[i][i] = 1;
	while (b){
		if (b & 1)
			res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

void solve(){
	int res = 0;
	
	for (li cur = 10; cur <= INF64; cur *= 10){
		if (cur <= a) continue;
		
		li len = (cur - a + b - 1) / b;
		len = min(len, l);
		mat tmp;
		tmp[0][0] = cur % MOD;
		tmp[1][0] = 1;
		tmp[1][1] = 1;
		tmp[2][1] = b % MOD;
		tmp[2][2] = 1;
		tmp = binpow(tmp, len);
		
		mat orig;
		orig[0][0] = res;
		orig[0][1] = a % MOD;
		orig[0][2] = 1;
		
		orig = mul(orig, tmp);
		res = orig[0][0];
		
		a += len * b;
		l -= len;
		if (l == 0)
			break;
	}
	
	printf("%d\n", res);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

const int N = 20;
int b[20], a[3][3];
bool st[3][3];
int n;

bool check() {
	if (st[0][0] && st[0][1] && st[0][2]) return true;
	if (st[0][0] && st[1][0] && st[2][0]) return true;
	if (st[0][0] && st[1][1] && st[2][2]) return true;
	if (st[0][1] && st[1][1] && st[2][1]) return true;
	if (st[0][2] && st[1][2] && st[2][2]) return true;
	if (st[0][2] && st[1][1] && st[2][0]) return true;
	if (st[1][0] && st[1][1] && st[1][2]) return true;
	if (st[2][0] && st[2][1] && st[2][2]) return true;
	return false;
}

int main() {
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> b[i];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++)
				if (b[i] == a[j][k])
					st[j][k] = true;

		if (check()) {
			puts("Yes");
			return 0;
		}
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 256
/*
 * hujx.cpp
 *
 *  Created on: 2015年5月21日
 *      Author: dell
 */
#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
#include<set>
#include<bitset>
//#define ONLINE_JUDGE
#define eps 1e-5
#define INF 0x7fffffff
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,num) scanf("%d%d%d",&a,&b,&num)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll long long
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
//#pragma comment(linker,"/STACK:1024000000,1024000000")
int n,m,x;
//#define N 200005
#define M 100010
#define Mod 1000000000
#define p(x,y) make_pair(x,y)
const int MAX_len=550;
int tot;
struct Edge{
	int v;
	int len,cost;
};
vector<Edge> G[10010];
struct Node{
	int id,len,val;
	bool operator <(const Node &x)const{
		return (len == x.len?val>x.val:len>x.len);
	}
};
void Dijsktra(){
	int dis[10010];
	int vis[10010];
	memset(dis,0x3f3f3f3f,sizeof dis);
	memset(vis,0,sizeof vis);
	dis[1]=0;
	priority_queue<Node> q;
	q.push((Node){1,0,0});
	int ans=0;
	while(!q.empty()){
		Node tmp = q.top();
		q.pop();
		if(vis[tmp.id]) continue;
		vis[tmp.id] = 1;
		ans += tmp.val;
		for(int i=0;i<(int)G[tmp.id].size();i++){
			int v = G[tmp.id][i].v;
			int len = G[tmp.id][i].len;
			int cost = G[tmp.id][i].cost;
			if(!vis[v] && dis[v]>=dis[tmp.id]+len){
				dis[v] = dis[tmp.id]+len;
				q.push((Node){v,dis[v],cost});
			}
		}
	}
	printf("%d\n",ans);
}
int main(){
    while(scanf("%d%d",&n,&m)!=EOF && n+m){
    	for(int i=0;i<=n;i++) G[i].clear();
    	int u,v,len,cost;
    	for(int i=0;i<m;i++){
    		scanf("%d%d%d%d",&u,&v,&len,&cost);
    		G[u].push_back((Edge){v,len,cost});
    		G[v].push_back((Edge){u,len,cost});
    	}
    	Dijsktra();
    }
    return 0;
}

Measured memory_bytes: 3312
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

let (n',a',b') = ParseInt3 <| Console.ReadLine()
let (n,a,b) = (int64 n', int64 a', int64 b')
let (_,ac) = Console.ReadLine()
             |> ParseIntN
             |> Array.toList
             |> List.map int64
             |> (fun ls -> List.fold (fun (p,ac) c -> (c, ((min ((c-p) * a) b) + ac))) ((List.head ls),0L) (List.tail ls))
printfn "%d" ac


Measured memory_bytes: 35160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Swapping_Two_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> input = new List<string>();

            while (true)
            {
                string temp = "";

                temp = Console.ReadLine();
                if (temp.Equals("0 0"))
                {
                    break;
                }

                input.Add(temp);
            }

            foreach (string item in input)
            {
                string[] temp = item.Split(' ');
                int num1 = int.Parse(temp[0]);
                int num2 = int.Parse(temp[1]);

                if (num1 <= num2)
                {
                    Console.WriteLine(num1 + " " + num2);
                }
                else
                {
                    Console.WriteLine(num2 + " " + num1);
                }

            }
        }
    }
}



Measured memory_bytes: 15976
/*
 in the name of god

for good future keep working ;-)
ahj ++> JANI
*/
#include <bits/stdc++.h>
#define migmig ios::sync_with_stdio(false)
#define ll long long
#define BIG(N) const int N
#define pb push_back
#define go while(t--)
#define mp make_pair

using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i = 0 ; i < n; i++){
		cout << "ACL";
	}
}


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

typedef long long ll;

int main() {
	ll X, Y;
	scanf("%lld%lld", &X, &Y);
	Y /= X;
	
	int sol = 0;
	for (ll pot = 1; pot <= Y; pot *= 2)
		sol++;
	
	printf("%d\n", sol);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main(){
  int N;
  string s;
  cin >> N >> s;
  vector<int> left(N),right(N);
  for(int i = 1; i < N; i++){
    if(s[i-1] == 'W') left[i] = left[i-1]+1;
    else left[i] = left[i-1];
    if(s[N-i] == 'E') right[N-i-1]  = right[N-i]+1;
    else right[N-i-1] = right[N-i];
  }
  int ans = inf;
  rep(i,N) ans = min(ans,left[i]+right[i]);
  cout << ans << endl;
  // rep(i,N) cout << right[i];cout << endl;
					 
		       
 
    
  
  

  
  return 0;
}







Measured memory_bytes: 3076
#include <iostream> 
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#define N 1000005

using namespace std;

int n;

signed main(void) {
	cin >> n;
	if(n == 0) cout << 1;
	else cout << 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main(void){
    string s,x;
    getline(cin,s);
    int l=s.length();
    for(int i=0;i<l;++i){
        char ch =s[i];
        if(islower(ch)) x += toupper(ch);
        else if(isupper(ch)) x += tolower(ch);
        else x += ch;
    }
    cout<<x<<endl;
    // Your code here!
    
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define repr(i, a, n) for(ll i = n-1; i >= a; i--)
#define meme(a, b) memset(a, b, sizeof(a))

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
ll ceil(ll a, ll b){if((a%b) != 0) return a/b+1; return a/b;}
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

void solve(){
    ll m ,n;; cin >> m >> n;
    ll s = 0 , k = 1;
    ll a[n], b[n];
    rep(i, 0, n)
    {
        cin >> a[i] >> b[i];
    }

    ll dp[maxn];
    meme(dp, MOD);

    dp[0] = 0;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j <= m; j++){
            if(j+a[i] < maxn){
                dp[j+a[i]] = min(dp[j+a[i]], dp[j]+b[i]);
            }
        }
    }
    ll ans = MOD;
    for(ll i = m; i < maxn; i++){ //cout << dp[i] << " ";
        ans = min(ans, dp[i]);
    }
    cout << ans;
}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 1024
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=[input() for _ in range(N)]
    Ss=["".join(sorted(x)) for x in S]
    Ss.sort()

    ans = 0
    cnt = 0
    s0 = Ss[0]
    for s in Ss[1:]:
        if s == s0:
            cnt += 1
        else:
            ans += (cnt+1)*cnt//2
            s0 = s
            cnt = 0
            continue
    ans += (cnt+1)*cnt//2

    print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc137","c",main)

Measured memory_bytes: 18204
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int H, W, dist[59][59], sum; string S[59];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
		for (int j = 0; j < W; j++) { if (S[i][j] == '.') sum++; }
	}
	for (int i = 0; i < 59; i++) { for (int j = 0; j < 59; j++) dist[i][j] = (1 << 30); }
	queue<pair<int, int>>Q; Q.push(make_pair(0, 0)); dist[0][0] = 1;
	while (!Q.empty()) {
		int a1 = Q.front().first, a2 = Q.front().second; Q.pop();
		int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
		for (int i = 0; i < 4; i++) {
			int cx = a1 + dx[i], cy = a2 + dy[i];
			if (cx < 0 || cy < 0 || cx >= H || cy >= W || dist[cx][cy] <= dist[a1][a2] + 1 || S[cx][cy] == '#') continue;
			Q.push(make_pair(cx, cy));
			dist[cx][cy] = dist[a1][a2] + 1;
		}
	}
	if (dist[H - 1][W - 1] == (1 << 30)) cout << "-1" << endl;
	else cout << sum - dist[H - 1][W - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
flag=0
for i in range(n-1):
    if flag==0:
        if h[i] - h[i + 1] ==1:
            flag += 1
            temp=h[i]
        elif h[i] - h[i + 1] >= 2:
            flag+=2
            break
    else:
        if h[i] - h[i + 1] >= 2:
            flag += 1
            break
        if h[i] - h[i + 1] == 1:
            if h[i]-temp<0:
                flag += 1
                break
            else:
                temp=h[i]
if flag==0 or flag==1:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 63856
i = gets.chomp.split(" ").map(&:to_i)
if (i[0]-i[1]).abs > i[0]
    puts i[0]
else
    a = i[1]*(i[0]/i[1])
    b = i[1]*((i[0]/i[1])+1)
    if i[0]-a > b-i[0]
        puts b-i[0]
    else
        puts i[0]-a
    end
end

Measured memory_bytes: 3836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		double[] c = new double[n];
		double[] a = new double[n-k+1];
		for(int i = 0; i < n; i++) {
			double x = sc.nextDouble();
			c[i] = (1+x)/2;
		}
		double ans = 0;
		for(int i = 0; i < k; i++) {
			ans += c[i];
		}
		a[0] = ans;
		for(int i = 0; i < n-k; i++) {
			ans += c[i+k] - c[i];
			a[i+1] = ans;
		}
		Arrays.sort(a);
		System.out.println(a[a.length-1]);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

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

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

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

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

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


Measured memory_bytes: 58272
N,M,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
ans = 0
ind_a = 0
ind_b = 0
s = 0
for i in range(N):
  if s + A[i] <= K:
    s += A[i]
  else:
    ind_a = i
    break
  if i == N-1:
    ind_a = N
while ind_b < M and s + B[ind_b] <= K:
    s += B[ind_b]
    ind_b += 1  
ans = ind_a + ind_b
t = ind_a
for i in reversed(range(t)):
  s -= A[i]
  ind_a -= 1
  while ind_b < M and s + B[ind_b] <= K:
    s += B[ind_b]
    ind_b += 1
  ans = max(ans,ind_a+ind_b)
print(ans)

Measured memory_bytes: 111912
#include <bits/stdc++.h>
#define ll long long int
#define Fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

int main() {
    Fast
    
    int n; cin>>n;
    int arr[n][3], dp[n][3];
    for(int i=0; i<n; i++) for(int j=0;  j<3; j++) cin>>arr[i][j];
    for(int i=0 ;i<3; i++) dp[0][i]=arr[0][i];

    for(int i=1; i<n; i++) {
        for(int j=0; j<3; j++) {
            if(j==0) dp[i][j]=arr[i][j]+max(dp[i-1][1], dp[i-1][2]);
            if(j==1) dp[i][j]=arr[i][j]+max(dp[i-1][0], dp[i-1][2]);
            if(j==2) dp[i][j]=arr[i][j]+max(dp[i-1][0], dp[i-1][1]);
        }
    }

    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

Measured memory_bytes: 2560
r, c = [int(i) for i in input().split()]
ss = []
for _ in range(r):
    s = [int(i) for i in input().split()]
    ss.append(s + [sum(s)])

ans = [[i[j] for i in ss] for j in range(c+1)]
ss.append([sum(i) for i in ans])
print("\n".join(" ".join(map(str, i)) for i in ss))


Measured memory_bytes: 5852
import java.util.*;
import java.util.Scanner;

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

    String s = sc.next();
    if(s.length() < 4) {
      System.out.println("No");
      return;
    }
    String s2 = s.substring(0, 4);
    if(s2.equals( "YAKI"))System.out.println("Yes");
    else System.out.println("No");

  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<math.h>
using namespace std;
double bigger(double a, double b) {
	if (a > b)return a;
	else return b;
}
int main() {
	int N, K, i;
	long double ans = 0;
	cin >> N >> K;
	for (i = 1; i < N + 1; i++) {
		ans += powl((long double)0.5, bigger(ceil(log((long double)K / i) / log(2.0)), 0.0)) / (long double)N;
	}
	printf("%.12llf\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i, n) for( int i=0 ; i<n ; i++ )
#define f(i, a, b) for( int i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll fact(ll n)
{
    ll ans = 1e14;
    for(ll i = 1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll sol = (i - 1) + (n/i - 1);
            ans = min(ans,sol);
        }
    }
    return ans;
}
int visited[200000] = {0};
vector<vector<int> > v(200000);
int dfs(int x)
{
    int ans = 0;
    if(visited[x]==0)
    {
        visited[x] = 1;
        ans++;
        int a = v[x].size();
        for(int j = 0; j<a; j++)
        {
            int data = v[x][j];
            ans = ans + dfs(data);
        }
    }
    return ans;
}
void primefactors(int n)
{
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        cout << n << " ";

}
double fib(int n)
{
    double sol1,sol2;
    sol1 = (1 + sqrt(5))/2;
    sol2 = (1 - sqrt(5))/2;
    sol1 = pow(sol1,n);
    sol2 = pow(sol2,n);
    double ans = sol1 - sol2;
    ans = ans/sqrt(5);
    //ans = int(ans);
    return ans;
}

ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}


int main()
{

    ll a,b,k;
    cin>>a>>b>>k;
    ll x = min(a,k);
    a -= x;
    k -= x;
    if(k==0)
    {
        cout<<a<<" "<<b;
    }
    else
    {
        ll y = min(b,k);
        b = b - y;
        k = k - y;
        cout<<a<<" "<<b;

    }
}


Measured memory_bytes: 7844
#include <bits/stdc++.h>
#include <queue>
using namespace std;
signed main(){
    int n,m;
    queue<int>que[15];
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        if(a == 0){
            cout<<que[b].front()<<'\n';
            que[b].pop();
        }else{
            int minp=1;
            for(int j=2;j<=n;j++){
                if(que[j].size()<que[minp].size()){
                    minp=j;
                }
            }
            que[minp].push(b);
        }
    }
    return(0);
}


Measured memory_bytes: 3204
N = int(input())
X = tuple(map(int, input().split()))

MaxCoo = max(X)
MinCoo = min(X)
ave = (MaxCoo + MinCoo)//2
Range = MaxCoo - MinCoo + 2
MinCost = 10**12
for i in range(Range//2):
    pos = ave + i
    cost = 0
    for member in X:
        cost += (member-pos)**2
    if cost < MinCost:
        MinCost = cost

    pos = ave - i
    cost = 0
    for member in X:
        cost += (member-pos)**2
    if cost < MinCost:
        MinCost = cost
print(MinCost)

Measured memory_bytes: 3064
require "set"

s = gets.to_i
cnt = 1
prev = s
a_set = Set.new

def f(n)
  if n%2 == 0
    return n/2
  else
    return 3*n+1
  end
end

a_set << s

while true
  cnt+=1
  prev = f(prev)
  if a_set.include?(prev)
    break
  end
  a_set << prev
end

p cnt

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F(i, a, b) for (int i = (a); i <= (b); i++)
#define D(i, a, b) for (int i = (a); i >= (b); i--)
#define R(i, a, b) for (int i = (a); i < (b); i++)
#define N 500000
#define ALL(vt) vt.begin(), vt.end()

int main()
{
    int n; cin >> n;
    int a[n];
    for(int &k : a) cin >> k;
    sort(a, a + n);
    ll ansmin = 1e9;
    F(i, a[0], a[n-1]){
        ll tempMin = 0;
        R(j, 0, n){
            tempMin += pow(abs(i - a[j]), 2);
        }
        ansmin = min(ansmin, tempMin);
    }
    cout << ansmin;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k; cin>>n>>k;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin>>l.at(i);
    sort(l.begin(),l.end(),greater<int>());
    int sum=0;
    for(int i=0; i<k; i++) sum+=l.at(i);
    cout<<sum<<endl;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int n;
	cin >> n;

	int a[n], b[n];
	FOR(i, n){
		cin >> a[i];
		b[i] = a[i];
	}
	
	sort(b, b+n);

	FOR(i, n){
		if(a[i] == b[n-2]){
			cout << b[n-1] << endl;
		} else if(a[i] == b[n-1]){
			cout << b[n-2] << endl;
		} else {
			cout << b[n-1] << endl;
		}
	}

    return 0;
}


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

int main() {
	int a,b;
  	cin>>a>>b;
  
  	int ana=1;
  	int tako;
  
  	while(b>ana){
    	ana--;
      	ana+=a;
      	tako++;      	
    }
  
  cout<<tako<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

map <int,int> ans;

int main(){
    int n;
    scanf("%d",&n);
    priority_queue<int> res;
    for (int i = 0; i < n; i++){
        int k;
        scanf("%d",&k);
        ans[k]++;
        if (ans[k] == 2){
            res.push(k);
        }
        else if (ans[k] == 4){
            res.push(k);
        }
    }
    if (res.empty()){
        printf("0\n");
        return 0;
    }
    long long result = res.top();
    res.pop();
    if (res.empty()){
        printf("0\n");
    }
    else{
        result = result*res.top();
        printf("%lld\n",result);
    }
    return 0;
}


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

int main(){
int a,b,c;
cin>>a>>b>>c;
if(a>b){
    int d=a;
    a=b;
    b=d;
}
if(b>c){
    int e=b;
    b=c;
    c=e;
}
if(a>b){
    int f=a;
    a=b;
    b=f;
}
cout<<a<<" "<<b<<" "<<c<<endl;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, K; cin >> N >> K;
  ll result = 0;
  repr(i,K,N+2) result = (result+((N-i+1)*i+1)) % MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3640
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int[] array = new int[3];
        int answer = 0;

        for(int i = 0; i < 3; i++){
            array[i] = Integer.parseInt(input[i]);
        }

        Arrays.sort(array);
        for(int i = 0; i < 3; i++){
            array[i] = array[2] - array[i];
        }

        if(array[0] + array[1] == 0){
            //do nothing.
        }else if(array[0] != array[1] && array[1] != array[2]){    
            if(array[0] % 2 == array[1] % 2){
                answer += (array[0] - array[1]) / 2;
                answer += array[1];
            }else if(array[0] % 2 == 0){
                answer++;
                array[0]--;
                answer += array[0]/2 + 1;
                answer += array[1]/2 + 1;
            }else if(array[1] % 2 == 0){
                answer++;
                array[1]--;
                answer += array[0]/2 + 1;
                answer += array[1]/2 + 1;    
            }    
        }else if(array[0] == array[1]){
            answer += array[0];
        }else if(array[1] == array[2]){
            answer += array[0]%2;
            answer += (array[0]+1)/2;
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N,K;
    cin >> N >> K;
    int stp = 1;
    int cnt = 1;
    while(N/stp > 0) {
        stp*=K;
        if (N/stp <= 0) break;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n; i>0; i--)
#define rep1(i, n) for(int i=1; i<n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;

int type = 26;

int main() {
	int D;
	cin >> D;
	// 不開催により低下する満足度
	int dec = 0;
	vector<int64_t> c(type);
	vector<vector<int64_t>> l(type, vector<int64_t>(1, -1));
	rep(i, type) {
		cin >> c.at(i);
		dec += c.at(i);
	}
	// 開催により増加する満足度
	vector<vector<int64_t>> s(D, vector<int64_t>(type));
	rep(i, D) {
		rep(j, type) {
			cin >> s.at(i).at(j);
		}
	}

	// 日程変更クエリ
	int M = 1000;
	vector<pint> dq(M);
	// srand((unsigned int)time(NULL));
	rep(i, M) {
		dq.at(i).first = rand() % D;
		dq.at(i).second = rand() % type;
	}

	// 初期解の満足度計算
	int64_t a=0, b=0, x, y, z;
	vector<int64_t> t(D);
	rep(i, D) {
		// i日目に開催するtype
		x = 0;
		y = 0;
		rep(j, type) {
			if(chmax(y, s.at(i).at(j))) {
				x = j;
			}
		}
		t.at(i) = x;
		// 開催による増加
		a += s.at(i).at(x);
		// 不開催による減少
		b += (dec - c.at(x)*(i-l.at(x).at(l.at(x).size()-1)));
		l.at(x).push_back(i);
		a -= b;
		// 暫定満足度
		// cout << a << endl;
	}
	rep(i, type) {
		l.at(i).push_back(D);
	}

	// 変更処理
	rep(i, M) {
		int64_t p = a;
		x = dq.at(i).first;
		y = t.at(x);
		z = dq.at(i).second;
		if (y == z) continue;
		// 開催による増加差分
		a -= s.at(x).at(y);
		a += s.at(x).at(z);
		// 不開催による減少差分 減少
		int f = 0;
		rep1(j, l.at(y).size()) {
			if (l.at(y).at(j-1) == x) {
				break;
			} else {
				f = j;
			}
		}
		// l.at(y).pop_back();
		a -= (l.at(y).at(f) - x) * (x - l.at(y).at(f-1)) * c.at(y);
		// 不開催による減少差分 増加
		f = 0;
		// l.at(z).push_back(x);
		rrep(j, l.at(z).size()-1) {
			if (l.at(z).at(j-1) <= x) {
				f = j;
				break;
			}
		}
		a += (l.at(z).at(f) - x) * (x - l.at(z).at(f-1)) * c.at(z);
		// 暫定満足度
		// cout << a << endl;
		if (p > a) {
			a = p;
		} else {
			t.at(x) = z;
			// for(int j = f; j < l.at(y).size(); j++) {
			rep1(j, l.at(y).size()) {
				if (l.at(y).at(j-1) == x) {
					l.at(y).at(j-1) = l.at(y).at(j);
					l.at(y).at(j) = x;
				}
			}
			l.at(y).pop_back();
			l.at(z).push_back(x);
			rrep(j, l.at(z).size()-1) {
				if (l.at(z).at(j-1) > x) {
					l.at(z).at(j) = l.at(z).at(j-1);
					l.at(z).at(j-1) = x;
				} else {
					break;
				}
			}
		}
	}

	// 解
	rep(i, D) {
		cout << t.at(i)+1 << '\n';
	}
}


Measured memory_bytes: 3708
# Quick Sort

N = int(input())
A = []
for _ in range(N):
    s, a = input().split()
    A.append((s, int(a)))

B = [a for a in A]


def partition(p, r):
    i = p-1
    x = A[r][1]
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]

    A[r], A[i+1] = A[i+1], A[r]
    return i+1


def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)


INF = float('inf')


def merge(left, mid, right):
    L = B[left:mid]+[('sentinel', INF)]
    R = B[mid:right]+[('sentinel', INF)]
    l = 0
    r = 0

    for i in range(left, right):
        if L[l][1] <= R[r][1]:
            B[i] = L[l]
            l += 1
        else:
            B[i] = R[r]
            r += 1


def merge_sort(left, right):
    if left+1 < right:
        mid = (left+right)//2
        merge_sort(left, mid)
        merge_sort(mid, right)
        merge(left, mid, right)


quick_sort(0, N-1)
merge_sort(0, N)

print('Stable' if A == B else 'Not stable')
for s, v in A:
    print(s, v)


# print('Merge')
# for s, v in B:
#     print(s, v)



Measured memory_bytes: 17716
#include<iostream>
using namespace std;
int main(){


	int H,W,i,o,p;
   
    for(p=0;p<300;p++)
    {
        cin>>H>>W;
        if(H==0 && W==0)
        {
            break;
        }
        
   
   for(i=0;i<H;i++)
   {
	  
       for(o=0;o<W;o++)
       {
           cout<<"#";
       }
       cout<<endl;
        
    }
    cout<<endl;
    }
  
    



return 0;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
vec2int b(2, vecint(3, 0));
vec2int c(3, vecint(2, 0));
vec2int G(3, vecint(3, -1));
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecll a(n, 0);
  REPe(e, a) cin >> e;
  vector<vecll> dp(n, vecll(2, 0));
  dp[1][0] = (ll)(a[0] + a[1]);
  dp[1][1] = -(ll)(a[0] + a[1]);
  REP(i, n - 1) {
    if (i == 0) continue;
    dp[i + 1][0] = max(dp[i][0], dp[i][1]) + a[i + 1];
    dp[i + 1][1] = max(dp[i][0] - 2 * a[i], dp[i][1] + 2 * a[i]) - a[i + 1];
  }
  // REP(i, n) { cout << dp[i][0] << " " << dp[i][1] << endl; }
  cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int main() {

  int n; cin >> n;

  while (n--) {
    int y, m, d; cin >> y >> m >> d;
    --y; --m; --d;
    int cx = 0;
    rep (y_, 1000) {
      rep (m_, 10) {
        rep (d_, 20) {
          if (y_ == y && m_ == m && d_ == d) goto end;

          int D = (y_ % 3 == 2) ? 20 : (m_ % 2 == 0 ? 20 : 19);
          if (d_ == D) break;
          ++cx;
        }
      }
      //trace(cons(y_, cx));
    }
end:;
    const int offset = 196470;
    cout << (offset - cx) << endl;
  }


  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int n,m;
int a[200010];
int b[200010];
vector<int> v[200010];
bool vis[200010];
long long mx=0;
long long ans=0;
void dfs(int x){
	vis[x]=1;
	ans++;
	for(int i=0;i<v[x].size();i++){
		if(!vis[v[x][i]]){
			dfs(v[x][i]);
		}
	}
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			ans=0;
			dfs(i);
			mx=max(mx,ans);
		}
	}
	cout<<mx<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

const ll INF = 1e15;

int main () {
	ll maxX = -INF, maxY = -INF, minX = INF, minY = INF;
	ll sol = 0;
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		ll x1 = x + y;
		ll y1 = y - x;
		sol = max (sol, maxX - x1);
		sol = max (sol, x1 - minX);
		sol = max (sol, maxY - y1);
		sol = max (sol, y1 - minY);
		maxX = max (maxX, x1);
		minX = min (minX, x1);
		maxY = max (maxY, y1);
		minY = min (minY, y1);
	}

	cout << sol << '\n';
}


Measured memory_bytes: 3548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] h = new int[n];

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

        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for (int i = 0; i < n-2; i++) {
            dp[i+1] = Math.min(dp[i] + Math.abs(h[i]-h[i+1]), dp[i+1]);
            dp[i+2] = Math.min(dp[i] + Math.abs(h[i]-h[i+2]), dp[i+2]);
        }
        dp[n-1] = Math.min(dp[n-2] + Math.abs(h[n-2]-h[n-1]), dp[n-1]);

        System.out.println(dp[n-1]);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 42820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if(d <= t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
A, B = map(int, input().split())
part1 = 0
part2 = 0

if A > 0:
    if (A - 1) % 4 == 0:
        part1 = A - 1
    elif (A - 1) % 4 == 1:
        part1 = 1
    elif (A - 1) % 4 == 2:
        part1 = A
    else:
        part1 = 0
if B > 0:
    if B % 4 == 0:
        part2 = B
    elif B % 4 == 1:
        part2 = 1
    elif B % 4 == 2:
        part2 = B + 1
    else:
        part2 = 0

print(part1 ^ part2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,maxn=0,m=0;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		if(a[i]==b[i]){
			maxn++;
			m++;
		}else if(m<3&&a[i]!=b[i]){
			m=0;
		}
	}
	if(maxn>=3){
		if(m>=3){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 3632
/*
次の人がやってくるまでの時間がポイントになる
次の人がやってくるまでにT秒以上必要ならば, お湯はT秒出る
次の人がT秒以内にやってくるならば, それまでの時間,お湯が出る
最後の人がボタンを押したあと, お湯がT秒間出ることに注意せよ
*/

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

long long N, T;
int main(){
    cin >> N >> T;
    
    vector<long long> t(N);
    for (int i = 0; i < N; i++) cin >> t[i];
    
    long long time = 0;
    
    for (int i = 1; i < N; i++){
        time += min(T, t[i]-t[i-1]);
    }
    time += T;
    cout << time << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,X;
    cin >> n >> X;
    int b; cin >> b;
    b -= X;
    
    rep(i,n-1){
        int a;
        cin >> a;
        a -= X;
        b = __gcd(b,a);
    }
    cout << (b<0? -b : b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-6
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 998244353;
long double PI = acosl(-1);
const ll infl = 1e18+100;
const int inf = 2e9+100;
const int nmax = 2e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;


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

    ll n;
    cin>>n;
    vector<int>res;
    int sz;
    for(int i=60; i>=0; i--){
        ll val = (1LL<<i) - 1;
        if(val <= n){
            for(int j=1; j<=i; j++) res.push_back(j);
            for(int j=1; j<=i; j++) res.push_back(j);
            n -= val;
            sz = i;
            break;
        }
    }
    int extra = 0, cur = sz;
    for(int i=60; i>=0; i--){
        if(n & (1LL<<i)){
            int bame = sz - i + extra;
            cur++;
            res.insert(res.begin() + sz + extra, cur);
            extra++;
            res.insert(res.begin() + bame, cur);
        }
    }
    cout<<res.size()<<"\n";
    for(int x : res) cout<<x<<" ";
}
/*

*/


Measured memory_bytes: 384
#include <iostream>

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;

  int left = a + b;
  int right = c + d;
  std::string ans;
  if (left > right) {
    ans = "Left";
  } else if (left < right) {
    ans = "Right";
  } else {
    ans = "Balanced";
  }
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
*A, = map(int, input().split())
DP = [[0 for j in range(n+1)] for i in range(n+1)]
for l in range(1, n+1):
    for i in range(n-l+1):
        j = i+l
        DP[i][j] = max(A[i]-DP[i+1][j], A[j-1]-DP[i][j-1])
print(DP[0][n])


Measured memory_bytes: 120348
#include <cstdio>
#include <algorithm>

long long m[100000];
long long t[100000];
long long a[100000];

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%lld", t + i);
    if (i == 0 || t[i] == 1 || t[i] != t[i - 1]) m[i] = t[i];
  }
  for (int i = 0; i < n; ++i)
  {
    scanf("%lld", a + i);
  }
  for (int i = n - 1; i >= 0; --i)
  {
    if (i == n - 1 || a[i] == 1 || a[i] != a[i + 1])
    {
      if (m[i] == 0)
      {
        m[i] = a[i];
      }
    }
    if (m[i] == 0) continue;
    if (m[i] > a[i])
    {
      puts("0");
      return 0;
    }
  }
  long long ans = 1;
  for (int i = 0; i < n; ++i)
  {
    if (m[i] != 0) continue;
    ans = ans * std::min(t[i], a[i]) % 1000000007;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2560
# 146a

#日曜からの日数を指定
SUN_N = 0
MON_N = 1
TUE_N = 2
WED_N = 3
THU_N = 4
FRI_N = 5
SAT_N = 6

S = input() # 曜日を入力

if S == 'SUN':
    From_days = SUN_N
elif S == 'MON':
    From_days = MON_N
elif S == 'TUE':
    From_days = TUE_N
elif S == 'WED':
    From_days = WED_N
elif S == 'THU':
    From_days = THU_N
elif S == 'FRI':
    From_days = FRI_N
elif S == 'SAT':
    From_days = SAT_N
else:
    From_days = -99

To_days = 7 - From_days

print(To_days)


Measured memory_bytes: 9116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();
		String[] tmpArray = input.split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		//10000
		for(int i = 0; i <= n ; i++){
			//5000
			for(int j = 0; j <= n - i; j++){
				int sum = i*10000 + j*5000 + (n - i - j)*1000;
				
				if(sum == y){
					System.out.println(i + " " + j + " " + (n - i - j));
					return;
				}
			}
		}
		
		System.out.println("-1 -1 -1");
	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h) rep(j,w) cin >> a[i][j];

    rep(i,w+2){
        cout << "#";
    }
    cout << endl;
    
    rep(i,h){
        cout << "#";
        rep(j,w){
            cout << a[i][j];
        }
        cout << "#" << endl;
    }

    rep(i,w+2){
        cout << "#";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3580