akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<String> s = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			s.add(sc.next());
		}
		int innerAB = 0;
		int leftCount = 0;
		int rightCount = 0;
		int bothCount = 0;
		for (String str : s) {
			for (int i = 0; i < str.length() - 1; i++) {
				if (str.charAt(i) == 'A' && str.charAt(i + 1) == 'B') {
					++innerAB;
				}
			}
			if (str.charAt(0) == 'B' && str.charAt(str.length() - 1) == 'A') {
				++bothCount;
			} else {
				if (str.charAt(0) == 'B') {
					++leftCount;
				}
				if (str.charAt(str.length() - 1) == 'A') {
					++rightCount;
				}
			}
		}
		int result = innerAB;
		while (true) {
			if (bothCount > 0 && (leftCount > 0 || rightCount > 0)) {
				--bothCount;
				++result;
			} else if (bothCount > 1) {
				--bothCount;
				++result;
			} else if (rightCount > 0 && leftCount > 0) {
				--rightCount;
				--leftCount;
				++result;
			} else if (bothCount > 0 && (rightCount > 0 || leftCount > 0)) {
				--bothCount;
				if (rightCount > 0) {
					++leftCount;
				} else {
					++rightCount;
				}
				++result;
			} else {
				break;
			}
		}
		System.out.println(result);
	}
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)

signed main()
{
    int n; cin >> n;
    int minA = INF;
    int maxA = INF_NEG;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        minA = min(minA, a[i]);
        maxA = max(maxA, a[i]);
    }

    int ans = INF;

    for (int i = minA; i <= maxA; ++i){
        int tmpAns = 0;
        rep(j,n) tmpAns += (a[j]-i) * (a[j]-i);
        ans = min(ans,tmpAns);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> h(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	h[0]--;

	for (int i = 1; i < n; i++) {
		if (h[i-1] < h[i]) {
			h[i]--;
		} else if (h[i-1] == h[i]) {
		} else {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 640
/* ex7_3
   key_tree */

#include <stdio.h>
#include <stdlib.h>


int main(void){
    int row_num, col_num;
    int *row, *col;
    char **matrix;
    // 縦と横のマス目の数を読み取る
    scanf("%d %d", &row_num, &col_num);
    
    // メモリ領域の確保
    row = (int*)calloc(row_num, sizeof(int));
    // エラーチェック
    if (row == NULL){
        exit(1);
    }

    // メモリ領域の確保
    col = (int*)calloc(col_num, sizeof(int));
    // エラーチェック
    if (col == NULL){
        exit(1);
    }
    
    // メモリ領域の確保
    matrix = (char**)calloc(row_num, sizeof(char*));
    // エラーチェック
    if (matrix == NULL){
        exit(1);
    }
    for (int i=0; i<row_num; i++){
        // メモリ領域の確保
        matrix[i] = (char*)calloc(col_num, sizeof(char));
        // エラーチェック
        if(matrix[i] == NULL){
            exit(1);
        }
    }

    // マス目を読み取る
    for (int i=0; i < row_num; i++){
        for (int j=0; j < col_num; j++){
            scanf(" %c", &matrix[i][j]);
            // マス目が黒なら該当する行列の配列に1を代入
            if (matrix[i][j] == '#'){
                row[i] = 1;
                col[j] = 1;
            }
        }
    }
 
    // 出力
    for (int i=0; i < row_num; i++){
        // 黒マスがない行は飛ばす
        if (row[i] == 0)
            continue;
        for (int j=0; j < col_num; j++){
            // 黒マスがない列は飛ばす
            if (col[j] == 0)
                continue;
            printf("%c", matrix[i][j]);
            }
        printf("\n");
        
    }
    
    // 確保と逆順でメモリの解放
    free(row);
    free(col);
    for (int i=0; i<row_num; i++){
        free(matrix[i]);
    }
    free(matrix);
 
    return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>

int main(){
    int a[4][3][10];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                a[i][j][k] = 0;
            }
        }
    }
    
    int b, f, r, v, n;
    char cc;
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++){
        scanf("%c", &cc);
        scanf("%d %d %d %d", &b, &f, &r, &v);
        a[b-1][f-1][r-1] += v;
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                printf(" %d", a[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3){
            printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

const int MAX = 1000010;
int c[MAX] = {};

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        c[a]++; c[a+1]++; c[a+2]++;
    }
    int ans = 0;
    for (int i = 0; i < MAX-2; i++) {
        ans = max(ans, c[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
s = input()
t = input()

c1 = len(s)
c2 = len(t)
max_count = 0
if c1 != c2:
  for i in range(c1 - c2):
    count = 0
    for j in range(c2):
      if s[i + j] == t[j]:
        count += 1
    if count > max_count:
      max_count = count
else:
  for i in range(c1):
    if s[i] == t[i]:
      max_count += 1
print(c2-max_count)


Measured memory_bytes: 72808
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

//Author: Jiangsu Nanjing Li Zongtai
//强壮标记*10000,手牌*10000,血量10000 lyl+hzj也打不死我哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈~~~~

const int inf=2147483647;

typedef long long ll;

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

int n;
ll tt[1111];

int main()
{
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>tt[i];
	}
	
	if(n==1)
	{
		cout<<tt[1]<<endl;
		return 0;
	}
	
	ll gg=gcd(tt[1],tt[2]);
	ll ans=tt[1]/gg;
	ans=ans*tt[2];
	
	for(int i=3;i<=n;i++)
	{
		gg=gcd(ans,tt[i]);
		ans=ans/gg;
		ans=ans*tt[i];
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io;
use std::cmp::max;

macro_rules! parse_tuple {
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
                a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

fn main() {
    let (A, B) = parse_tuple!(i32, i32);
    println!("{}", max(max(A + B, A - B), A * B));
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


int main() {
    const long long int mod = 1000000007,INF=50000000000000;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    string str[120];
    long long int n,speed=0,t[600]={},v[600],nowt=1,x1,x2,y1,y2;
    long double res=0.0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>t[i];
    }
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    v[n+1]=0;
    for(int i=1;i<=n+1;i++){
        t[i]=t[i]+t[i-1];
    }

    for(int i=1;i<=t[n+1];i++){
        long long int tmp=999999,tmp2=999999;
        for(int j=nowt;j<=n;j++){
            tmp=min(tmp,t[j]-i+v[j+1]);
            tmp2=min(tmp2,2*t[j]-2*i+1+2*v[j+1]);
        }
        if(tmp>=speed+1&&speed<v[nowt]){
            
            res+=(long double)(speed*2+1)/2.0;
            speed++;
        }else if(tmp>=speed){
            if(tmp2>=1&&speed<v[nowt]){
                res+=0.25;
            }
            res+=speed;
        }else{
            res+=(long double)(speed*2-1)/2.0;

            speed--;
        }
        if(t[nowt]==i){
            nowt++;
        }
    }
    cout<<res;
} 


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[2][125];
int sum[2][125];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a[0]+i);
  REP(i,n)scanf("%d",a[1]+i);
  REP(j,2){
    sum[j][0] = 0;
    REP(i,n)sum[j][i+1] = sum[j][i] + a[j][i];
  }
  int ans = 0;
  REP(i,n)CHMAX(ans, sum[0][i+1] + sum[1][n] - sum[1][i]);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 764
import java.util.*;
import java.io.*;

public class Main {
    static final long mod = 1000000007;
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = scanner.nextInt();
        long k = scanner.nextInt();
        long[] cnt = new long[2001];
        long ans = 0;
        int[] arr = new int[n];
        for(int j = 0; j < n; j++) {
            int next = scanner.nextInt();
            arr[j] = next;
            cnt[next]++;
            for(int i = next+1; i < 2001; i++) {
                ans = (ans + k * cnt[i]) %mod;
            }
        }
        long t = ((k * (k-1))/2) % mod;
        for(int j = 0; j < n; j++) {
            for(int i = 0; i < arr[j]; i++) {
                ans = (ans + (t * cnt[i]))%mod;
            }
        }
        out.println(ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22836
import bisect


def solve(memo, left, right):
    left_key = bisect.bisect_left(memo, left)
    right_key = bisect.bisect_right(memo, right)
    return right_key - left_key


def main():
    length, questions = map(int, input().split())
    string = input()

    memo = []
    for key in range(length - 1):
        if string[key:key+2] == "AC":
            memo.append(key + 1)

    for question in range(questions):
        left, right = map(int, input().split())
        right -= 1
        ans = solve(memo, left, right)
        print(ans)


if __name__ == "__main__":
    main()


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

typedef long long ll;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==1&&m==0)
    {
        cout<<0<<endl;
        return 0;
    }
    int digit[9];
    memset(digit,0,sizeof(digit));
    bool flag=false;
    vector<int>v(n);
    for(int i=0; i<n; i++)
    {
        if(i==0)
        {
            v[i]=1;
        }
        else
        {
            v[i]=0;
        }
    }
    for(int i=0; i<m; i++)
    {
        int a,b;
        cin>>a>>b;
        if(digit[a]!=0)
        {
            if(v[a-1]!=b)
            {
                flag=true;
            }
        }
        else
        {
            v[a-1]=(b);
        }
        digit[a]++;
        if(a==1&&b==0)
        {
            if(n!=1)
            {
            flag=true;
            }
        }
    }
    if(flag)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(auto x:v)
    {
        cout<<x;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
 
int main() {
    int N, K, Q; cin >> N >> K >> Q;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    vector<ll> B(A);
    sort(all(B));
    A.push_back(-1);
    B.push_back(INF);
    ll ans = INF;
    REP(left,N) {
        int ub = N;
        int lb = left-1;
        int right;
        while(ub-lb>1) {
            right = (ub + lb) / 2;
            int cnt = 0;
            int cnt1 = 0;
            int cnt2 = 0;
            REP(i,N) {
                if (B[left]<=A[i]) cnt1++;
                if (B[left]<=A[i] && A[i]<=B[right]) cnt2++;
                if (A[i+1]<B[left]){
                    cnt += min(max(0,cnt1-K+1),cnt2);
                    cnt1 = 0;
                    cnt2 = 0;
                }
            }
            if (cnt>=Q) ub = right;
            else lb = right;
        }
        ans = min(ans, B[ub]-B[left]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m=map(int, input().split())
x=list(map(int, input().split()))
x=sorted(x)
y=[0]*(m-1)

for i in range(m-1):
    y[i]=x[i+1] - x[i]
z=sorted(y)

if n>=m:
    print(0)
else:
    print(sum(z[0:m-n]))


Measured memory_bytes: 54440
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main()
{
	int a;
	int ans = 0;
	int counter;
	cin >> a;
	for (int i = 1; i <= a; i+=2) {
		counter = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0) {
				counter++;
			}
		}
		if (counter == 8) {
			ans++;
			cerr << i << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int bingo[3][3];
	rep(i,3) rep(j,3) std::cin >> bingo[i][j];
	int n;
	std::cin >> n;
	int got[3][3];
	rep(i,3) rep(j,3) got[i][j]=false;
	rep(i,n) {
		int a;
		std::cin >> a;
		rep(i,3) rep(j,3) if(bingo[i][j]==a) got[i][j]=true;
	}
	rep(i,3) {
		int all = true;
		rep(j,3) if(!got[i][j]) all=false;
		if(all) {
			print("Yes");
			return 0;
		}
	}
	rep(j,3) {
		int all = true;
		rep(i,3) if(!got[i][j]) all=false;
		if(all) {
			print("Yes");
			return 0;
		}
	}
	int all = true;
	rep(i,3) {
		if(!got[i][i]) all=false;
	}
	if(all) {
		print("Yes");
		return 0;
	}
	all = true;
	rep(i,3) {
		if(!got[i][2-i]) all=false;
	}
	if(all) {
		print("Yes");
		return 0;
	}
	print("No");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
string s, t;
int main() {
	cin >> s >> t;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1000000010;

struct edge{
    int to,cost;
};
class Dijkstra{
    public:
        vector<int> d;//始点からの距離
        vector<vector<edge>> G;//辺とそのコスト
        int s;
        priority_queue<P,vector<P>,greater<P>> q;
        Dijkstra(int n,int _s):d(n,INF),G(n),s(_s){
            d[s] = 0;
        }

        void solve(){
            q.push(P(0,s));
            while(q.size()){
                P p = q.top();
                q.pop();
                int v = p.second;
                if(d[v] < p.first)continue;

                for(int i = 0;i < G[v].size();i++){
                    edge e = G[v][i];
                    if(d[e.to] > d[v] + e.cost){
                        d[e.to] = d[v] + e.cost;
                        q.push(P(d[e.to],e.to));
                    }
                }
            }
        }
};


int main(){
    int v,e,s;
    cin >> v >> e >> s;

    Dijkstra dij(v,s);

    for(int i = 0;i < e;i++){
        int a,b,d;
        cin >> a >> b >> d;
        dij.G[a].push_back(edge{b,d});
    }

    dij.solve();

    for(int i = 0;i < v;i++){
        if(dij.d[i] != INF)cout << dij.d[i] << endl;
        else cout << "INF" << endl;
    }
}



Measured memory_bytes: 12904
#include <stdio.h>
int main() {
  int a,b,c;
  scanf("%d %d", &a, &b);
  //printf("%d %d\n", a,b);
  
  c = a*(a-1)/2 +b*(b-1)/2; 
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
#include <iomanip>
using namespace std;

typedef pair<int,int> pi;

const int Maxn=200005;
const int INF=1e9+5;
const long double pai=3.1415926535897932384626;

int main(){
	int x1,y1,x2,y2;
	int f[Maxn];
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	int lx=min(x1,x2),ux=max(x1,x2),ly=min(y1,y2),uy=max(y1,y2);
	int n;
	scanf("%d",&n);
	int x,y;
	vector<pi> p;
	vector<int> h;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		if(x>=lx&&x<=ux&&y>=ly&&y<=uy) p.push_back(pi(x,y));
	}
	sort(p.begin(),p.end());
	for(int i=0;i<p.size();i++){
		h.push_back(p[i].second);
	}
	if(x1>x2){
		swap(x1,x2);
		swap(y1,y2);
	}
	if(y1<=y2){
		fill(f,f+Maxn,INF);
		for(int i=0;i<h.size();i++){
			int k=upper_bound(f+1,f+Maxn,h[i])-f;
			f[k]=h[i];
		}
		int id=lower_bound(f+1,f+Maxn,INF)-f-1;
		int d=min(ux-lx,uy-ly);
		if(id<=d) cout<<fixed<<setprecision(11)<<(long double)100*(ux-lx+uy-ly)-(long double)id*20+(long double)id*5*pai<<"\n";
		if(id==d+1) cout<<fixed<<setprecision(11)<<(long double)100*(ux-lx+uy-ly)-(long double)(id-1)*20+(long double)(id-1)*5*pai-(long double)20+(long double)10*pai<<"\n";
	}
	else{
		fill(f,f+Maxn,INF);
		reverse(h.begin(),h.end());
		for(int i=0;i<h.size();i++){
			int k=upper_bound(f+1,f+Maxn,h[i])-f;
			f[k]=h[i];
		}
		int id=lower_bound(f+1,f+Maxn,INF)-f-1;
		int d=min(ux-lx,uy-ly);
		if(id<=d) cout<<fixed<<setprecision(11)<<(long double)100*(ux-lx+uy-ly)-(long double)id*20+(long double)id*5*pai<<"\n";
		if(id==d+1) cout<<fixed<<setprecision(11)<<(long double)100*(ux-lx+uy-ly)-(long double)(id-1)*20+(long double)(id-1)*5*pai-(long double)20+(long double)10*pai<<"\n";
	}
return 0;
}

Measured memory_bytes: 4464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] x = new long[n + 1];
		long[] sum = new long[n + 1];
		sum[0] = 0;
		for(int i = 1; i < n + 1; i++) {
			x[i] = sc.nextLong();
			if(i == 1)
				sum[i] = 0;
			else {
				sum[i] = sum[i - 1] + x[i] - x[i - 1];
			}
		}
		long ans = Long.MAX_VALUE;
		for(int i = 1; k - 1 + i <= n; i++) {
			int tmp = k - 1 + i;
			long anstmp = 0;
			anstmp += sum[tmp] - sum[i];
			anstmp += Math.min(Math.abs(x[i]), Math.abs(x[tmp]));
			ans = Math.min(ans, anstmp);
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 60596
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
 
 
void func(long long A, long long B, long long C, long long D, long long E, long long F){
    double deg = 0;
    lli ansW=100*A,ansS=0;
    for(lli a=0;100*a*A <= F;a++){
    for(lli b=0;100*(a*A+b*B)<=F;b++){
    for(lli c=0; (100*(a*A+b*B)+c*C <= F && c*C <= E*(a*A+b*B));c++){
    for(lli d=0; (100*(a*A+b*B)+c*C+d*D<=F && (c*C+d*D)<=E*(a*A+b*B)) ;d++){
        lli suger = c*C+d*D;
        lli water = 100*(a*A+b*B) + suger;
        if(suger==0)continue;
        if(water==0)continue;
        if(deg<(100*suger)/(double)(water)){
            deg = (100*suger)/(double)(water);
            ansW = water;
            ansS = suger;
        }
    }
    }
    }
    }
    cout<<ansW<<" "<<ansS<<endl;
}
 
int main(){
    // cout << fixed << setprecision(5);
 
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    long long E;
    scanf("%lld",&E);
    long long F;
    scanf("%lld",&F);
    func(A, B, C, D, E, F);
    return 0;
}

Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:break
    ans=0
    k=0
    l1=[]
    l2=[]
    for i in range(n):
        a=input()
        l1.append(int(3600*int(a[0:2])+60*int(a[3:5])+int(a[6:8])))
        l2.append(int(3600*int(a[9:11])+60*int(a[12:14])+int(a[15:17])))
    l1.sort()
    l2.sort()
    for t in l1:
        while t>=l2[0]:
            k+=1
            l2.pop(0)
        if k==0:
            ans+=1
        else:
            k-=1
    print(ans)




Measured memory_bytes: 6440
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var tm = +(new Date()) + 900;
var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [a,b,c] = nexts(3);
  var cnt = 0;
  while(new Date() < tm){
    if(a % 2 || b % 2 || c % 2)return cnt;
    var a2 = b+c >> 1, b2 = a+c >> 1, c2 = a+b >> 1;
    a = a2, b = b2, c = c2;
    cnt++;
  }
  return -1;
}

Measured memory_bytes: 35420
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    # 最後に+は付けられない
    # bit全探索
    for i in r(1 << len(s) - 1):
        # sの中に+を入れて計算する
        p = ""
        for j, d in e(s):
            p += d
            if id.bit_n(i, j):
                p += "+"
            if j == len(s) - 1:
                break
        ans += eval(p)
    print(ans)


main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
    return 0;
}



Measured memory_bytes: 256
S=chomp(readline())
T=chomp(readline())
for i=1:length(S)
	flag=true
	for j=1:length(T)
		if S[mod1(i+j,length(S))]!=T[j]
			flag=false
		end
	end
	if flag
		println("Yes")
		exit()
	end
end
println("No")


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

vector<vector<int> > g;
int dp[101000];

int dfs(int v){
  if(dp[v] != -1) return dp[v];
  
  int res = 0;
  for(auto nv: g[v]) res = max(res, dfs(nv)+1);
  return dp[v] = res;
}

int main(void){
  int N, M;
  cin >> N >> M;
  g.assign(N, vector<int>());
  for(int i=0; i<N; i++) dp[i] = -1;
  for(int i=0; i<M; i++){
    int x, y; cin >> x >> y; x--; y--;
    g[x].push_back(y);
  }
  int ans = 0;
  for(int i=0; i<N; i++) ans = max(ans, dfs(i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
// #define MOD 2019
ll L,R;
void solve(){
  cin>>L>>R;
  cin.tie(0);
  ios::sync_with_stdio(false);
  const ll MOD = 2019;
  if(R- L > 2019)  R = L+2020;
  // else{
    ll ans =2000000001;
    for(ll i=L;i<R;i++){
      for(ll j = i+1;j<R+1;j++){
        if(ans > (i*j)%MOD) ans = (i*j)%MOD;
      }
      }
    cout<<ans<<endl;
  // }
}

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


Measured memory_bytes: 256
from sys import stdin
from bisect import bisect_left


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    B.sort()
    C.sort()

    nums = [0] * (N + 1)

    pos = 0
    for i, b in enumerate(B):
        pos = bisect_left(C, b + 1, pos)
        nums[i] = N - pos

    for i in range(N, 0, -1):
        nums[i - 1] += nums[i]

    ans = 0
    pos = 0
    for a in A:
        pos = bisect_left(B, a + 1, pos)
        ans += nums[pos]

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    int n;cin>>n;
    string a,b,c; cin>>a>>b>>c;
    int ans = 0;
    for(int i=0; i<n; i++) {
        if(a[i]==b[i]){
            if(b[i]==c[i]) ans +=0;
            else ans += 1;
        }
        else if(b[i]==c[i]) ans +=1;
        else if(a[i]==c[i]) ans +=1;
        else ans += 2;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define inf 1e18
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100001
// <<fixed << setprecision(9)

void err()
{
	cout<<"NO\n";
	exit(0);
}

int main()
{
	int i,j;
	string x,y;
	cin>>x>>y;
	int r=x.size(),c=y.size();
	int lcs[r+1][c+1];
	rep(i,0,c+1)
	{
		lcs[0][i]=0;
	}
	rep(i,0,r+1)
	{
		lcs[i][0]=0;
	}
	rep(i,1,r+1)
	{
		rep(j,1,c+1)
		{
			if(x[i-1]==y[j-1])lcs[i][j]=lcs[i-1][j-1]+1;
			else
			{
				lcs[i][j]=max(lcs[i][j-1],lcs[i-1][j]);
			}
		}
	}
//	cout<<lcs[r][c];

	stack<char> ans;
	i=r;j=c;
	while(i>0 && j>0)
	{
		if(x[i-1]==y[j-1])
		{
			ans.push(x[i-1]);
			i--;j--;
		}
		else
		{
			if(lcs[i][j-1]>=lcs[i-1][j])
			{
				j--;
			}
			else i--;
		}
	}
	while(ans.empty()==0)
	{
		cout<<ans.top();
		ans.pop();
	}
	return 0;
}



Measured memory_bytes: 35456
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;

int main(void) {
    double n,k; cin >> n >> k;
    string s; cin >> s;
    s[k-1] = tolower(s[k-1], locale());
    cout << s << endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
//#include<stdlib.h>
using namespace std;


int main()
{
	int n, q, t;
	string name;
	queue< pair<string, int> > Q;
	
	cin >> n >> q;
	
	for(int i = 0; i < n; i++)
	{
		cin >> name >> t;
		Q.push(make_pair(name,t));
	}
	
	pair<string, int> u;
	int elaps = 0, c;
	
	while(!Q.empty())
	{
		u = Q.front(); Q.pop();
		
		c = min(u.second, q);
		elaps += c;
		if(u.second - c > 0)
		{
			u.second -= c;
			Q.push(u);
		}
		else
		{
			cout << u.first << " " << elaps << endl;
		}
	}
	
//	system("pause");	
	return 0;
}


Measured memory_bytes: 6340
#include <stdio.h>

int main(){
  int n, i, turn_on=0, count=0;
  scanf("%d", &n);
  int a[n];
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  for(i=0; i<n; i++){
    turn_on=a[turn_on]-1;
    count++;
    if(turn_on==1){
      printf("%d\n", count);
      return 0;
    }
  }
  printf("-1\n");

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int R,C,sum,original[10][10000],max;
void search(int pattern[]){
    int map[10][10000],i,o,sum1;
    sum=0;
    for(i=0;i<R;i++)
        for(o=0;o<C;o++)
            map[i][o]=original[i][o];
    for(i=0;i<R;i++)
        if(pattern[i])
            for(o=0;o<C;o++)
                map[i][o]=1-map[i][o];
    for(i=0;sum1=0,i<C;i++){
        for(o=0;o<R;o++)
            sum1+=map[o][i];
        if(sum1 < R-sum1)
            sum1=R-sum1;
        sum+=sum1;
    }
    if(max < sum)
        max=sum;
}
void set(int line[],int x){
    int line1[10];
    if(x==R){
        search(line);
        return;
    }
    memcpy(line1,line,sizeof(int)*(x));
    line[x]=0;
    set(line,x+1);
    line1[x]=1;
    set(line1,x+1);
}
int main(void){
    int i,o,line[10]={0};
    for(;max=0,scanf("%d %d",&R,&C),R+C!=0;){
        for(i=0;i<R;i++)
            for(o=0;o<C;o++)
                scanf("%d",&original[i][o]);
        set(line,0);
        printf("%d\n",max);
    }
    return 0;
}

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

int digit(int C, int d);
int f(int C);

int A, B, j=0;

int main() {
  cin >> A >> B;
  for (A; A<B+1; A++){
    j += f(A);
  }
  cout << j << endl;
}

int digit(int C, int d){
  int x=0, y=1;
  for(int i=0; i<d; i++){
    x = (C%(y*10) -x)/y;
    y *= 10;
  }
  return x;
}

int f(int C){
  bool i;
  if(digit(C, 1) == digit(C, 5) && digit(C, 2) == digit(C, 4)){
    i = 1;
  } else {
    i = 0;
  }
  return i;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
int minimumCost(int price[], int n) 
{ 
	sort(price, price + n); 
	int totalCost = 0; 
	for (int i = n - 1; i > 1; i -= 2) { 
		if (i == 2) { 
			totalCost += price[2] + price[0]; 
		} 
		else { 
			int  price_first = price[i] + price[0] + 2 * price[1]; 
			int  price_second = price[i] + price[i - 1] + 2 * price[0]; 
			totalCost += min(price_first, price_second); 
		} 
	} 
	if (n == 1) { 
		totalCost += price[0]; 
	} 
	else { 
		totalCost += price[1]; 
	} 

	return totalCost; 
} 
int func(int a){
	if(a==0)
		return 0;
	return 1+2*func(a/2);
}
int32_t main() 
{ 
	int h;
	cin>>h;
	cout<<func(h);
	return 0; 
} 


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

int main(void) {
  int N, K, len=0, ans=0;
  cin >> N >> K;
  int d[K], A[K][100];
  int CNT[10000];
  
  for(int i=0; i<K; i++){
    cin >> d[i];
    for(int j=0; j<d[i]; j++){
      cin >> A[i][j];
    }
  }
  
  for(int i=0; i<K; i++){
    for(int j=0; j<d[i]; j++){
      CNT[A[i][j]-1]++;
      len++;
    }
  }
  
  for(int i=0; i<N; i++){
    if(CNT[i] == 0) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    char op;
    cin >> a >> op >> b;
    if(op == '-') cout << a-b;
    else cout << a + b;

    cout << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
n = int(input())
ans = ""

if n == 0: 
    ans = "0"
    
while n != 0:
    if n % 2 == 0:
        ans += "0"
    else:
        ans += "1"
        n -= 1
#     print(n, ans)
    n = n//-2
print(ans[::-1])

Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] a = new int[n+1];
	int[] b = new int[n];
	for (int i=0; i<n+1; i++) a[i] = sc.nextInt();
	for (int i=0; i<n; i++) b[i] = sc.nextInt();
	long count = 0;
	int nokori = 0;
	int carry = 0;
	int teki;
	for (int i=0; i<n; i++) {
	    nokori = b[i];
	    teki = a[i] - carry;
	    if (nokori >= teki) {
		nokori -= teki;
		count += teki;
		if (nokori >= a[i+1]) {
		    carry = a[i+1];
		    count += a[i+1];
		} else {
		    carry = nokori;
		    count += nokori;
		}
	    } else {
		carry = 0;
		count += nokori;
	    }
	}
	System.out.print(count);
    }
}


Measured memory_bytes: 59980
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

#define int long long

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1e5 + 123, inf = 1e18;
int n, l[N], r[N], pl[N], pr[N], sl[N], sr[N];
int f[N], g[N], ind[N], rev[N];

bool cmp(const int & x, const int & y) {
    if (l[x] == l[y]) {
        return r[x] < r[y];
    }
    return l[x] < l[y];
}

bool cmp2(const int & x, const int & y) {
    if (r[x] == r[y]) {
        return l[x] < l[y];
    }
    return r[x] < r[y];
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n;
    pl[0] = sl[n + 1] = 0, pr[0] = sr[n + 1] = inf;
    for (int i = 1; i <= n; i++) {
        cin >> l[i] >> r[i];
        pl[i] = max(pl[i - 1], l[i]);
        pr[i] = min(pr[i - 1], r[i]);
    }
    for (int i = n; i >= 1; i--) {
        sl[i] = max(sl[i + 1], l[i]);
        sr[i] = min(sr[i + 1], r[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, max(0LL, min(pr[i - 1], sr[i + 1]) - max(pl[i - 1], sl[i + 1]) + 1)
        + r[i] - l[i] + 1);
        ind[i] = rev[i] = i;
    }
    sort(ind + 1, ind + n + 1, cmp);
    sort(rev + 1, rev + n + 1, cmp2);
    int L = 0, R = inf;
    for (int i = 1; i <= n; i++) {
        int cur = rev[i];
        if (L > 0 && R < inf) {
            f[i] = max(0LL, R - L + 1);
        }   else {
            f[i] = 0;
        }
        L = max(L, l[cur]);
        R = min(R, r[cur]);
    }
    L = 0, R = inf;
    for (int i = n; i >= 1; i--) {
        int cur = ind[i];
        if (L > 0 && R < inf) {
            g[i] = max(0LL, R - L + 1);
        }   else {
            g[i] = -inf;
        }
        L = max(L, l[cur]);
        R = min(R, r[cur]);
    }
    multiset <int> st;
    for (int i = 1; i <= n; i++) {
        st.insert(r[rev[i]] + f[i]);
    }
    int j = 0;
    for (int i = 1; i <= n; i++) {
        int cur = ind[i];
        while (j + 1 <= n) {
            int k = rev[j + 1];
            if (r[k] < l[cur]) {
                L = max(L, l[k]);
                R = min(R, r[k]);
                st.erase(st.find(r[k] + f[j + 1]));
                j++;
            }   else {
                break;
            }
        }
        if (g[i] > -inf) {
            if (r[rev[1]] >= l[cur]) {
                ans = max(ans, r[rev[1]] - l[cur] + 1 + g[i]);
            }
        }   else {
            if (!st.empty()) {
                ans = max(ans, - l[cur] + 1 + *(--st.end()));
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 12800
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	ll n, k;
	cin >> n >> k;
	VL v(n);
	REP(i, n) { cin >> v[i]; }

	ll min = 1e15;
	REP(i, n - k + 1) {
		ll sum = 0;
		if (v[i] * v[i + k - 1] > 0) {
			sum = (v[i] < 0) ? -v[i] : v[i + k - 1];
		} else {
			ll sa = v[i];
			ll sb = v[i + k - 1];
			sum = std::min(sb - 2 * sa, 2 * sb - sa);
		}
		min = std::min(sum, min);
	}
	cout << min << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int d,n,i;
	int mennseki;
	
	while(scanf("%d",&d) != EOF){
		mennseki = 0;
		n = 600/d;
		for(i=0;i<n;i++){
			
			mennseki += d*(i)*d*(i)*d;
		}
	printf("%d\n",mennseki);
	}
	
			
		
return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env pypy3
import sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    print(N+N**2 + N**3)


# oj t -c "python main.py"
# acc s -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 61860
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int a[100010]; 
int main() {
  string s; cin >> s;
  int n = s.size();
  rep(i,n) {
    int st = i;
    while (i<n-1 && s[i] == s[i+1]) i++;
    int suc = i-st+1;
    if (s[i] == 'L') {
      a[st] += (suc+1) / 2;
      a[st-1] += suc / 2;
    } else {
      a[i] += (suc+1) / 2;
      a[i+1] += suc / 2;
    }
  }
  rep(i,n) cout << a[i] << " ";
  cout << endl;
  return 0;
}

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

#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

ll gcdll(ll a, ll b){
    if(!b) return a;
    return gcdll(b, a%b);
}

int gcd(int a, int b){
    if(!b) return a;
    return  gcd(b, a%b);
}

void seive(int n){
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=n; j+=i){
                is_prime[j] = false;
            }
        }
    }
}

vector<int> constructZFunc(string s){
    int n = s.size();
    vector<int> z(n);
    int l, r;
    l = r = 0;
    z[0] = 0;
    rep(i, 1, n-1){
        z[i] = 0;
        if(i<=r){
            z[i] = min(r-i+1, z[i-l]);  /// initialization, req. for linear time approach.
        }
        while(i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if(i+z[i]-1 > r){
            r = i+z[i]-1;
            l = i;
        }
    }
    return z;
}

ll solve(ll n){
    if(n == 0ll) return 0;
    if(n == 1ll) return 1ll;
    return 1+2*solve(n/2);
}

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

    ll n;
    cin>>n;
    cout<<solve(n);

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
    const int MAX = 1000;
    int D, G; cin >> D >> G;
    vector<int> dp(MAX + 1);
    for (int pt = 100; pt <= D * 100; pt += 100) {
        int num, comp; cin >> num >> comp;
        vector<int> ndp(dp);
        for (int i = 1; i <= num; i++) {
            int add = pt * i + comp * (i == num);
            for (int j = i; j <= MAX; j++) chmax(ndp[j], dp[j - i] + add);
        }
        dp = ndp;
    }
    int ans = 0;
    while (dp[ans] < G) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256