akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
void swap(int a[],int i,int j){
	int t=a[i];
	a[i]=a[j];
	a[j]=t;
}

void q_sort(int a[],int left,int right){
	int i=left,j=right,pivot=a[(left+right)/2];
	while(1){
		while(a[i]<pivot) i++;
		while(a[j]>pivot) j--;
		if(i>=j) break;
		swap(a,i,j);
		i++;
		j--;
	}
	if(left<i-1) q_sort(a,left,i-1);
	if(j+1<right) q_sort(a,j+1,right);
}

int main(void){
	int N,M,i,check,t,sum=0;
	scanf("%d %d",&N,&M);
	int X[M],diff[M-1];
	for(i=0;i<M;i++) scanf("%d",&X[i]);
	
	if(N>=M){
		printf("0");
		return 0;
	}
	
	//Xをソート
	q_sort(X,0,M-1);
	
	//for(i=0;i<M;i++) printf("%d,",X[i]);
	//printf("\n");
	
	//差を計算
	for(i=0;i<M-1;i++) diff[i]=X[i+1]-X[i];
	
	//for(i=0;i<M-1;i++) printf("%d,",diff[i]);
	//printf("\n");
	
	//差をソート
	q_sort(diff,0,M-2);
	
	//for(i=0;i<M-1;i++) printf("%d,",diff[i]);
	//printf("\n");
	
	for(i=0;i<N-1;i++) sum+=diff[M-2-i];
	
	printf("%d",X[M-1]-X[0]-sum);
}

Measured memory_bytes: 896
#include "bits/stdc++.h"

using namespace std;

void solve()
{
    long n, a, b;
    cin >> n >> a >> b;
    vector<long> hs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> hs[i];
    }
    long c = a - b;
    long ng = 0, ok = 1e9;
    while (ng + 1 < ok)
    {
        long m = (ok + ng) >> 1;
        vector<long> rs;
        long k = 0;
        for (int i = 0; i < n; i++)
        {
            long h = hs[i] - b * m;
            k += max(0L, (h + c - 1) / c);
        }
        (k <= m ? ok : ng) = m;
    }
    cout << ok << endl;
}

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


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

using namespace std;

typedef long long ll;

const ll MOD = 998244353;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    ll pot = 2;
    vector< vector<ll> > dp(n, vector<ll>(s + 1, 0));
    if (a[0] <= s)
        dp[0][a[0]] = 1;
    for (int i = 1; i < n; ++i)
    {
        for (int j = 1; j <= s; ++j)
        {
            dp[i][j] = (dp[i][j] + dp[i - 1][j] * 2) % MOD;
            if (j - a[i] > 0)
                dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % MOD;
            if (j == a[i])
                dp[i][j] = (dp[i][j] + pot) % MOD;
        }
        pot = (pot * 2) % MOD;
    }
    cout << dp[n - 1][s];
    return 0;
}


Measured memory_bytes: 73684
n = int(input())
H = list(map(int, input().split()))

piv = 1
pre_ans = 0
pre_h = H[0]
ans = 0
while piv < n:
  if H[piv] <= pre_h:
    pre_h = H[piv]
    piv += 1
    pre_ans += 1
  else:
    ans = max(ans, pre_ans)
    pre_h = H[piv]
    piv += 1
    pre_ans = 0
  #print(pre_ans)
ans = max(ans, pre_ans)
print(ans)

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 1; i < n-1; i++){
    if((a[i-1]<a[i] && a[i] < a[i+1]) || (a[i-1] > a[i] && a[i] > a[i+1])){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int n = readint;

    bool[int] m;
    for (int i = 0; i < n; i++) {
        int x = readint;
        if (x in m) {
            m[x] = !m[x];
        }
        else {
            m[x] = true;
        }
    }

    int ans = 0;
    foreach (k, v; m) {
        if (v)
            ans++;
    }
    writeln(ans);
}


Measured memory_bytes: 7932
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const int MAX_N = 100010;

int group1[7] = { 1,3,5,7,8,10,12 };
int group2[4] = { 4,6,9,11 };

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int cnt = 0;
	int ans = 0;
	rep(i, n) {
		if (s[i] == 'I')cnt++;
		else cnt--;
		chmax(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// AISing.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>

using namespace std;

using ll = long long;

int main()
{
    int l, r, d;
    cin >> l >> r >> d;

    int cnt = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0)cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3620
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: &Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<usize>();
    let mut A = 0;
    let mut B = 0;
    let mut a = Vec::new();
    for n in 0..N {
        let tmp = read::<i32>();
        a.push(tmp);
    }
    a.sort();
    a.reverse();
    let mut alice = 0;
    let mut bob = 0;
    for n in 0..N {
        if n%2 == 0 {
            alice += a[n];
        } else {
            bob += a[n];
        }
    }
    println!("{}", alice - bob);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h, w;
    const ll M = 1e9+7;
    cin >> h >> w;
    V<V<char>> a(h, V<char>(w));
    rep(i,0,h) rep(j,0,w) cin >> a[i][j];
    V<V<ll>> dp(h, V<ll>(w, 0));
    dp[0][0] = 1;
    rep(i,1,h) dp[i][0] = a[i][0] == '.' ? dp[i-1][0] : 0;
    rep(j,1,w) dp[0][j] = a[0][j] == '.' ? dp[0][j-1] : 0;
    rep(i,1,h) rep(j,1,w) {
        if (a[i][j] == '.') dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % M;
    }
    cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 9088
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int cnt = 0;

vector<vector<int>> g;

void bfs(int u, int v, int n) {
  vector<bool> is_visited(n, false);
  queue<int> q;
  q.push(0);
  is_visited[0] = true;

  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int i = 0; i < (int)g[cur].size(); i++) {
      int nxt = g[cur][i];
      if (is_visited[nxt]) {
        continue;
      }
      if (cur == u && nxt == v) {
        continue;
      }
      if (nxt == u && cur == v) {
        continue;
      }
      is_visited[nxt] = true;
      q.push(nxt);
    }
  }

  for (int i = 0; i < n; i++) {
    if (!is_visited[i]) {
      cnt++;
      break;
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  g.assign(n, vector<int>());

  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  for (int i = 0; i < m; i++) {
    bfs(a[i], b[i], n);
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int mae[1024][100001], V[262144], W[262144];

int dp(int i, int w){
  if(w==0){ return 0; }
  if(i<1024){ return mae[i][w]; }
  int ans=dp(i/2, w);
  if(W[i]<=w){ ans=max(ans, dp(i/2, w-W[i])+V[i]); }
  return ans;
}

int main(){
int N, Q; cin >> N;
REP(i, N){ cin >> V[i+1] >> W[i+1]; }
for(int i=1; i<1024; i++){ REP(j, 100001){
  if(W[i]<=j){ mae[i][j]=max(mae[i/2][j-W[i]]+V[i], mae[i/2][j]); }
  else{ mae[i][j]=mae[i/2][j]; } 
} }
cin >> Q; int v, L;
REP(i, Q){ cin >> v >> L; cout << dp(v, L) << "\n"; }
}

Measured memory_bytes: 405256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll oo = 1e18;
const ll mod = 1e9 + 7,maxn = 100000000;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s, ans;
    int n;
    cin >> s;
    n = s.size();
    ans.append(n, 'x');

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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


signed main(){
	
	ll n,k,memo = 0;
	cin >> n >> k;
	
	memo = (n+1)/2;
	
	if(memo < k) cout << "NO" << endl;
	else cout << "YES" << endl;
	
	
	return 0;

}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, H = MAP()
    A, B = [0] * N, [0] * N
    for i in range(N):
        A[i], B[i] = MAP()

    MAX_A = max(A)
    B.sort(reverse=True)

    ans = 0
    for i in range(N):
        if MAX_A >= B[i]:
            ans += -(-H // MAX_A)
            print(ans)
            break
        else:
            H -= B[i]
            ans += 1

        if H <= 0:
            print(ans)
            break
    else:
        ans += -(-H // MAX_A)
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17892
inputABT = input().split()
a = float(inputABT[0])
b = inputABT[1]
t = float(inputABT[2])

end =  t + 0.5
n = 1
bisket = 0

while n * int(a) < end:
    n = n + 1

    bisket = bisket + int(b)


print(bisket)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }


int main()
{
    li n,a,ans=0;
    cin>>n;
    map<li,li> x;
    rep(i,n) {
        cin>>a;
        if(x[a]%2) ans--;
        else ans++;
        x[a]++;
    }
    cout<<ans<<endl;

    return 0;
}


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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int k;
    long[] d;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    String solve() throws IOException{
        LinkedList<Character> res = new LinkedList<>();
        String s = sc.next();
        for(char c:s.toCharArray()) res.addLast(c);
        int q = sc.nextInt();
        int normalOrder = 1;
        while(q-->0){
            int t = sc.nextInt();
            if(t==1){
                normalOrder ^= 1;
            } else{
                int f = sc.nextInt()-1;
                char c = sc.next().charAt(0);
                if((f^normalOrder)==1){
                    res.addFirst(c);
                } else{
                    res.addLast(c);
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        while(res.size()>0){
            if(normalOrder==1) sb.append(res.pollFirst());
            else sb.append(res.pollLast());
        }
        return sb.toString();
    }
}



Measured memory_bytes: 165476
/* MaTb3aa */
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n,bag;
const int N = 100005;
ll dp[105][100005];
int W[N], C[N];
ll solve(int i,int rem) {
	if (i == n)return 0;
	ll& ret = dp[i][rem];
	if (~ret)return ret;
	ret = max(ret, solve(i + 1, rem));
	if(rem>=W[i])ret = max(ret, solve(i + 1, rem - W[i]) + C[i]);
	return ret;
}
int main() {
	cin >> n>>bag;
	for (int i = 0; i < n; i++)cin >> W[i] >> C[i];
	memset(dp, -1, sizeof dp);
	cout << solve(0, bag);	 
}

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


N, = readints()
H = readints()

dp = [100000*10000+1]*N

dp[0] = 0

for i in range(0, N):
    if i+1 < N:
        dp[i+1] = min(dp[i+1], dp[i] + abs(H[i]-H[i+1]))
    if i+2 < N:
        dp[i+2] = min(dp[i+2], dp[i] + abs(H[i]-H[i+2]))

print(dp[N-1])


Measured memory_bytes: 13976
import java.util.*;

public class Main {

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

		while(sc.hasNext()){
			int n = sc.nextInt();
			int max = sc.nextInt();
			int[] a = new int[n];
			int[] b = new int[n];
			
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
			}
			
			int now = max;
			boolean out = true;
			for(int i=0;i<n;i++){
				now = now + a[i] - b[i];
				if(now<0){
					out = false;
					break;
				}
				if(max<now)max=now;
			}
			if(out==true){
				System.out.println(max);
			}else{
				System.out.println("0");
			}
		}
	}
}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if(a + b >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21588
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN 10

int maxx, maxy, k;
int a[MAXN][MAXN];
int b[MAXN][MAXN];

int main() {
	cin >> maxx >> maxy >> k;
	for (int i = 0; i < maxx; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < maxy; j++) {
			if (s[j] == '#') {
				a[i][j] = 1;
			}
		}
	}
	int ret = 0;
	for (int maskx = 0; maskx < (1 << maxx); maskx++) {
		for (int masky = 0; masky < (1 << maxy); masky++) {
			memset(b, 0, sizeof(b));
			for (int i = 0; i < maxx; i++) {
				if (maskx & (1 << i)) {
					for (int j = 0; j < maxy; j++) {
						b[i][j] = 1;	
					}
				}
			}
			for (int j = 0; j < maxy; j++) {
				if (masky & (1 << j)) {
					for (int i = 0; i < maxx; i++) {
						b[i][j] = 1;
					}
				}
			}
			int cnt = 0;
			for (int i = 0; i < maxx; i++) {
				for (int j = 0; j < maxy; j++) {
					if (a[i][j] && !b[i][j]) {
						cnt++;
					}
				}
			}
			if (cnt == k) {
				ret++;
			}
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin>>A.at(i);
  }
  double reverseSUM = 0;
  for(int i=0;i<n;i++){
    reverseSUM+=(double)1/A.at(i);
  }
  printf("%.10f\n",1/reverseSUM);
  return 0;
}

Measured memory_bytes: 256
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms

#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define PI acos(-1)

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	
	double extra = (m/60.0)*30;
	if( m == 0 )
		m = 60;
	if( h == 0 )
		h = 12;
	double angle = abs(30*h + extra - 6*m);
	double tem = 2*a*b*cos( angle*PI/180.0 );
	double ans = sqrt( a*a + b*b - tem);
	
	cout << fixed << setprecision(10) << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4228
import sys
input = sys.stdin.readline

from functools import lru_cache

@lru_cache()
def F(N):
    if N < 10:
        return N
    q,r = divmod(N,10)
    x1 = F(q) + r
    x2 = F(q-1) + 9
    return max(x1,x2)

answer = F(int(input()))
print(answer)

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<vector>
using namespace std;


int main()
{
    int n;
    cin >> n;
    double hairetu[n] = {0};
    double sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> hairetu[i];
        sum += (1 / hairetu[i]);
    }

    cout << (1 / sum) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>
#define ll long long 

using namespace std;

int main() {
  int N, T, A;
  cin >> N;
  ll X = 1, Y = 1;
  ll n;
  for(int i=0;i<N;i++){
    cin >> T >> A;
    n = max((X+T-1)/T,(Y+A-1)/A);
    X = n*T;
    Y = n*A;
  }
  cout << X + Y << endl;
  return 0;
}




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

int main(){
    int a;
    int b;
    int total;
    int num = 0;
    cin >> a >> b;
    total = 1;
    while(total<b){
        total = total - 1 + a;
        num++;
    }
    cout << num << endl;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<pair<string,int>> v(n);
    map<pair<string,int>,int> mp;
    rep(i,n){
      cin >> v[i].first >> v[i].second;
      v[i].second = -v[i].second;
      mp[v[i]] = i+1;
    }
    sort(all(v));
    rep(i,n){
      cout << mp[v[i]] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  bitset<32> x(in());
  bitset<32> y(in());
  cout << (x&y) << endl;
  cout << (x|y) << endl;
  cout << (x^y) << endl;
}



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

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)a[i]=i;
  vector<vector<int>>g(n,vector<int>(n,-1));
  
  rep(i,n-1){
    for(int j=i+1; j<n; ++j){
      int x;
      rep(k,30)if((i>>k)^(j>>k))x=k;
      cout<<x+1<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 4340
from itertools import combinations
from collections import Counter

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

if N == 1:
    print(1)
    quit()

X.sort()
diff = []
for i, j in combinations(range(N), 2):
    diff.append((X[i][0] - X[j][0], X[i][1] - X[j][1]))
print(N - Counter(diff).most_common()[0][1])




Measured memory_bytes: 39152
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef pair<int, int> P;

void rot90(int& x, int& y) {
    int tmp = x;
    x = -y;
    y = tmp;
}

int main() {
    for(int N; cin >> N, N; ) {
        vector<P> points;
        for(int i = 0; i < N; i++) {
            int x, y; cin >> x >> y;
            points.push_back(P(x, y));
        }
        sort(points.begin(), points.end());
        
        int maxSize = 0;
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                int ax = points[i].first, ay = points[i].second;
                int bx = points[j].first, by = points[j].second;
                int dx = bx - ax;
                int dy = by - ay;

                rot90(dx, dy);
                if(binary_search(points.begin(), points.end(), P(ax+dx,ay+dy)) &&
                        binary_search(points.begin(), points.end(), P(bx+dx, by+dy)))
                    maxSize = max(maxSize, dx*dx+dy*dy);

                dx *= -1, dy *= -1;
                if(binary_search(points.begin(), points.end(), P(ax+dx,ay+dy)) &&
                        binary_search(points.begin(), points.end(), P(bx+dx, by+dy)))
                    maxSize = max(maxSize, dx*dx+dy*dy);

            }
        }

        cout << maxSize << endl;
    }
}

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

signed main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int ans = 1;
  string abc = "abcdefghijklmnopqrstuvwxyz";
  for( int i = 0; i < abc.size(); i++ ){
    int cnt = 0;
    for( int j = 0; j < N; j++ ){
      if( S.at(j) == abc.at(i) ) cnt++;
    }
    ans *= (cnt+1);
    ans = ans % 1000000007;
  }
  cout << ans - 1 << endl;
  
}


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

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

ll N;

int main(){
    cin >> N;
    deque<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vector<ll> B;
    B.push_back(1);
    for(int i=1;i<N;i++){
        if(i % 2 == 1){
            if(i < N-1) B.push_back(-2);
            else B.push_back(-1);
        }else{
            if(i < N-1) B.push_back(2);
            else B.push_back(1);
        }
    }
    sort(B.begin(),B.end());
    ll f = 0;
    for(int i=0;i<N;i++) f += A[i] * B[i];
    ll b = 0;
    for(int i=0;i<N;i++) b += -1 * A[i] * B[N-1-i];
    cout << max(f,b) << endl;
    return 0;
}

Measured memory_bytes: 5152
#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 10000
#include<math.h>
int N,K,m=0;

void cal(int n,int k){
	
	if(n >= k){
		m++;
		int i=(n-n%k)/k;
		cal(i,k);
	}
}

int main(void){
	scanf(" %d",&N);
	scanf(" %d",&K);
	
		cal(N,K);
	printf(" %d",m+1);
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
using namespace std;
int	main(){
	int n;
	cin>>n;
	for(int	i=0;i<n;i++){
	int a,b,c;
		cin>>a>>b>>c;
		if(a>c){
			swap(a,c);
		}
		if(b>c){
		  swap(b,c);
		}
		if(a*a+b*b==c*c)
			cout<<"YES"<<endl;

		else
			cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define endl "\n"
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define ll long long
#define llu unsigned long long
#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
#define ABS(X) ((X)< 0 ? -(X): (X))
#define LCM(X, Y)  ( ( (X) / (GCD( (X)  , (Y) ))) * (Y) )
#define MEM( A,  B) memset((A), (B), sizeof(A))
#define MEM_VEC(V, FILL ) fill( V.begin(), V.end(), FILL)
#define FOR_EACH(IT, V) for (auto IT = V.begin(); IT != V.end(); IT++)
#define DEBUG_ARRAY_PRINT(A,I) cout<<"at pos "<< I <<"  value is: "<< A[I]
#define TURBO ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0)
const double EPS =1e-9 ;
const double PI = 3.1415926535897932384626433832795 ;
using namespace std ;
inline ll GCD(ll A, ll B){
      if ( B == 0 ) return A;
      return GCD( (B) ,  (A % B) );
}
inline ll POW(ll BASE, ll EXP) {
   ll RES = 1;
   for(ll I= 0; I < EXP; I++) RES *= BASE ;
   return RES;
}

inline ll BIGMOD  ( ll a, ll p, ll m ) {
   ll res = 1 % m;
   ll x = a % m;
   while ( p > 0 ) {
       if ( (p & 1) > 0 ) res = ( res * x ) % m;
       x = ( x * x ) % m; p >>= 1;
   }
   return res;
}
inline void FILE_HANDLE( ){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}

int main()
{
            TURBO;
            //FILE_HANDLE() ;
            string str ;
            cin >> str ;
            for(int i = 0 ; i < str.size() ; i++) cout <<"x";

}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int MAXN=3e3+10;
double pos[MAXN];
double dp[MAXN][MAXN];
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>pos[i];
	}
	dp[0][0]=1.0;
	for(int i=0;i<=n;++i){
		for(int j=0;i+j<=n;++j){
			if(i) dp[i][j]+=dp[i-1][j]*pos[i+j];
			if(j) dp[i][j]+=dp[i][j-1]*(1.0-pos[i+j]);
		}
	}
	double ans=0;
	for(int i=n;i>(n>>1);--i){
		ans+=dp[i][n-i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

// v を縦方向にカットしていった時の最小のカットの回数
// ただし，全部の切れ目でカットしても条件を満たさない場合は -1 を返す
int solve(const vector<vector<int>>& v, const int& h, const int& w, const int& k) {
  vector<int> r(v.size(), 0);
  int ans = 0;
  for (int j = 0; j < w ; j++) {
    bool cut = false;  
    rep(i, v.size()) {
      if (v[i][j] > k) return -1;
      r[i] += v[i][j];
      if (r[i] > k) {
        cut = true;
        break;
      }
    }
    if (cut) {
      ans++;
      rep(i, v.size()) {
        r[i] = v[i][j];
      }
    }
  }
  return ans;
}

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

  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  int ans = INF;

  for (int bit = 0; bit < (1 << (h-1)); bit++) {
    bitset<32> bs(bit);
    vector<vector<int>> v(bs.count() + 1, vector<int>(w, 0));
    int idx = 0;
    for (int i = 0; i < h; i++) {
      rep(j, w) if (s[i][j] == '1') v[idx][j]++;
      if ((bit >> i) & 1) idx++;
    }

    // ここまでOK
    int ret = solve(v, h, w, k);
    if (ret != -1) chmin(ans, ret + int(bs.count()));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}
ll d[3][100001];
ll a[3][100001];
ll solve(ll type,ll i,ll n){
    if(i>=n){
        return -1;
    }
    if(type>=3){
        return -1;
    }
    if(d[type][i]!=0){
        return d[type][i];
    }
    if(i==n-1){
        d[type][i]=a[type][i];
        return d[type][i];
    }
    ll s1=solve((type+1)%3,i+1,n);
    ll s2=solve((type+2)%3,i+1,n);

      d[type][i]=max(s2,s1)+a[type][i];
      return d[type][i];
}
int main(){
   ll n;
   cin>>n;
   for(int i=0;i<n;i++){
    ll as,bs,cs;
    cin>>as>>bs>>cs;
    a[0][i]=as;
    a[1][i]=bs;
    a[2][i]=cs;
   }
   ll answer1=solve(0,0,n);
   ll answer2=solve(1,0,n);
   ll answer3=solve(2,0,n);
   cout<<max(answer1,max(answer2,answer3))<<endl;
}


Measured memory_bytes: 92212
#include<iostream>

int main(){
	int w,n,data[31];
	std::cin>>w>>n;
	for(int i=1;i<=w;i++)data[i]=i;
	for(int i=0;i<n;i++){
		int a,b,d;
		char c;
		std::cin>>a>>c>>b;
		d=data[a];
		data[a]=data[b];
		data[b]=d;
	}
	for(int i=1;i<=w;i++)std::cout<<data[i]<<std::endl;	
	return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        ArrayList<Integer> scores = new ArrayList<>();
        int n = in.nextInt();
        for (int i = 0; i < n; i++){
            scores.add(in.nextInt());
        }
        scores.sort(Comparator.naturalOrder());
        System.out.println(scores.get(n / 2) - scores.get(n / 2 - 1));
    }
}


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

using namespace std;

int n=0;
int p=0;
int have[55] = {};
int winner=0;
int judge=0;

int main()
{
    while(1){
        scanf("%d %d",&n,&p);
        if(n==0 && p == 0){
            break;
        }
        int pebble = p;
        for(int j=0;j<n;j++){
            have[j]=0;
        }
        while(1){
            for(int j=0;j<n;j++){
                if(pebble != 0){
                    have[j]++;
                    pebble--;
                    if(have[j] == p){
                        winner = j;
                        judge = 1;
                        break;
                    }
                }else{
                    pebble += have[j];
                    have[j] = 0;
                }
            }
            if(judge == 1){
                cout << winner << endl;
                judge = 0;
                break;
            }
        } 
    }

    return 0;
}


Measured memory_bytes: 3044
/*input
5
0.42 0.01 0.42 0.99 0.42
*/
#include<bits/stdc++.h>
#define append emplace_back
#define endl "\n"
#define N 1000000
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#pragma GCC optimize("O2")
typedef long long int ll;
using namespace std;
const ll M = 1e9+7;

int main()
{
	IOS;
	int n;
	cin>>n;
	vector<double>arr(n,0.0);
	for(int i=0;i<n;i++)
		cin >>arr[i];
	vector<vector<double>>dp(n+1,vector<double>(n+1,0.0));
	dp[1][1] = arr[0];
	dp[1][0] = 1.0 - arr[0];
	cout << setprecision(20);
	for(int i=2;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j==0)
				dp[i][j]=(1.0-arr[i-1])* dp[i-1][0];
			dp[i][j] = arr[i-1]*dp[i-1][j-1] + (1.0-arr[i-1])*dp[i-1][j];
		}
	}
	double sum = 0.0;
	for(int j=n;j>n/2;j--)
		sum += dp[n][j];	
	cout << sum<<endl;
	return 0;
}


Measured memory_bytes: 70784
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] a=new int[n+1];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        int[] b=new int[n];
        for (int i = 0; i < n; i++) {
            b[i]=sc.nextInt();
        }
        int[] c=new int[n+1];
        for (int i = 0; i < n; i++) {
            c[i]=sc.nextInt();
        }
        a[n]=1000000001;
        c[n]=1000000001;
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        long ans=0,ai=0,ci=0;
        for (int i = 0; i < n; i++) {
            while(b[i]>a[(int)ai]){
                ai++;
            }
            while(b[i]>=c[(int)ci]){
                ci++;
            }
            ans+=ai*(n-ci);
        }
        out.println(ans);
    }
}

Measured memory_bytes: 92656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
// #define space printf(" ")
#define endl printf("\n")
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{
		return;
	}
	void assign_value_(int val)
	{
		return;
	}
	void merge_nodes_(ST_Node& left, ST_Node& right)
	{
		return;
	}
};

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;

ll a[4];

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	ll n, ans = 0LL;
	int i;
	fo(i,0,4)
		cin >> a[i];
	cin >> n;
	fo(i,1,4)
		if(a[i] > a[i-1]+a[i-1])
			a[i] = a[i-1]+a[i-1];
	ans = (n/2)*a[3];
	n %= 2LL;
	ans += (n*a[2]);
	cout << ans;
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<bool> ans(n);
  bool first[] = { true, false };
  bool second[] = { true, false };
  for(int x = 0; x < 2; x++){
    for(int y = 0; y < 2; y++){
      ans[0] = first[x];
      ans[1] = second[y];
      for(int i = 2; i < n; i++){
        if(ans[i-1]){ // 隣が正直
          if(s[i-1] == 'o'){ // 両隣同じ
            ans[i] = ans[i-2];
          }else{
            ans[i] = !ans[i-2];
          }
        }else{
          if(s[i-1] == 'o'){
            ans[i] = !ans[i-2];
          }else{
            ans[i] = ans[i-2];
          }
        }
      }

      bool ok = true;

      for(int i = 0; i < n; i++){
        if(ans[i]){ // i が正直
          // cout << s[i] << ": " << ans[(i+1)%n] << ", " << ans[(n+i-1)%n] << endl;
          if(s[i] == 'o'){
            if(ans[(i+1)%n] != ans[(n+i-1)%n]){
              ok = false;
              break;
            }
          }else{
            if(ans[(i+1)%n] == ans[(n+i-1)%n]){
              ok = false;
              break;
            }
          }
        }else{
          if(s[i] == 'o'){
            if(ans[(i+1)%n] == ans[(n+i-1)%n]){
              ok = false;
              break;
            }
          }else{
            if(ans[(i+1)%n] != ans[(n+i-1)%n]){
              ok = false;
              break;
            }
          }
        }
      }

      if(!ok) continue;

      for(int i = 0; i < n; i++){
        if(ans[i]){
          cout << 'S';
        }else{
          cout << 'W';
        }
      }
      cout << endl;
      return 0;
      // if(ans[0]){ // 最初が正直
      //   if(s[0] == 'o'){
      //     if(ans[1] != ans[n-1]){
      //       continue;
      //     }
      //   }else{
      //     if(ans[1] == ans[n-1]){
      //       continue;
      //     }
      //   }
      // }else{
      //   if(s[0] == 'o'){
      //     if(ans[1] == ans[n-1]){
      //       continue;
      //     }
      //   }else{
      //     if(ans[1] != ans[n-1]){
      //       continue;
      //     }
      //   }
      // }
      // if(ans[n-1]){

      // }
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 512
N = int(input())
xmin = ymin = float('inf')
xmax = ymax = 0
p = []
for i in range(N):
    x,y = map(int, input().split())
    if x > y : 
        x,y= y,x
    p.append((x, y))
    if x < xmin:
        xmin = x
    elif x > xmax:
        xmax = x
    if y < ymin:
        ymin = y
    elif y > ymax:
        ymax = y
ret = (ymax-ymin) * (xmax-xmin)


p.sort()
dx = p[-1][0] - p[0][0]
ymin = p[0][1]
tymin = float('inf')
tymax = 0
for i in range(N-1):
    # print(i, dx, (xmax, xmin), end=' ==> ')
    tymin = min(tymin, p[i][1])
    xmax = max(xmax, p[i][1])
    xmin = min(tymin, p[i+1][0])
    ymin = min(ymin, p[i][0])
    dx = min(dx, xmax - xmin)
    # print(i, dx, (xmax, xmin))

# print(ret, (ymax-ymin) * (xmax-xmin) ,(ymax,ymin), (xmax,xmin), dx)
print(min(ret, (ymax-ymin) * dx))




Measured memory_bytes: 32136
program atcoder
implicit none
integer :: l , r , d , n
read *,l , r , d
if(l == 1)then
  print *, r/d
else if (mod(l,d) == 0)then
  n = int(r/d) - int(l/d) + 1
  print *,n
else
  n = int(r/d) - int(l/d)
  print *,n
end if
end program atcoder

Measured memory_bytes: 2856
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] arr = line.split(" ");
		double x1 = Double.parseDouble(arr[0]);
		double y1 = Double.parseDouble(arr[1]);
		double x2 = Double.parseDouble(arr[2]);
		double y2 = Double.parseDouble(arr[3]);

		double width2 = Math.pow(x2 - x1, 2);
		double height2 = Math.pow(y2 - y1, 2);
		double result = Math.sqrt(width2 + height2);

		System.out.printf("%.5f%n", result);

		if (br != null) {
			br.close();
			br = null;
		}
	}
}

Measured memory_bytes: 16944
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

D getExpectation(D x) {
   return perform(x)/x;
}

int main()
{
   cin>>N>>K;
   vector<int> A(N);
   
   for(auto &x:A) cin>>x;
   D best=0;
   D ans=0;
   
   for(int i=0;i<K;++i){
       ans+=getExpectation((D)A[i]);
   }
   best=max(best,ans);
   for(int i=K;i<N;++i){
       ans-=getExpectation((D)A[i-K]);
       ans+=getExpectation((D)A[i]);
       best=max(best,ans);
   }
   cout<<fixed<<setprecision(12)<<best<<"\n";
   
    
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h + 1, vector<int>(w + 1, 0));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }

    int count = 0;
    vector<int> y_prev(h * w), x_prev(h * w), y_next(h * w), x_next(h * w);
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j < w; j++) {
            if (a[i][j] % 2 == 1) {
                a[i][j]--;
                y_prev[count] = i;
                x_prev[count] = j;
                a[i][j + 1]++;
                y_next[count] = i;
                x_next[count] = j + 1;
                count++;
            }
        }
        if (a[i][w] % 2 == 1 && i < h) {
            a[i][w]--;
            y_prev[count] = i;
            x_prev[count] = w;
            a[i + 1][w]++;
            y_next[count] = i + 1;
            x_next[count] = w;
            count++;
        }
    }

    cout << count << endl;
    for (int i = 0; i < count; i++) {
        cout << y_prev[i] << " " << x_prev[i] << " " << y_next[i] << " " << x_next[i] << endl;
    }
}

Measured memory_bytes: 7168