akhauriyash/Code-Regression huggingface dataset:
// 2011/02/19 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int sum = 0;
		for(int i=0; i<n; i++){
			int x, y, h, w;
			cin >> x >> y >> h >> w;
			int z = x+y+h;
			if(z<=60&&w<=2)
				sum += 600;
			else if(z<=80&&w<=5)
				sum += 800;
			else if(z<=100&&w<=10)
				sum += 1000;
			else if(z<=120&&w<=15)
				sum += 1200;
			else if(z<=140&&w<=20)
				sum += 1400;
			else if(z<=160&&w<=25)
				sum += 1600;
		}

		cout << sum << endl;
	}

	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main(){
    ll N;
    cin>>N;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    ll X = 0LL;
    for(ll i = 2; i < N; i++){
         X ^= v[i];
    }
    ll T = v[0] + v[1];
    ll Y = (T-X)/2;
    ll ans = 0;
    ll s = 1LL<<50;
    bool can = true;
  	if((T-X)%2!=0||(T-X)<0) can = false;
    while(s>0){
        if(!(X&s)&&(Y&s)) {
            ans += s;
            s >>= 1;
            continue;
        }
        if(!(X&s)&&!(Y&s)) {
            s >>= 1;
            continue;
        }
        s >>= 1;
    }
    if(ans>v[0]) can = false;
    s = 1LL<<50;
    while(s>0){
        if((X&s)&&!(Y&s)){
            if(ans+s>v[0]){
                s >>= 1;
                continue;
            }
            else {
                ans += s;
                s>>=1;
                continue;
            }
        }
      	if((X&s)&&(Y&s)) can = false;
        s>>=1;
    }
    if(can&&ans>0) cout<<v[0]-ans<<endl;
    else cout<<-1<<endl;
}


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

int main() {
	int n, ans, flag;
	cin >> n;
	char s;
	flag = 0;

	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == 'Y') {
			flag++;
			break;
		}

	}
	
	if (!flag) {
		cout << "Three";
	}
	else {
		cout << "Four";
	}
	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 all(v) begin(v),end(v)
using ll = long long;

int main() {
  string s;cin>>s;
  int n=s.size();
  cout<<s[0]<<n-2<<s[n-1]<<endl;
}

Measured memory_bytes: 3592
// OURL: https://atcoder.jp/contests/abc141/tasks/abc141_a
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

#ifdef LOCAL
#include "pprint.hpp"
pprint::PrettyPrinter printer;
#define debug(...) cerr << "[L" << __LINE__ << ":" <<#__VA_ARGS__ << "]:", printer.print(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  string s;
  cin >> s;
  debug(s);
  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  else if (s == "Rainy") cout << "Sunny" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <array>
#include <cassert>

using namespace std;

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

const ll MOD = 998244353;
const ll INF = LLONG_MAX;
const ll MAX_N = ll(3e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(a-x)<abs(b-x))cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}


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

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(v) int(v.size())

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/

int N;
int l[1005];
int ans;



int main() {
    scanf ("%d", &N);
    N *= 2;
    FO (i,0,N) scanf ("%d", &l[i]);
    sort (l, l+N);
    for (int i = N-2; i >= 0; i-=2) {
        ans += l[i];
    }
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
using namespace std;
#define N 100050
const long long mod = 1e9 + 7;
/*
ways[i]=way[i-1]+way[i-2]
 */
int n, m;
bool broken[N];
long long ways[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int pos;
    memset(broken, 0, sizeof(broken));
    for (int i = 0; i < m; i++)
    {
        cin >> pos;
        broken[pos] = 1;
    }
    memset(ways, 0, sizeof(ways));
    if (!broken[1])
        ways[1] = 1;
    if (!broken[2])
        ways[2] = ways[1] + 1;
    for (int i = 3; i <= n; i++)
    {
        if (!broken[i])
            ways[i] = (ways[i - 1] + ways[i - 2]) % mod;
    }
    cout << ways[n] << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line;
        String line1;
        while(true) {
            try {
                line = sc.nextLine();
                line1 = sc.nextLine();
            }catch(Exception e) {
                break;
            }
            int[] a = new int[4];
            int[] b = new int[4];
            String[] A = line.split(" ");
            String[] B = line1.split(" ");
            int hit = 0;
            int blow = 0;
            for(int i = 0; i < 4; i++) {
                a[i] = Integer.parseInt(A[i]);
                b[i] = Integer.parseInt(B[i]);
            }
            
            for(int i = 0; i < 4; i++) {
                if(a[i] == b[i]) {
                    hit++;
                    continue;
                }
                for(int j = 0; j < 4; j++) {
                    if(a[i] == b[j]) {
                        blow++;
                        break;
                    }
                }
            }
            System.out.println(hit+" "+blow);
        }
    }
}


Measured memory_bytes: 26080
package main

import (
	"fmt"
)

func main() {
	var count, a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)

	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i + 100*j + 50*k == x {
					count++
					break;
				} 
			}
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w,n;
    cin>>h>>w>>n;
    if (n%max(h,w)!=0) {
        cout<<n/max(h,w)+1<<endl;
    } else {
        cout<<n/max(h,w)<<endl;
    }
}

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

int main(){
  int s;
  cin >> s;
  int s1 = s / 100;
  int s2 = (s - s1*100) / 10;
  int s3 = s % 2;
  cout << (s1 + s2 + s3) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		if(inputArray.length == 2){
			int width = Integer.parseInt(inputArray[0]);
			int height = Integer.parseInt(inputArray[1]);

			int menseki = width * height;
			int syuu = (width + height) * 2;
			System.out.println(menseki + " " + syuu);
		}else{
			System.out.println("2???????????¶??°?????\?????????????????????");
		}
	}
}

Measured memory_bytes: 26048
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10

    N=II()
    S=input()
    p = 0
    num_right_p = 0
    ans = ''
    r = 0
    for s in S:
        if s == '(':
            p += 1
        else:
            if p > 0:
                p -= 1
            else:
                r += 1

    
        ans = '(' * r + S + ')' * p
    print(ans)
            
    

    
main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<ll> a;
int b[100];
ll n, k, sum;
int maxbit;

void f(ll a)
{
    for (ll i = 0; (a>>i) > 0; i++) {
        b[i] += (a>>i) & 1;
        if (maxbit < i)
            maxbit = i;
    }
}

ll g(ll num, int i)
{
    if (num > k) {
        return static_cast<ll>(-1e12);
    } else if ((1ll<<i) > k) {
        return 0;
    } else {
        //ll tmp1 = b[i] * (1<<i);
        //ll tmp2 = (n - b[i]) * (1<<i);
        ll tmp = (n - b[i] * 2) * (1ll<<i);
        if (tmp >= 0)
            return max(g(num, i+1), g(num + (1ll<<i), i+1) + tmp);
        else
            return g(num, i+1);
    }
}

ll h()
{
    ll r = 0ll, kk = 0ll;
    for (int i = 62; i > -1; i--) {
        if (kk + (1ll<<i) <= k && n - b[i] > b[i]) {
            r += (n - b[i]) * (1ll<<i);
            kk += (1ll<<i);
        } else {
            r += b[i] * (1ll<<i);
        }
    }
    return r;
}

int main()
{
    cin>>n>>k;
    REP(i,n) {
        ll ta;
        cin>>ta;
        a.push_back(ta);
        sum += ta;
        f(ta);
    }
    //cout<<g(0ll, 0) + sum<<endl;
    cout<<h()<<endl;

    return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
int n,m,sum;
const int N=10005;
bool cmp(int x,int y){
	return x>y;
}
int a[N];
int main ()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	    scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=m;i++)
	    sum+=a[i];
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
x=len(str(n))
for i in range(2,int(n**(1/2))+1):
  if n%i==0:
    a=int(n/i)
    if max(len(str(i)),len(str(a)))<x:
      x=max(len(str(i)),len(str(a)))
print(x)

Measured memory_bytes: 3060
from math import floor, ceil


def result_dividing_by_a_direction(x, y, is_ceil):
    new_x = floor(x / 3)
    if is_ceil:
        new_x = ceil(x / 3)
    return abs(new_x - (x - 2 * new_x)) * y


def result_dividing_2plus1(x, y, d):
    area1 = x * d
    area2 = (y - d) * (x // 2)
    area3 = (y - d) * (x - (x // 2))
    return max(area1, area2, area3) - min(area1, area2, area3)


def main():
    h, w = map(int, input().split())
    ans = h * w
    for i in range(2):
        ans = result_dividing_by_a_direction(h, w, i)
        ans = min(result_dividing_by_a_direction(w, h, i), ans)
    for d in range(1, w):
        ans = min(result_dividing_2plus1(h, w, d), ans)
    for d in range(1, h):
        ans = min(result_dividing_2plus1(w, h, d), ans)
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int n;
  cin >> n;
  long ans = 0;
  REP(a,1,n){
    int b = (n-1)/a;
    ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

int n;
const int N = 301;
vector<vector<vector<double>>> table(N,vector<vector<double>>(N,vector<double>(N)));

double f(int a, int b, int c){
	if (a < 0 or b < 0 or c < 0) return 0;
	if (a == 0 and b == 0 and c == 0) return 0;
	if (table[a][b][c] != 0) return table[a][b][c];
	int t = a+b+c;
	double ans = 0;
	ans += 1.0*c/t * f(a,b+1,c-1);
	ans += 1.0*b/t * f(a+1,b-1,c);
	ans += 1.0*a/t * f(a-1,b,c);
	ans += 1.0*n/t;
	table[a][b][c] = ans;
	return ans;
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int vi;
	cin >> n;
	int a = 0, b = 0, c = 0;
	for (int i=0; i<n; ++i){
		cin >> vi;
		if (vi == 1) a++;
		else if (vi == 2) b++;
		else c++;
	}
	cout.precision(10);
	cout << fixed;
	cout << f(a,b,c);
	return 0;
}


Measured memory_bytes: 219884
import java.util.Scanner;

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

		String a=sc.next();
		char[] mjs=new char[a.length()];

		for(int i=0; i<a.length(); i++) {
			mjs[i]=a.charAt(i);
		}

		int[] moji=new int[26];

		for(int i=0; i<a.length(); i++) {
			moji[mjs[i]-97]++;
		}

		char ke=97;
		for(int i=0; i<26; i++) {
			if(moji[i]==0) {
				ke+=i;
				char res=ke;
				System.out.println(res);
				System.exit(0);
			}
		}
		System.out.println("None");
	}
}

Measured memory_bytes: 26988
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

int n, pos;
vector<int> pre, ina, post;

void rec(int l, int r){
    if(l>=r)return;
    int root = pre[pos++];
    int m = distance(ina.begin(), find(ina.begin(), ina.end(), root));
    rec(l, m);
    rec(m+1, r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0,pre.size());
    for(int i=0; i<n; i++){
        if(i)cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main(void){
    
    /////////
    //write//
    /////////

    
    int k;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> k;
        pre.push_back(k);
    }
    
    for(int i=0; i<n; i++){
        cin >> k;
        ina.push_back(k);
    }
    
    solve();
    
    return  0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int N;
  cin>>N;
  vector<int>table(10000005);
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N/i;j++){
      table[i*j]++;
    }
  }
  int64_t sum=0;
  for(int i=1;i<=N;i++){
   sum+=(int64_t)i*table[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 42284
#include<iostream>
#include<cstdio>

using namespace std;

void read(int &x){
	x=0;int f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	x*=f;
}

int a;

int main(){
	int n;
	read(n);
	for(int i = 1; i <= n; i++){
		read(a);
		if(a%2!=0) continue;
		if(a%3!=0&&a%5!=0){
			cout <<"DENIED";return 0;
		}
	}
	cout << "APPROVED";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	string s;
	cin >> s;
	int c = 0, c1 = 0;;
	for (int i = 0; s[i] != 'A'; i++) c++;
	for (int j = s.size()-1; s[j] != 'Z'; j--) c1++;
	cout << s.size() - (c + c1) << endl;
	return 0;
}



Measured memory_bytes: 640
S = input()

loop = True
index = 1
ans = 1
stmp = S[0]
cnt = 1
while loop:
    if index == len(S):
        break
    if stmp == S[cnt: index + 1]:
        index += 1
        continue
    else:
        ans += 1
        index += 1
        stmp = S[cnt: index]
        cnt = index
print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = inx(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

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

void solve(){
	
	ll N;
	cin >> N;
	vl A(N);
	vl p(1000007);
	rep(i, N){
		cin >> A[i];
		p[A[i]]++;
	}
	bool flg = true;

	rep2(i, 2, 1000007){
		ll cnt = 0;
		for(ll j = i; j < 1000007; j += i) cnt += p[j];
		if(cnt > 1){
			flg = false;
			break;
		}
	}
	
	if(flg){
		print("pairwise coprime");
		return;
	}
	
	ll g = 0;
	rep(i, N) g = gcd(g, A[i]);
	if(g == 1) print("setwise coprime");
	else print("not coprime");
		
}	

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
    
	return 0;
	
}





Measured memory_bytes: 18724
#include<iostream>
#include<math.h>
using namespace std;

bool isprime(int x){
    if ( x == 2 ) return true;
    if ( x < 2 || x % 2 == 0 ) return false;
    
    int a = 3;
    while ( a <= sqrt(x)){
        if ( x % a == 0 ) return false;
        a += 2;
    }
    
    return true;
}

int main(){
    
    int n, x, count = 0;
    cin >> n;
    for ( int i = 0; i < n; i++ ){
        cin >> x;
        if ( isprime(x)) count++;
    }
    cout << count << endl;
    
    return 0;
}


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

using namespace std;

int main(){

    string s;
    int n, num1[101], num2[101], num3[102];

    cin >> n;

    for(int i = 0; i < n; ++i){

        memset(num1, 0, sizeof(num1));
        memset(num2, 0, sizeof(num2));
        memset(num3, 0, sizeof(num3));

        cin >> s;

        for(int i = 0, len = s.size(); i < len; ++i){
            num1[i] = s[len - 1 - i] - '0';
        }

        cin >> s;

        for(int i = 0, len = s.size(); i < len; ++i){
            num2[i] = s[len - 1 - i] - '0';
        }

        for(int i = 0, num; i < 101; ++i){
            num = num1[i] + num2[i] + num3[i];
            num3[i] = num % 10;
            num3[i + 1] = num / 10;
        }

        int ldigit = 0;
        for(int i = 101; i >= 0; i--){
            if(num3[i] != 0){
                ldigit = i;
                break;
            }
        }

        if((ldigit + 1) > 80){
            cout << "overflow" << endl;
        } else {
            for(int i = ldigit; i >= 0; i--){
                cout << num3[i];
            }
            cout << endl;
        }

    }

}

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


int main(){
	ios;
	string s;
	cin>>s;
	
	if(s=="SUN")cout<<"7\n";
	else if (s=="MON")cout<<"6\n";
	else if (s=="TUE")cout<<"5\n";
	else if (s=="WED")cout<<"4\n";
	else if (s=="THU")cout<<"3\n";
	else if (s=="FRI")cout<<"2\n";
	else cout<<"1\n";
	return 0;
}



Measured memory_bytes: 256
(sx, sy, tx, ty) = [int(i) for i in input().split(" ")]
dx = tx - sx
dy = ty - sy

s  = ""
# go 1st
s += "R"*dx
s += "U"*dy

# go 2nd
s += "L"*dx
s += "D"*dy

# go 3rd
s += "D"
s += "R"*(dx + 1)
s += "U"*(dy + 1)
s += "L"

# go 4th
s += "U"
s += "L"*(dx + 1)
s += "D"*(dy + 1)
s += "R"

print(s)


Measured memory_bytes: 3064
card = [0]*3
for i in range(3):
    a = input().split()
    card[i] = [int(s) for s in a]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == card[j][k]:
                card[j][k] = 0
if (card[0][0] == 0 and card[1][0] == 0 and card[2][0] == 0) or (card[0][1] == 0 and card[1][1] == 0 and card[2][1] == 0) or (card[0][2] == 0 and card[1][2] == 0 and card[2][2] == 0) or(card[0][0] == 0 and card[0][1] == 0 and card[0][2] == 0) or (card[1][0] == 0 and card[1][1] == 0 and card[1][2] == 0) or (card[2][0] == 0 and card[2][1] == 0 and card[2][2] == 0) or (card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0) or (card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0):
    print("Yes")
else:
    print("No")

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[10], s;

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	sort(a, a + n);
	reverse(a, a + n);
	inc(i, n) { s += (i == 0 ? a[i] / 2 : a[i]); }
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
from math import sqrt

N = int(input())

F = 10**12
for i in range(int(sqrt(N))):
    if N % (i+1) == 0:
        cand = max([len(str(int(i+1))), len(str(int(N/(i+1))))])
        if F > cand:
            F = cand
print(cand)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int INF = 1e8;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];
    P pma(-INF, -INF), pmi(INF, INF), nma(-INF, INF), nmi(INF, -INF);
    REP(i,h) REP(j,w){
        if (s[i][j] != 'B') continue;
        if (i + j > pma.first + pma.second) pma = P(i, j);
        if (i + j < pmi.first + pmi.second) pmi = P(i, j);
        if (i - j > nma.first - nma.second) nma = P(i, j);
        if (i - j < nmi.first - nmi.second) nmi = P(i, j);
    }
    int ans = 0;
    REP(i,h) REP(j,w){
        if (s[i][j] != 'B') continue;
        chmax(ans, abs(i - pma.first) + abs(j - pma.second));
        chmax(ans, abs(i - pmi.first) + abs(j - pmi.second));
        chmax(ans, abs(i - nma.first) + abs(j - nma.second));
        chmax(ans, abs(i - nma.first) + abs(j - nma.second));
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3804
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    N,=pin()
    A=lispin()
    A.sort()
    #print(A)
    temp=0
    for i in range(N*2):
        t=A.pop()
        if i%2:temp+=t
    print(temp)
#%%submit!
resolve()

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

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

  for (int i = 1; i <= 100; i ++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define int long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n;
int a[200010];
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int mx=a[1];
	int ans=0;
	for(int i=2;i<=n;i++){
		if(a[i]>mx)mx=a[i];
		else ans+=mx-a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5168
#include<iostream>
#include<unordered_map>
#include<string>
#include<algorithm>

using namespace std;

int main(void){
    int n;
    long int count = 0;
    string s;
    unordered_map<string, int> um;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s;
        sort(s.begin(), s.end());
        um[s]++;
    }
    for(auto &a : um){
        int x = a.second;
        count += (long int)x * (x - 1) / 2;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1e5 + 7; 
 
int n, q, z[MAXN];
vector<int> v;
map<int, int> mp;
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> q;
	v.push_back(n);
	for (int i = 0; i < q; i++) {
		int f;
		cin >> f;
		while (!v.empty() && v.back() >= f) v.pop_back();
		v.push_back(f);
	}
	reverse(v.begin(), v.end());
	mp[v[0]] = 1;
	for (int i = 0; i < (int)v.size(); i++) {
		int a = v[i];
		while (a > v.back()) {
			int tmp = *--upper_bound(v.rbegin(), v.rend() - i - 1, a);
			mp[tmp] += mp[v[i]] * (a / tmp);
			a %= tmp;
		}
		z[a] += mp[v[i]];
	}
	for (int i = MAXN - 2; ~i; i--) z[i] = z[i] + z[i + 1];
	for (int i = 1; i <= n; i++) cout << z[i] << '\n';
	return 0;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  int count = 0;
  sort(d.begin(),d.end());
  for (int i = 0; i < N; i++) {
    if (d[i] == d[i + 1]) {
      count++;
    }
  }
  int ans = d.size() - count;
  cout << ans << endl;
    
       

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	class Masu {
		int masuNumber;
		ArrayList<Integer> closeMasuNumber;

		Masu(int i) {
			masuNumber = i;
			closeMasuNumber = new ArrayList<Integer>();
		}
	}

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

		// マスの数を取得
		int masuNum = scan.nextInt();

		ArrayList<Masu> masuList = new ArrayList<Masu>();
		Main main = new Main();
		for(int i = 0; i < masuNum; i++) {
			masuList.add(main.new Masu(i));
		}

		for(int i = 0; i < masuNum - 1; i++) {
			main.inputMasu(scan.nextInt(), scan.nextInt(), masuList);
		}

		int[] fennecList = new int[masuNum];
		fennecList[0] = -1;
		int[] snukeList = new int[masuNum];
		snukeList[masuNum - 1] = -1;

		// 何手で相手のマスに行き着くか計算する
		// fennecの探査
		main.tansa(masuList,fennecList,0,0);
		// snukeの探査
		main.tansa(masuList,snukeList,masuNum - 1,0);

		int fennecWinMasu = 0;
		int snukeWinMasu = 0;

		for(int i = 0; i < masuNum; i++) {
			if(fennecList[i] <= snukeList[i]) {
				fennecWinMasu++;
			} else {
				snukeWinMasu++;
			}
		}

		if(fennecWinMasu > snukeWinMasu) {
			System.out.println("Fennec");
		} else {
			System.out.println("Snuke");
		}
	}

	private void inputMasu(int i, int j, ArrayList<Masu> masuList) {
		masuList.get(i - 1).closeMasuNumber.add(j - 1);
		masuList.get(j - 1).closeMasuNumber.add(i - 1);
	}

	private void tansa(ArrayList<Masu> masuList, int[] tansaList, int masu, int depth) {
		ArrayList<Integer> closeMasuList = masuList.get(masu).closeMasuNumber;

		for(Integer i:closeMasuList) {
			if(tansaList[i] == 0) {
				tansaList[i] = depth + 1;
				tansa(masuList, tansaList, i , depth + 1);
			}
		}
	}
}

Measured memory_bytes: 125108
import math

originN = int(raw_input())

isValid = False
for h in xrange(1, 3501):
    for n in xrange(1, 3501):
        if (4*n*h-n*originN-h*originN) > 0 and (originN*n*h) % (4*n*h-n*originN-h*originN) == 0:
            isValid = True
            print str(h)+" "+str(n)+" "+str((originN*n*h)/(4*n*h-n*originN-h*originN))
            break
    if isValid: break


Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int main()
{
  int a,ans=0;
  cin>>a;
  ans+=(a%10==9);
  ans+=(a/10==9);
  if(ans>=1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main() {
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0) cout << 1 << "\n";
    else if(b==0) cout << 2 << "\n";
    else if(c==0) cout << 3 << "\n";
    else if(d==0) cout << 4 << "\n";
    else cout << 5 << "\n";
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void chey(){ cout <<"hey" <<endl; }


int main() {
  int x,y,z; cin >>x >>y >>z;
  swap(x,y); swap(x,z);
  cout <<x <<" " <<y <<" " <<z <<endl;
}

Measured memory_bytes: 768
#include <iostream>                                                                                                          
#include <vector>
#include <queue>

int main(){
   int H, W;
   std::cin >> H >> W;
   std::vector<std::string> A(H);
   std::queue<int> p;
   for(int i=0; i<H; ++i){
      std::cin >> A[i];
      for(int j=0; j<W; ++j)
         if(A[i][j]=='#') p.push(i*W+j);
   }   

   int ans = -1; 
   while(!p.empty()){
      std::queue<int> q = p;
      while(!q.empty()){
         int i = q.front()/W;
         int j = q.front()%W;
         q.pop();
         p.pop();
        if(i>0   && A[i-1][j]=='.'){
            p.push((i-1)*W+j);
            A[i-1][j] = '#';
         }
         if(i+1<H && A[i+1][j]=='.'){
            p.push((i+1)*W+j);
            A[i+1][j] = '#';
         }
         if(j>0   && A[i][j-1]=='.'){
            p.push(i*W+(j-1));
            A[i][j-1] = '#';
         }
         if(j+1<W && A[i][j+1]=='.'){
            p.push(i*W+(j+1));
            A[i][j+1] = '#';
         }
      }
      ++ans;
   }
   std::cout << ans << std::endl;

   return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    int ans = 0;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    int cnt = 0;
    rep(i, n-1) {
        //cout << h[i+1] << " " << h[i] << endl;
        if (h[i+1] > h[i]) {
            ans = max(ans, cnt);
            cnt = 0;
        }
        else {
            ++cnt;
        }
        if (i == n - 2) {
            ans = max(ans, cnt);
        }
    } 
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;

int main()
{
    IOS;
    //freopen("fr.txt","r",stdin);
    int m,n;
    cin>>m>>n;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#define maxn 1000000007
main()
{
    int i,j;
    long long n,s;
    while(scanf("%lld",&n)!=EOF)
    {s=1;
    for(i=1;i<=n;i++)
        {s=s*i;
        s=s%maxn;
       }
    printf("%lld\n",s%maxn);
    }
}


Measured memory_bytes: 128
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int N;
int c[501] = {};
int s[501] = {};
int f[501] = {};

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

  int N;
  cin >> N;

  REP(i, N - 1) {
    cin >> c[i] >> s[i] >> f[i];
  }

  REP(i, N) {
    int t = 0;
    for (int j = i; j < N - 1; j++) {
      if (t <= s[j]) {
        t = s[j];
      } else {
        int k = ceil((double)(t - s[j]) / f[j]);
        t = s[j] + k * f[j];
      }
      t += c[j];
    }
    cout << t << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int ans = 0;
		for(int i = 0; i*r <= n; i++){
			for(int j = 0; i*r+j*g <= n; j++){
				if((n-(i*r+j*g))%b == 0){
					ans++;
				}
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;
vector<char> acgt{'A', 'C', 'G', 'T'};

int main(int argc, char **argv)
{
	string str; cin >> str;

	ll res{0};
	for (ll i = 0; i < (ll)str.size(); ++i)
	{
		ll tmp{0};
		for (ll j = i; j < (ll)str.size(); ++j )
		{
			auto it = find(acgt.begin(), acgt.end(), str[j]);
			if (it == acgt.end()) break;
			++tmp;
		}
		res = max(res, tmp);
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define chmin(x,y) x = min(x, y)
#define chmax(x,y) x = max(x, y)
#define V vector
vector<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
vector<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    int st = -1;
    for (int i = 0; i + m - 1 < n; i++) {
        bool flag = true;
        rep(j, m) {
            if (!(s[i+j] == t[j] || s[i+j] == '?')) flag = false;
        }
        if (flag) chmax(st, i);
    }
    if (st == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    rep(i, m) {
        s[st+i] = t[i];
    }
    rep(i, n) {
        if (s[i] == '?') cout << 'a';
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    int maxV = max(max(a, b), c);
    cout << sum - maxV << "\n";
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right


def det(p1, p2, p3):
    area = (p2[0] - p1[0])*(p3[1] - p1[1]) - (p2[1] - p1[1])*(p3[0] - p1[0])
    return area > 0


def convex_hull(pts):
    pts = sorted(pts)
    n = len(pts)
    extsize = 0
    extpts = []
    for i in range(n):
        while extsize > 1:
            if det(extpts[-2], extpts[-1], pts[i]):
                break
            extsize -= 1
            extpts.pop()
        extpts.append(pts[i])
        extsize += 1
    t = extsize
    for i in range(n-1, -1, -1):
        while extsize > t:
            if det(extpts[-2], extpts[-1], pts[i]):
                break
            extsize -= 1
            extpts.pop()
        extpts.append(pts[i])
        extsize += 1
    return extpts[:-1]


n = int(input())
aa = [int(x) for x in input().split()]
bb = [int(x) for x in input().split()]

ma = max(aa)
ind = -1
for i in range(n):
    if ma == aa[i]:
        ind = i
        break

a = aa[i:] + aa[:i+1]
b = bb[i:] + bb[:i+1]

c = [0]*(n+1)
for i in range(2, n+1):
    c[i] = 2*(c[i-1]+b[i-1])-c[i-2]

pts = []
for i in range(n+1):
    pts.append((i, a[i]-c[i]))

f = [-10**15]*(n+1)
ext = []

for i, val in convex_hull(pts):
    if val*n < (a[0]-c[0])*(n-i)+(a[n]-c[n])*i:
        continue
    f[i] = val
    ext.append(i)

ext = sorted(ext)

for i in range(n+1):
    if f[i] == -10**15:
        t = bisect_right(ext, i)
        l = ext[t-1]
        r = ext[t]
        f[i] = f[l] + (i-l)*(f[r]-f[l])/(r-l)


ans = 0
for i in range(1, n+1):
    ans += f[i]+c[i]

print(f'{ans/n:.12f}')


Measured memory_bytes: 147044
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n;cin >> n;n--;
	string str = "";
	bool flag = false;

	while(1){
		//cout << n % 26 << " " << n << endl;
		if(flag && (n % 26 == 0)){
			n--;
			str = (char)('a' + (n % 26) + 1) + str;
		}
		else {
			str = (char)('a' + (n % 26)) + str;
		}
		n /= 26;
		if(n == 0)break;
		flag = true;
	}

	//cout << str << endl;
	REP(i, str.size() - 1)str[i]--;
	cout << str << endl;

	return 0;
}


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

typedef long long ll;
typedef std::pair <ll, int> pli;

bool operator < (pli p1, pli p2){
    return p1.first * p2.second < p2.first * p1.second;
}

int sum(ll n){
    int ret = 0;
    while (n){
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main(){
    std::vector <ll> vec;
    for (int i = 0; i <= 13; ++ i){
        for (int j = 0; j < 1000; ++ j){
            ll x = j;
            for (int k = 0; k < i; ++ k){
                x = x * 10 + 9;
            }
            vec.push_back(x);
        }
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    vec.erase(vec.begin());
    std::vector <pli> vec1;
    for (auto u : vec){
        vec1.push_back({u, sum(u)});
    }
    vec.clear();
    pli min;
    for (int i = vec1.size() - 1; i >= 0; -- i){
        if (i == vec1.size() - 1){
            min = vec1[i];
            vec.push_back(vec1[i].first);
            continue;
        }
        if (min < vec1[i]) continue;
        vec.push_back(vec1[i].first);
        min = std::min(min, vec1[i]);
    }
    std::reverse(vec.begin(), vec.end());
    int k;
    scanf("%d", &k);
    for (int i = 0; i < k; ++ i){
        printf("%lld\n", vec[i]);
    }
    return 0;
}

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

#define       pb                 push_back
#define       mx                 200005
#define       MOD                1000000007
#define 	  optimize           ios::sync_with_stdio(0);cin.tie(0);
#define 	  inf                0x3f3f3f3f
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);

using namespace std;

typedef       long long int      ll;
typedef       vector<int> 	     vi;

int main()
{
    int n, a[55];
    double ans = 0;

    cin >> n;

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

    sort(a, a+n);

    ans = (((double)a[0])+((double)a[1]))/2.0;

    for(int i = 2; i < n; i++)
    {
        ans = (ans+((double)a[i]))/2.0;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e6;
const int INF=1e9;
int main(){
	int N,L;cin>>N>>L;
	if(L>=0) cout<<L*(N-1)+N*(N-1)/2;
	else if(L+N-1>=0) cout<<L*N+N*(N-1)/2;
	else cout<<L*(N-1)+(N-1)*(N-2)/2;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();

    let ans = if c < (a - b) { 0 } else { c - a + b };

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


Measured memory_bytes: 4352
#![allow(dead_code, unused_mut, unused_variables)]
use std::collections::VecDeque;
use std::io::*;
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
impl<'a> Io<'a> {
    fn r<T: std::str::FromStr>(&mut self) -> T {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!())
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::str::FromStr>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
        }
    }
}
struct IoIter<'a: 'b, 'b, T: std::str::FromStr> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
}
impl<'a, 'b, T: std::str::FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<T> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let io = Io {
        r: r,
        w: w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    problem(io);
}

fn problem(mut io: Io) {
    let n: isize = io.r();
    let m: usize = io.r();
    let cost: isize = io.iter::<isize>().take(m).sum();

    let free = n - cost;
    if free < 0 {
        io.w(-1i8);
    } else {
        io.w(free);
    }
}


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

unsigned gcd(unsigned a, unsigned b) {
    if (a < b) return gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
// ref: https://qiita.com/EqualL2/items/6e3de4d1d09e2e5f3611

int main() {
    int w, h, c;
    cin >> w >> h >> c;
    const int g = gcd(w, h);
    cout << w / g * h / g * c << endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    double a, l, x;
    while(cin >> a >> l >> x){
        double ret = 0;
        double d = sqrt(abs(l*l-(a/2)*(a/2)));
        ret += a*d/2;
        double e = sqrt(pow((l+x)/2, 2)-pow((l/2), 2));
        ret += e*l;
        printf("%.9f\n", ret);
    }
}

Measured memory_bytes: 1244