akhauriyash/Code-Regression huggingface dataset:
// Problem : C - Ubiquity
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

Falling down is an accident, Staying down is a choice.

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

long long modexp(long long x,long long n,long long M)
{
    long long result=1;
    while(n>0)
    {
        if(n&1)
            result=(result*x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

int main()
{
    io;
    ll n;
    cin>>n;
    
    cout<<((modexp(10,n,mod)%mod+modexp(8,n,mod)%mod)%mod-(2%mod*modexp(9,n,mod)%mod)+mod)%mod;
    return 0;
}



Measured memory_bytes: 3668
package main

import "fmt"

var N int
var P []int

func main() {
	fmt.Scan(&N)
	num := 0
	if N == 0 {
		fmt.Println("0")
	}
	tmp := 0
	min := 0
	fmt.Scan(&min)
	for i := 1; i < N; i++ {
		fmt.Scan(&tmp)
		if tmp > min {
			num++
		}
		if min > tmp {
			min = tmp
		}
	}
	fmt.Println(N - num)
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  int ans=0;
  for(int j=0;j<k;j++){
    ans+=p.at(j);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    int a=0,b=0;
    cin>>s;
    a=a*10+s[2]-'0';
    a=a*10+s[3]-'0';
    b=b*10+s[0]-'0';
    b=b*10+s[1]-'0';
    if(a>=1&&a<=12&&b>=1&&b<=12) cout<<"AMBIGUOUS"<<endl;
    else if(a>=1&&a<=12) cout<<"YYMM"<<endl;
    else if(b>=1&&b<=12) cout<<"MMYY"<<endl;
    else cout<<"NA"<<endl;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A.sort()
F.sort(reverse=True)
l,r = 0,10**12+1
while l <r:
    mid = (l+r)//2
    cnt = 0
    for a,f in zip(A,F):
        cnt += max(0,a-mid//f)
    if cnt <=k:
        r = mid
    else:
        l = mid+1
print(l)

Measured memory_bytes: 103964
#include<stdio.h>
int main(void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  while(1){
    c-=b;
    if(c<=0){printf("Yes");
             return 0;
            }
    a-=d;
    if(a<=0){printf("No");
            return 0;
           }
  }
  return 0;
}

Measured memory_bytes: 1732
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
l = LI()
l.sort(reverse=True)
if l[0] == l[1] + l[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 74648
N, M, Q = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(Q)]
A = [1] * N
ans = 0

for a, b, c, d in l:
    if A[b-1] - A[a-1] == c:
        ans += d

if M > 1:
    while True:
        A[-1] += 1
        if A[-1] == M + 1:
            for i in range(1, N):
                A[-(i+1)] += 1
                for k in range(N-(i+1), N):
                    A[k] = A[-(i+1)]
                if A[-(i+1)] != M + 1:
                    break
            
        ans_ = 0
        for a, b, c, d in l:
            if A[b-1] - A[a-1] == c:
                ans_ += d
        ans = max(ans, ans_)

        if A[0] == M:
            break
print(ans)

    
    






Measured memory_bytes: 68200
#include<iostream>
using namespace std;
int main(){
    long a=0,ans=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A')s[i]='1';
        if(i<s.size()-1&&s[i]=='B'&&s[i+1]=='C')s.replace(s.begin()+i,s.begin()+i+2,"2");
    }
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')a++;
        else if(s[i]=='2')ans+=a;
        else a=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <stdio.h>
long long a [100010];
int main (){
    int n;
    scanf("%d",&n);

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

    int zero =0;
    for(int i=0;i<n;i++)if(a[i]==0) zero ++;
    if(zero >0){
    // a[i] contains 0
    printf("0\n");
    return 0;
    }


    long long prod =1;

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

        if(a[i ] <=1000000000000000000/ prod ){
        // This condition is equivalent to prod*a[i] <=10ˆ18
        prod *=a[i];
        }else{
         printf("-1\n");
        return 0;

      }
    }

    printf("%lld\n",prod );
}


Measured memory_bytes: 4484
package main


import (
    "bufio"
    "os"
    "strconv"
    "math"
    "fmt"
)

/* input */
var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
    return n
}

func abs(x int) int {
    return int(math.Abs(float64(x)))
}

func ceil(x, y int) int {
    ret := x / y
    if x % y == 0{
        return ret
    } else {
        return ret + 1
    }
}

func check(x int, a int, b int, hList []int) bool {
    defaultDamage := b * x
    cnt := 0
    for _, h := range hList {
        if h > defaultDamage {
            cnt += ceil(h - defaultDamage, a - b)
        }
    }
    return cnt <= x
}

func main() {
    sc.Split(bufio.ScanWords)
    n, a, b := readInt(), readInt(), readInt()
    var hList []int
    for i := 0; i < n; i++ {
        hList = append(hList, readInt())
    }
    left, right := 0, 1000000000
    for abs(right - left) > 1 {
        center := (right + left) / 2
        if check(center, a, b, hList) {
            right = center
        } else {
            left = center
        }
    }
    fmt.Println(right)
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxA = 1e5 + 5;

// THINK: INT vs LONG LONG?

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

	int n;
	cin >> n;
	vector<int> cnt_odd(mxA), cnt_even(mxA);
	for (int i = 0; i < n; ++i) {
		int foo;
		cin >> foo;
		if (i & 1) cnt_odd[foo]++;
		else cnt_even[foo]++;
	}
	int x = (int) (max_element(cnt_odd.begin(), cnt_odd.end()) - cnt_odd.begin());
	int y = (int) (max_element(cnt_even.begin(), cnt_even.end()) - cnt_even.begin());
	if (x == y) {
		vector<int> ncnt_odd = cnt_odd;
		ncnt_odd[x] = 0;
		vector<int> ncnt_even = cnt_even;
		ncnt_even[x] = 0;
		int ans1 = n - *max_element(ncnt_odd.begin(), ncnt_odd.end()) - *max_element(cnt_even.begin(), cnt_even.end());
		int ans2 = n - *max_element(cnt_odd.begin(), cnt_odd.end()) - *max_element(ncnt_even.begin(), ncnt_even.end());
		cout << min(ans1, ans2) << '\n';

	}
	else {
		cout << (n - *max_element(cnt_odd.begin(), cnt_odd.end()) - *max_element(cnt_even.begin(), cnt_even.end())) << '\n';
	}
	return 0;
}

Measured memory_bytes: 4788
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>

using namespace std;

int main(){
	int N;
	scanf("%d",&N);

	string S,T,out="";
	cin >> S  >> T;
	for(int i=0;i<N;i++){
		out += S[i];
		out += T[i];
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c,d,e,f,g,h;
	cin>>a>>b>>c>>d;
	e=a*c;
	f=a*d;
	g=b*c;
	h=b*d;
	cout<<max(e,max(f,max(g,h)));
	
	return 0;
}

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

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

 long long x;
 cin >> x;
 long long init = 100;
 int year = 0;
 while(init < x){
 	init += init / 100;
 	year++;
 }
 cout << year << "\n";


}


Measured memory_bytes: 3640
# l = open('input.txt').readline()
l = input()

k = 0
S1, S2 = [], []
for i in range(len(l)):
    if l[i] == '\\':
        S1.append(i)
    elif l[i] == '/' and S1:
        j = S1.pop()
        a = i - j
        k += i - j

        while S2 and S2[-1][0] > j:
            a += S2.pop()[1]
        S2.append((j, a))
print(k)
print(len(S2), *(a for j, a in S2))

Measured memory_bytes: 8172
"""
algo1 algo2 algo3 
 0     0     0
"""
n, m, x = map(int, raw_input().split(' '))
books = [map(int, raw_input().split(' ')) for _ in range(n)]

def dfs(i, books, x, cc, knowledge, r):
	if i == len(books):
		if all([k>= x for k in knowledge]):
			r[0] = min(r[0], cc)
		return

	u = books[i]
	cost = u[0]
	book = u[1:]
	improvedknowledge = [k+book[ii] for ii,k in enumerate(knowledge)]
	
	dfs(i+1, books, x, cc + cost, improvedknowledge, r)
	dfs(i+1, books, x, cc, knowledge[::], r)

r = [+float('inf')]
dfs(0, books, x, 0, [0] * m, r)
print r[0] if r[0] < float('inf') else -1


Measured memory_bytes: 73576
/*
車両の出入り。
入力された番号の車両が格納されていき、0が入力されたときは、
最後に格納した（1番手前にある）車両の番号を表示し、出発させる。
*/

#include <iostream>
using namespace std;

int main(void) {
    int garage[100] = {};
    int size;
    int i = 0;
    int number;
    
    while(cin >> number) {
        if(number == 0) {
            i--;
            if(i < 0) {
                break;
            }
            cout << garage[i] << endl;
        } else {
            garage[i] = number;
            i++;
        }
    }
}


Measured memory_bytes: 3004
<?php
fscanf(STDIN, "%s", $N);
fscanf(STDIN, "%s", $X);

$count = 0;
while (true) {
    $wPos = strpos($X, 'W');
    $rPos = strrpos($X, 'R');
    if ($wPos === false || $rPos === false || $wPos >= $rPos) {
        break;
    }

    // 切り取る
    $tmp = $X;
    $tmp = substr($tmp, $wPos + 1);
    $tmp = substr($tmp, 0, -(strlen($X) - $rPos));
    $X = $tmp;
    $count++;
}
echo $count;


Measured memory_bytes: 16792
#include <bits/stdc++.h>
using namespace std;
 
void solve()
{
	int s,w;
  	cin>>s>>w;
  	if(w>=s) cout<<"unsafe";
      else cout<<"safe";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
return 0;
}

Measured memory_bytes: 3620
//abc123_c.cpp
//Sat Apr 20 18:10:13 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,a,b,c,d,e;
	cin >> n >> a >> b >> c >> d >> e;

	ll mintime = min({a,b,c,d,e});
	ll ans = 0;
	if (n%mintime==0){
		ans = n/mintime-1;
	}else{
		ans = n/mintime;
	}
	cout << ans+5 << endl;
//	printf("%.4f\n",ans);
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<"99 99\n";
	vector<vector<char>> res(99,vector<char>(99,'.'));
	int x=1,y=1;
	for(int i=0;i<a-1;++i){
		res[x-1][y-1]='#';
		res[x-1][y]='#';
		res[x-1][y+1]='#';
		res[x][y-1]='#';
		res[x][y+1]='#';
		res[x+1][y-1]='#';
		res[x+1][y]='#';
		res[x+1][y+1]='#';
		if(y+3>=99) y=1,x+=3;
		else y+=3;
	}
	for(int i=0;i<b-1;++i){
		res[x][y]='#';
		if(y+3>=99) y=1,x+=3;
		else y+=3;
	}
	if(a==1){
		res[x][y]='#';
	}
	for(int i=0;i<99;++i){
		for(int j=0;j<99;++j)
			cout<<res[i][j];
		cout<<'\n';
	}
}




Measured memory_bytes: 3568
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        //int N =sc.nextInt();
        ArrayList<Integer>  allmen =new ArrayList <Integer>();
        //HashSet doubled =new HashSet<Integer>();
        
        //Set<?> yourHashSet = new HashSet<>();
        //List<?> sortedList = new ArrayList<>(yourHashSet);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int counter =0;
        //HashSet doubled =new HashSet<Integer>();
        for(int i =0;i <N;i++){
            allmen.add(i, sc.nextInt());
        }
        Collections.sort(allmen);
        for(int i =0;i <K;i++){
            counter += allmen.get(i);
        }

        System.out.println(counter);


        //System.out.println(ans);
    }
}
    

/*         for(int i=0;i<N-1;i++){
            int target = sc.nextInt();
            if(target < blocker){
                blocker = target;
            }
            if(allmen.contains(target)==false){
                if(target%blocker!=0){
                    allmen.add(target);
                } 
            }
                else{
                    doubled.add(target);
                }       
            
        }
        Collections.sort(allmen);
         //画面表示
        for(int i=0;i <=allmen.size()-1;i++){
            boolean judge = true;
            int target = allmen.get(i);
            if(doubled.contains(target)==false){
                for(int X= 0;X<i;X++){
                    if(target% allmen.get(X)==0){
                        judge = false;
                        break;
                    }
                }
            }else{
                judge = false;
            }
            if(judge == true){
                ans++;
            }
        } */

    

Measured memory_bytes: 38980
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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 namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll r, D;
    vi x(11);
    cin >> r >> D >> x[0];
    repf(i, 10){
        x[i] = r*x[i-1]-D;
        cout << x[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

vector<char> check(vector<char> &S) {

    vector<char> res;

    rep(i,0,S.size()) {
        if (res.size()==0) {
            res.push_back(S[i]);
        }
        else {
            if (res.back()!=S[i]) {
                res.pop_back();
            }
            else {
                res.push_back(S[i]);
            }
        }
    }
    return res;
}

int main (){
    vector<char> S;
    string tmp;
    cin >> tmp;
    rep(i,0,tmp.size()) {
        S.push_back(tmp[i]);
    }
    int l = S.size();
    int now = S.size();
    while(S.size()>0) {
        S = check(S);
        if (now == S.size()) {
            break;
        }
        else {
            now = S.size();
        }
    }
    cout << l-S.size() << endl;
}



Measured memory_bytes: 768
import math
r =  6378.1
def getRadian(degree):
    return degree * math.pi / 180

while(1):
    a,b,c,d = (float(x) for x in input().split())
    if a == -1 and b == -1 and c == -1 and d == -1:
        break
    cos = math.cos(getRadian(a)) * math.cos(getRadian(c)) * math.cos(getRadian(b) - getRadian(d)) + math.sin(getRadian(a)) * math.sin(getRadian(c))
    dist = r * math.acos(cos)
    print(format(dist, '.0f'))


Measured memory_bytes: 5732
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int main() {
	long long int n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0;
		return 0;
	}
	long long int x = 0;
	 long  double sum=n/10;
	int i = 1;
	long long int div = 5;
	while (floor(sum)!=0) {
		
		
		x += floor(sum) ;
		 sum=sum/5 ;
	}
	cout << x;

}


Measured memory_bytes: 256
L=[int(i) for i in input().split()]
L.sort()
L[2]-=L[0]
L[1]-=L[0]
L[0]-=L[0]
M=L[2]-L[1]
L[0]+=M
L[1]+=M
if (L[1]-L[0])%2==0:
    N=(L[1]-L[0])//2
    print(M+N)
else:
    N=(L[1]-L[0])//2
    print(N+M+2)


Measured memory_bytes: 3316
N,M = map(int,input().split())
l = []
for i in range(N):
    A,B = map(int,input().split())
    l.append((A,B))
l.sort()
n = 0
ans = 0
for i in range(N):
    A,B = l[i]
    if n+B <= M:
        ans += A*B
        n += B
    else:
        ans += A*(M-n)
        n += M-n
    if n==M:
        break
print(ans)

Measured memory_bytes: 16892
#include <iostream>
#include <vector>
using namespace std;
//区間和を書いてます
struct segK{//非再帰
    int n;
    long long MIN;
    int size;
    vector<long long> dat;
    segK(int n_){
        n = 1;
        MIN = -1;
        size = n_;
        while(n < n_) n *= 2;
        dat.resize(2 * n);
        for(int i = 1; i < 2 * n; i++) dat[i] = MIN;
    }
    void update(int k, long long a){
        k += n;
        dat[k] = a;
        while(k > 0){
            k >>= 1;
            dat[k] = max(dat[k << 1 | 0], dat[k << 1 | 1]);
        }
    }
    long long query(int l, int r){
        long long res = 0;
        l += n;
        r += n;
        while(r > l){
            if(l & 1) res = max(res, dat[l++]);
            if(r & 1) res = max(res, dat[--r]);
            l >>= 1;
            r >>= 1;
        }
        return res;
    }
    int bin(int l, long long v) {
        l += n;
        long long zero = -1;
        do {
            while (l % 2 == 0) l >>= 1;
            if (dat[l] >= v) {
                while (l < n) {
                    l = (2 * l);
                    if (dat[l] < v) {
                        zero = max(zero, dat[l]);
                        l++;
                    }
                }
                return l - n;
            }
            zero = max(zero, dat[l]);
            l++;
        } while ((l & -l) != l);
        return size;
    }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    segK segtree(N);
    for(int i = 0; i < N; i++){
        long long a;
        cin >> a;
        segtree.update(i, a);
    }
    for(int i = 0; i < Q; i++){
        int t, x, v;
        cin >> t >> x >> v;
        x--;
        if(t == 1) segtree.update(x, v);
        else if(t == 2) {
            long long ans = segtree.query(x, v);
            cout << ans << endl;
        }
        else if(t == 3){
            int ans = segtree.bin(x, v);
            if(ans < x) cout << N + 1 << endl;
            else cout << ans + 1 << endl;
        }
    }
}

Measured memory_bytes: 7464
from heapq import *
N, M = map(int, input().split())
l = list(map(lambda x: -1 * int(x), input().split()))
heapify(l)
for _ in range(M):
    m = heappop(l)
    heappush(l, -1*(-1*m//2))
print(sum(map(lambda x: -1 * x, l)))


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

vector<vector<ll>> comb; //�ォ��i�i��,������j�Ԗڂ̓񍀌W��

void Combination(int n){
	comb = vector<vector<ll>>(n,vector<ll>(n,0));
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= i; j++){
			if(j == 0 || i == j){
				//�e�s�̗��[
				comb[i][j] = 1;
			}else{
				//����ȊO
				comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
			}
		}
	}
}

int main()
{
	ll n,a,b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	sort(all(v)); v.push_back(1e9);
	reverse(all(v));
	Combination(55);
	ll sum = 0,cnt = 1,flag = -1;
	for(int i = 1; i <= a; i++){
		if(v[i-1] != v[i]){
			flag++;
			cnt = 1;
		}else cnt++;
		sum += v[i];
	}
	cout << fixed << (double)sum/a << endl;
	ll ans = 0,num = count(all(v),v[a]);
	if(!flag){
		for(int i = a; i <= b; i++){
			ans += comb[num][i];
		}
	}else{
		ans = comb[num][cnt];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int min = 1000000;
		int max = -1000000;
		long sum = 0;
		for(int i = 0; i < n; i++){
			int in = sc.nextInt();
			sum += in;
			if(in < min) min = in;
			if(in > max) max = in;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}


Measured memory_bytes: 41352
#include <stdio.h>
#include <math.h>
 
int main(void){
    int i,n,s[1000];
    double h,sum;
     
    while(1){
 
        scanf("%d",&n);
        if(!n) break;
         
        sum = 0;
        h = 0;
         
        for(i=0;i<n;i++){
            scanf("%d",&s[i]);
            sum += s[i];
        }
     
        sum /= n;
     
         
        for(i=0;i<n;i++){
            h += pow(s[i]-sum, 2.0);
        }
             
        h /= n;
 
 
        printf("%lf\n",pow(h,1.0/2.0));
     
    }
     
    return 0;
}


Measured memory_bytes: 2032
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      
      int n = sc.nextInt();
      long sum = 0;

      for(int i=1; i<=n; i++){
        if(i%3==0)
          continue;
        else if(i%5==0)
          continue;
        else
          sum+=i;
      }
      System.out.println(sum);

      sc.close();
   }
}

Measured memory_bytes: 27208
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a = int(input())
b = int(input())
h = int(input())
print(int(((a+b)*h)/2))


Measured memory_bytes: 38896
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> list = new ArrayList<>();

        for (int i = 0; i < n; i++){
            list.add(sc.next());
        }
        if (list.contains("Y")){
            System.out.println("Four");
        } else {
            System.out.println("Three");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>

using namespace std;

using ll = long long;

int main(){
    int d,n;cin>>d>>n;
    ll ans=0;
    ans = pow(100,d) * n;
    if(n==100) ans += pow(100,d);
    cout<<ans<<endl;
}

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

using PII = pair<int, int>;
#define F first
#define S second
constexpr int maxn = 2e5 * 2 + 10;
int64_t k;
int n, a[maxn], f[maxn], g[maxn];

int main() {
  scanf("%d%lld", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    a[i + n] = a[i];
  }
  unordered_map<int, int> m;
  for (int i = n * 2; i >= 1; --i) {
    if (m.count(a[i])) {
      f[i] = m[a[i]] + 1;
    } else {
      f[i] = i;
    }
    m[a[i]] = i;
  }
  f[n * 2 + 1] = n * 2 + 1;
  for (int i = n * 2 + 1; i >= 1; --i) {
    g[i] = i == f[i] ? f[i] : g[f[i]];
  }
  int s = n + 1;
  m.clear();
  int cnt = 0;
  while (k-- > 0) {
    s = g[s] - n;
    cnt++;
    if (m.count(s)) {
      int len = cnt - m[s];
      k %= len;
    }
    m[s] = cnt;
  }
  unordered_set<int> vis;
  vector<int> st;
  for (int i = s; i <= n; ++i) {
    if (vis.count(a[i])) {
      while (st.back() != a[i]) {
        vis.erase(st.back());
        st.pop_back();
      }
      vis.erase(st.back());
      st.pop_back();
    } else{
      vis.insert(a[i]);
      st.push_back(a[i]);
    }
  }
  for (size_t i = 0; i < st.size(); ++i)
    printf("%d%c", st[i], " \n"[i + 1 == st.size()]);
  return 0;
}



Measured memory_bytes: 22216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();
      StringBuilder buf = new StringBuilder();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          buf.append(tree.getRoundPath());
        }
      }

      System.out.print(buf);

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode();
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode();
    z.key = val;

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  String getRoundPath() {
    buf.setLength(0);

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    return buf.toString();
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode() {
    this.key = -1;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 125700
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

ll dp[MAX];

int main()
{
 

//cout << setprecision(15) << fixed;
fast

	cin >> n;
	fr(i,0,n)
		cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	fr(i,2,n)
	{
		dp[i] = min(dp[i-2]+abs(a[i-2]-a[i]) ,dp[i-1]+abs(a[i-1]-a[i]) );
	}
	cout << dp[n-1];


 
  return 0;
 
}


Measured memory_bytes: 5120
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let a = iter.next().unwrap().parse::<i32>().unwrap();
    let s = iter.next().unwrap();

    let res = calc(a, s);
    println!("{}", res);
}

fn calc(a: i32, s: &str) -> &str {
    if a >= 3200 {
        return s;
    }
    "red"
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test1() {
        assert_eq!("pink", calc(3200, "pink"));
    }

    #[test]
    fn test2() {
        assert_eq!("red", calc(3199, "pink"));
    }

    #[test]
    fn test3() {
        assert_eq!("red", calc(4049, "red"));
    }

}


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


int main() {
  int H,W;cin >> H >> W;
  vector<string> pic(H);

  for (int i = 0;i < H;i++){
    cin >> pic.at(i);
  }

  vector<string> ans(H+2);
  for (int h = 0;h < H+2;h++){
    if (h == 0){
      string line = "#";
      for (int w = 0;w < W+1;w++){
        line+="#";
      }
      ans.at(h) = line;
    }else if (h == H+1){
      string line = "#";
      for (int w = 0;w < W+1;w++){
        line+="#";
      }
      ans.at(h) = line;
    }else{
      string line = "#";
      line+=pic.at(h-1)+"#";
      ans.at(h) = line;
    }
  }

  for (int h = 0;h < H+2;h++){
    cout << ans.at(h) << endl;
  }


}       

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (void)
{
 int A, B;
 cin >> A >> B;
 int xMin = A / 0.08, xMax = (A+1) / 0.08;
 if ((int) (xMin * 0.08) != A)
 	xMin++;
 if ((int) (xMax * 0.08) != A)
 	xMax--;
 for (int yen = xMin; yen <= xMax; yen++)
 {
	if ((int) (yen * 0.1) == B)
	{
		cout << yen << endl;
		return 0;
	}
 }
 cout << -1 << endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define pb push_back

vector<int> G[100005];

int dfs(int v) {
  vector<int> vec;
  Rep(i, G[v].size()) {
    vec.pb(dfs(G[v][i]) + 1);
  }
  sort(vec.begin(), vec.end());
  int ret = 0;
  Rep(i, vec.size()) {
    ret = max(ret, (int)(vec[i] + vec.size() - 1 - i));
  }

  return ret;
}

int main()
{
  int N, A;
  
  cin >> N;
  for(int i = 1; i < N; i++) {
    cin >> A; --A;
    G[A].pb(i);
  }

  cout << dfs(0) << endl;

  return 0;
}
    


Measured memory_bytes: 13568
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  int ld = 0;
  int rd = n;
  cout << 0 << endl;
  string cur;
  cin >> cur;
  if(cur == "Vacant")return 0;
  while(true){
    int md = (ld + rd) / 2;
    cout << md << endl;
    string s;
    cin >> s;
    if(s == "Vacant"){
      return 0;
    }
    if(ld % 2 == md % 2){
      if(s == cur){
        ld = md;
        cur = s;
      }else{
        rd = md;
      }
    }else{
      if(s == cur){
        rd = md;
      }else{
        ld = md;
        cur = s;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <vector>

using namespace std ;

int main(void) {

    char s[4], buf[4] ;
    cin >> s ;

    int cnt = 1, cnt2 = 0 ;
    for (int i = 1; i < 4; i++) {
        if (s[0] == s[i]) {
            cnt++ ;
        }
        else {
            buf[cnt2++] = s[i] ;
        }
    }

    if (cnt == 2) {
        for(int i = 1; i < cnt2; i++) {
            if (buf[0] == buf[i])
                cout << "Yes" << endl ;
            else
                cout << "No" << endl ;
        }
    }
    else {
        cout << "No" << endl ;
    }


    return 0 ;
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
const int maxn=200000,mod=1000000007;
ll fac[maxn+10],inv[maxn+10],invfac[maxn+10];
void prework(){
	fac[0]=inv[0]=invfac[0]=1;
	for(int i=1;i<=maxn;++i){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=i==1?1:(mod-mod/i*inv[mod%i]%mod)%mod;
		invfac[i]=invfac[i-1]*inv[i]%mod;
	}
}
ll c(ll a,ll b){return b>a?0:fac[a]*invfac[b]%mod*invfac[a-b]%mod;}
int n,p[maxn+10],f,s; ll ans[maxn+10];
int main(){
	prework();
	scanf("%d",&n);
	for(int i=1;i<=n+1;++i){
		int x; scanf("%d",&x);
		if(!p[x]) p[x]=i; else f=p[x],s=i;
	}
	for(int i=1;i<=n;++i) ans[i]=c(n,i);
	for(int i=0;i<=n-1;++i) (ans[i+2]+=c(n-1,i))%=mod;
	for(int i=0;i<=n-1;++i){
		(ans[i+1]+=c(n-1,i))%=mod;
		ans[i+1]-=c(n-s+f,i); ans[i+1]=(ans[i+1]+mod)%mod;
	}
	for(int i=1;i<=n+1;++i) printf("%lld\n",ans[i]); return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll n;
	cin >> n;
	cout << (n + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
 
int main() {
  int n,q;
  string s;
  cin >> n >> q >> s;
  vector<int> vec(n);
  vec.at(0)=0;
  for(int i=0;i<n-1;i++){
   
     if(s.at(i)=='A'&&s.at(i+1)=='C'){
      vec.at(i+1)=vec.at(i)+1;
    
    }
    else{
      vec.at(i+1)=vec.at(i);
    }
  }
  int l,r;
  for(int i=0;i<q;i++){
    cin >> l >> r;
    cout << vec.at(r-1)-vec.at(l-1) << endl;
  }
}


Measured memory_bytes: 1408
from collections import defaultdict


n = int(input())
al = list(map(int, input().split()))

hs = defaultdict(int)
cnt = 0

for i, height in enumerate(al):
    num = i + 1
    if i-height in hs:
        cnt += hs[i-height]
    hs[i+height] += 1
print(cnt)





Measured memory_bytes: 40612
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<pair<int, int> > S;
int main(){

    int m,n;
    while(cin>>m,m){
        int x[300],y[300];
        for(int i = 0;i < m;i++)cin>>x[i]>>y[i];
        cin>>n;
        int X[1100],Y[1100];
        for(int i = 0;i < n;i++)cin>>X[i]>>Y[i],S.insert(make_pair(X[i],Y[i]));

        for(int i = 0;i < n;i++){
            int dx = X[i] - x[0];
            int dy = Y[i] - y[0];
            bool flg = true;
            for(int j = 0;j < m;j++){
                int nx = x[j] + dx;
                int ny = y[j] + dy;
                if(nx < 0 || 1000000 < nx || ny < 0 || 1000000 < ny){
                    flg = false;
                    break;
                }
                set<pair<int, int> >::iterator it = S.find(make_pair(nx,ny));
                if(it == S.end()){
                    flg = false;
                    break;
                }
            }
            if(flg){
                cout<<dx<<" "<<dy<<endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1352
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int sum=0;
		int[] s = new int[n+1];
		for(i=1;i<=n;i++) {
			s[i] = parseInt(sc.next());
			sum+=s[i];
		}
		sc.close();
		Arrays.parallelSort(s);
		int tmp=0;
		int ans=0;
		for(i=0;i<=n;i++) {
			tmp = sum-s[i];
			if(tmp%10!=0) {
				ans=tmp;
				break;
			}
		}
		out.println(ans);
	}
}


Measured memory_bytes: 23764
n,y = list(map(int,input().split()))

a = y//10000+1
for i in range(a):
  for j in range(n-i+1):
    k = n-i-j
    if k*1000+j*5000+i*10000==y and k>=0:
      print(i,j,k)
      exit()  
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#define INF 1000000000
#define MOD 1000000007

using namespace std;

int main()
{
    long long n;
    long long a, b;

    cin >> n;
    cin >> a >> b;

    if (a > b) {
        cout << 0 << endl;
    } else if (a == b && n == 1) {
        cout << 1 << endl;
    } else if (a != b && n == 1) {
        cout << 0 << endl;
    } else {
        cout << (b - a) * (n - 2) + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int n,d; cin>>n>>d;
    Int ans=0;
    for(int i=0; i<n; i++){
        Int x,y; cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define fix(n) fixed << setprecision(n)

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    
    map<string,string> ret;
    ret["Sunny"] = "Cloudy";
    ret["Cloudy"] = "Rainy";
    ret["Rainy"] = "Sunny";

    string s;
    cin >> s;
    cout << ret[s] << endl;
}

Measured memory_bytes: 3084
#include <stdio.h>

#define swap( x, y ) do { double tmp; tmp = x; x = y; y = tmp; } while ( 0 )

int rel_s_s( double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double *x, double *y ) {
	double a, b, c, d;
	int rel;

	if ( x1 < x0 ) {
		swap( x0, x1 );
		swap( y0, y1 );
	}
	if ( x3 < x2 ) {
		swap( x2, x3 );
		swap( y2, y3 );
	}

	if ( x0 != x1 ) {
		a = ( y0 - y1 ) / ( x0 - x1 );
		b = ( x0 * y1 - x1 * y0 ) / ( x0 - x1 );
	}
	if ( x2 != x3 ) {
		c = ( y2 - y3 ) / ( x2 - x3 );
		d = ( x2 * y3 - x3 * y2 ) / ( x2 - x3 );
	}

	rel = 1;
	if ( x0 == x1 ) {
		*x = x0;
		if ( x2 == x3 )
			if ( x0 == x2 ) {
				if ( y1 < y0 )
					swap( y0, y1 );
				if ( y3 < y2 )
					swap( y2, y3 );

				if ( y3 < y0 || y1 < y2 )
					rel = 3;
				else if ( y3 == y0 || y1 == y2 ) {
					*y = y3 == y0 ? y0 : y1;
					rel = 4;
				} else
					rel = 5;
			} else
				rel = 2;
		else {
			*y = c * *x + d;
			if ( *x < x2 || x3 < *x || *y < ( y0 < y1 ? y0 : y1 ) || ( y0 < y1 ? y1 : y0 ) < *y )
				rel = 0;
		}
	} else {
		if ( x2 == x3 ) {
			*x = x2;
			if ( *x < x0 || x1 < *x || *y < ( y2 < y3 ? y2 : y3 ) || ( y2 < y3 ? y3 : y2 ) < *y )
				rel = 0;
		} else
			if ( a == c )
				if ( b == d )
					if ( x3 < x0 || x1 < x2 )
						rel = 3;
					else if ( x3 == x0 || x1 == x2 ) {
						*x = x3 == x0 ? x0 : x1;
						rel = 4;
					} else
						rel = 5;
				else
					rel = 2;
			else {
				*x = ( -b + d ) / ( a - c );
				if ( *x < x0 || x1 < *x || *x < x2 || x3 < *x )
					rel = 0;
			}
		*y = a * *x + b;
	}

	return rel;
}

int main( void ) {
	int q;

	scanf( "%d", &q );
	while ( q-- ) {
		int rel;
		double x0, y0, x1, y1, x2, y2, x3, y3, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3 );

		rel_s_s( x0, y0, x1, y1, x2, y2, x3, y3, &x, &y );

		printf( "%.8f %.8f\n", x, y );
	}

	return 0;
}

Measured memory_bytes: 668
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
 
struct asumisu {
	int X, L;
};
 
int tomatu(const void* x, const void* y) {
	struct asumisu a = *(const struct asumisu*)x, b = *(const struct asumisu*)y;
	int aa = a.X + a.L, bb = b.X + b.L;
	return aa < bb ? -1 : aa > bb;
}
 
int N;
struct asumisu kugyu[114514];
 
int main(void) {
	int i;
	int sumipe = INT_MIN;
	int kitaeri = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &kugyu[i].X, &kugyu[i].L) != 2) return 1;
	}
	qsort(kugyu, N, sizeof(*kugyu), tomatu);
	for (i = 0; i < N; i++) {
		int hidari = kugyu[i].X - kugyu[i].L, migi = kugyu[i].X + kugyu[i].L;
		if (sumipe <= hidari) {
			kitaeri++;
			sumipe = migi;
		}
	}
	printf("%d\n", kitaeri);
	return 0;
}

Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define pb push_back
#define mt make_tuple
#define all(a) (a).begin(),(a).end()
#define frep(i,a,n) for(int i=(a);i<(n);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define rrep(i, n) for(int i=n-1;i>=0;--i)
#define debug(x) cout << #x << " : " << x << " ------------ " << endl;
using namespace std;
int main()
{
    int MAX = 200000;
    bool tmp[MAX];
    fill(tmp, tmp + MAX, true);
    tmp[0] = false;
    tmp[1] = false;
    for (int i = 4; i < MAX; i += 2) {
        tmp[i] = false;
    }
    for (int i = 3; i < MAX; i += 2) {
        if (!tmp[i]) continue;
        for (int j = 2; i * j < MAX; ++j) {
            tmp[i*j] = false;
        }
    }
    vector<int> prime{2};
    for (int i = 3; i < MAX; i += 2) {
        if (tmp[i]) prime.pb(i);
    }
    
    int n, p;
    while (cin >> n >> p, n != -1 && p != -1) {
        vector<int> sums;
        auto it = upper_bound(all(prime), n);
        rep (i, p) {
            frep (j, i, p) {
                sums.pb(*(it+i) + *(it+j));
            }
        }
        sort(all(sums));
        cout << sums[p-1] << endl;
    }
    return EXIT_SUCCESS;
}

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

#define INF (1e9)
#define INF_LL (1e17)
#define YJ 1145141919810

using LL = long long;
using ULL = unsigned long long;

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  cout << (A+B)%24 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long INT;  
int main(){
	INT a;
	cin >> a;
	cout << (a+1)*a/2 + 15 * ((a/15)*(a/15+1)/2)- 3* ((a/3)*(a/3+1)/2)-5 * ((a/5)*(a/5+1)/2);
	
}

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



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

    int ans=0;
    if(A>=13){
        ans=B;
    }else if(A>=6){
        ans=B/2;
    }else {
        ans=0;
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
/****************************************

			LostMartian

****************************************/
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma") 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	pn(args...); 
}
template <typename Arg1>
void ps(Arg1&& arg1) { 
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	ps(args...); 
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1; 
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { 
	cin >> arg1; 
	read(args...); 
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define umap unordered_map<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define test ll t; cin>>t; while(t--)
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define iAmSpeed ios_base::sync_with_stdio(false); cin.tie(NULL);
void LOCAL();
int main()
{
	clock_t z = clock();
	//LOCAL();
	iAmSpeed
	ll n;
	cin>>n;
	ll a[n];
	rep(i,0,n) {
		cin>>a[i];
	}
	ll sum=0;
	rep(i,1,n) {
		if(a[i]<a[i-1]) {
			sum+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<sum<<"\n";















	debug("Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}
void LOCAL() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}


Measured memory_bytes: 5336
import math
from functools import reduce
k=int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
ans=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans+=gcd(a,b,c)
print(ans)

Measured memory_bytes: 74984