akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int main()
{
    int X,N;
    cin>>X>>N;
    map<int,bool>m;
    for(int c=0;c<N;c++) {
        int z;
        cin>>z;
        m[z]=true;
    }

    int X2 = X;

    while(1){
        if(!m[X2]) {
            cout<<X2;
            return 0;
        }
        if(!m[X]) {
            cout<<X;
            return 0;
        }
        X2--;
        X++;
    }
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<limits.h>

#define N 500000

void Merge(int[],int,int,int);
void MergeSort(int[],int,int);
int c;

int main(){
  int a,i,A[N];
  scanf("%d",&a);
  for(i=0;i<a;i++)
    scanf("%d",&A[i]);
  MergeSort(A,0,a);
  for(i=0;i<a-1;i++)
    printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",c);
  return 0;
}

void Merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  int L[n1+1],R[n2+1];
  for(i=0;i<n1;i++)
    L[i]=A[left+i];
  for(i=0;i<n2;i++)
    R[i]=A[mid+i];
  L[n1]=INT_MAX;   
  R[n2]=INT_MAX;   
  i=0;
  j=0;
  for(k=left;k<right;k++){
      c++;
      if(L[i]<=R[j]){
        A[k]=L[i];
	i=i+1;
      }
      else{
        A[k]=R[j];
        j=j+1;
      }
  }
}       


void MergeSort(int A[],int left,int right){
  int mid;  
  if(left+1<right) {
    mid=(left+right)/2;
    MergeSort(A,left,mid);    
    MergeSort(A,mid,right);    
    Merge(A,left,mid,right);    
  }
}

Measured memory_bytes: 4504
n = int(input())
a = [list(map(int,input().split()))for _ in range(n)]
A,B = a[0][0],a[0][1]
for i in range(1,n):
    C = max([1,-(-A//a[i][0]),-(-B//a[i][1])])
    A = a[i][0]*C
    B = a[i][1]*C
print(A+B)

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll t1 = ( A - 1 ) / C;
	ll t2 = ( A - 1 ) / D;
	ll t3 = B / C;
	ll t4 = B / D;
	ll t5 = ( A - 1 ) / lcm( C, D );
	ll t6 = B / lcm( C, D );

	cout << ( ( B - A ) - ( t3 - t1 ) - ( t4 - t2 ) + ( t6 - t5 ) + 1 ) << endl;

	return ( 0 );
}


Measured memory_bytes: 256
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <utility>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long 
#define pii pair<int,int> 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<int> t;
vector<int> a;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	cout <<  ((b % a == 0) ? a + b : b - a) << '\n';
	return 0;
}


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

cnt = 0
for i in [1, 3, 5]:
    int_quot = n // (10 ** i)
    if n < (10 ** (i - 1)):
        break
    if int_quot == 0:
        cnt += n - 10 ** (i-1) + 1
    else:
        cnt += (10 ** i - 1) - (10 ** (i - 1)) + 1


print(cnt)


Measured memory_bytes: 2940
void main() {
	ri;
	auto a = readAs!(int[]);
	foreach_reverse(i, v; a) {
		if(i != 0) writef("%d ", v);
		else writeln(v);
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}



Measured memory_bytes: 2520
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

template<typename T>
void cout_mat(vector<vector<T>  > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int main(){
    string S;
    cin >> S;
    ll ans=0;
    reverse(S.begin(), S.end());
    vector<vector<ll> > dp((int)S.size()+1,vector<ll>(2,0));
    dp[0][1]=MOD;
    for(int i=0; i<(int)S.size(); i++){
        ll a=S[i]-'0';
        dp[i+1][0]=min(dp[i][1]+a+1, dp[i][0]+a);
        dp[i+1][1]=min(dp[i][1]+10-a-1, dp[i][0]+10-a);
    }

    //cout_mat(dp);

    cout << min(dp[(int)S.size()][0], dp[(int)S.size()][1]+1) << endl;
}

Measured memory_bytes: 55940
fn solve(s: String) -> usize {
    let n = s.len();
    let mut cs = s.chars().collect::<Vec<_>>();

    let mut ans = 1;
    let mut last = 0;
    let mut i = 1;

    loop {
        if i >= n {
            return ans;
        }

        if cs[last] != cs[i] {
            last += 1;
            i += 1;
            ans += 1;
            continue;
        }

        if i == n - 1 {
            return ans;
        }

        if i == n - 2 {
            return ans + 1;
        }

        ans += 2;
        last += 3;
        i += 3;
    }
}

#[test]
fn solve_test() {
    assert_eq!(solve("a".to_owned()), 1);
    assert_eq!(solve("ab".to_owned()), 2);
    assert_eq!(solve("aa".to_owned()), 1);
    assert_eq!(solve("aaa".to_owned()), 2);
    assert_eq!(solve("aaba".to_owned()), 3);

    assert_eq!(solve("aabbaa".to_owned()), 4);
    assert_eq!(solve("aaaccacabaababc".to_owned()), 12);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let s = read_line!();
    println!("{}", solve(s));
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc133/tasks/abc133_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        l: i64, r: i64
    };

    let mut best = 2019;
    for i in l..min(r+1, l+2019) {
        for j in max(l, r-2019)..r+1 {
            if i == j {
                continue;
            }
            best = min(best, i*j%2019);
        }
    }
    println!("{}", best);
}


Measured memory_bytes: 4352
import Control.Monad
import Data.Int

fn :: (Int64, Int64) -> Int64 -> Maybe (Int64, Int64)
fn (a, b) m
    | a > b = Nothing
    | otherwise = Just (m * ( (a + m - 1) `div` m), m * (b `div` m) + m - 1)

main = do
  getLine
  a <- fmap (reverse . (1:) . fmap read . words) getLine
  putStrLn $ case foldM fn (2, 2) a of
    Nothing -> "-1"
    Just (x, y) -> unwords $ [show x, show y]


Measured memory_bytes: 62844
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string a;
    cin >> a;
    bool alvi = false;
    if(a[2] == a[3] && a[4] == a[5])
        cout <<"Yes" << endl;
    else
        cout <<"No"<< endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		int left = Math.max(A, C);
		int right = Math.min(B, D);

		if (right - left > 0) {
			System.out.println(right - left);
		} else {
			System.out.println(0);
		}
	}

	private static long factorial(int n) {
		long factor = 1;
		for (int i = 1; i <= n; i++) {
			factor = factor * i;
		}
		debug(n, factor);
		return factor;
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

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

		public void fill(int[] a, int[] b, int[] c) throws IOException {
			if (a.length != b.length || b.length != c.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
				c[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

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

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 22996
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e2+5;

int x , y;
int parent[N];

int main(){
    cin >> x >> y;
    for(int i = 1; i <= 12; i++){
        parent[i] = i;
    }
    parent[3] = 1;
    parent[5] = 1;
    parent[7] = 1;
    parent[8] = 1;
    parent[10] = 1;
    parent[12] = 1;

    parent[6] = 4;
    parent[9] = 4;
    parent[11] = 4;

    if(parent[x] == parent[y]){
        cout << "Yes";
    } else {
        cout << "No";
    }
}
/*1 3 5 7 8 10 12
4 6 9 11
2*/


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  string st;
  cin >> st;
  int left = 0, right = n - 1;
  int ans = 0;
  while (left < right) {
    while (st[left] == 'R') ++left;
    while (st[right] == 'W') --right;
    if (left < right) {
      swap(st[left], st[right]);
      ++ans;
    } else {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
const int MOD = 1e9+7;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N]; rep(i,N) cin >> A[i];
    vi cnt(N,0);
    rep(i,N) {
        cnt[A[i]]++;
    }
    bool can=true;
    if(N%2) {
        rep(i,N/2) {
            if(i==0) {
                if(cnt[i]!=1) can=false;
            } else {
                if(cnt[2*i]!=2) can=false;
            }
        }
    } else {
        rep(i,N/2) {
            if(cnt[i*2+1]!=2) can=false;
        }
    }
    if(!can) cout << 0 << endl;
    else {
        int ans=1;
        rep(i,N/2) {
            ans*=2; 
            ans%=MOD;
        }
        cout << ans << endl;
    }
}

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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int count = 0, ans;
    for(int i=min(a,b);i>=1;i--){
        if(a % i == 0 && b % i == 0){
            count++;
            if(count == k){
                ans = i;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

ans = 10 ** 5
for i in range(N+1):
    j = N-i
    count = 0
    while i > 0:
        count += i % 6
        i //= 6
    while j > 0:
        count += j % 9
        j //= 9
    ans = min(ans, count)

print(ans)

Measured memory_bytes: 3060
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll N;
  string str;
  cin >> N >> str;

  ll nW_fromW[N + 1];
  ll nE_fromE[N + 1];

  nW_fromW[0] = 0;
  for (int i = 0; i < N; i++) {
    nW_fromW[i + 1] = nW_fromW[i];
    if (str[i] == 'W') nW_fromW[i + 1]++;
  }

  nE_fromE[N] = 0;
  for (int i = 0; i < N; i++) {
    nE_fromE[N - i - 1] = nE_fromE[N - i];
    if (str[N - i - 1] == 'E') nE_fromE[N - i - 1]++;
  }

  ll ans = LONG_LONG_MAX;
  for (int i = 0; i < N; i++) {
    if (ans > nW_fromW[i] + nE_fromE[i+1]) ans = nW_fromW[i] + nE_fromE[i+1];
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	string s;
	cin >> s;

	for (int i = 0; i < 3; i++) {
		if (s.at(i) == '1') s.at(i) = '9';
		else s.at(i) = '1';
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

from collections import Counter

ans = []

for (key, value) in Counter(A).items():
  if value >=2:
    ans.append(key)
  if value >= 4:
    ans.append(key)

if len(ans) <= 1:
  print(0)
else:
  ans = sorted(ans, reverse=True)
  print(ans[0] * ans[1])

Measured memory_bytes: 18316
#include <bits/stdc++.h>
using namespace std;
int main(){
	double a;
	int n;
	vector<pair<double,int> > lose;
	for(int i=0;i<3;i++){
		vector<pair<double,int> > data;
		for(int j=0;j<8;j++){
			cin>>n>>a;
			data.push_back(make_pair(a,n));
		}
		sort(data.begin(),data.end());
		for(int j=0;j<2;j++){
			printf("%d %.2f\n",data[j].second,data[j].first);
		}
		for(int j=2;j<4;j++){
			lose.push_back(make_pair(data[j].first,data[j].second));
		}
	}
	sort(lose.begin(),lose.end());
	for(int i=0;i<2;i++){
		printf("%d %.2f\n",lose[i].second,lose[i].first);
	}
}

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

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;

    if (s.size() <= k) {
        cout << s << endl;
    }
    else {
        for (int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }

    
    
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

  int N, M;
  cin >> N >> M;

  vector< pair<long, long> > drinks;
  for (int i = 0; i < N; i++) {
    long a, b;
    cin >> a >> b;
    drinks.push_back(pair< long, long>(a, b));
  }

  sort(drinks.begin(), drinks.end());

  long ans = 0;
  int num = 0;
  for (int i = 0; i < N; i++) {
    long p = drinks[i].first;
    long n = drinks[i].second;

    if (M - num < n) {
      // 残りのぶん買う
      ans += (p * (M - num));
      num += (M - num);
      break;
    }
    else {
      // 全て買う
      ans += (p * n);
      num += n;
    }

    if (num == M) {
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 2420
from sys import exit

# import copy
# import numpy as np
# from collections import deque

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

cnt = 0
for a in A:
    if a[0] ** 2 + a[1] ** 2 <= D ** 2:
        cnt += 1

print(cnt)


Measured memory_bytes: 45368
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll INF=(1ll<<60);
constexpr ll mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll n;cin>>n;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];

    ll ans=0;
    rep(i,n){
        bool can=true;
        for(ll j=0;j<i;j++){
            if(h[i]<h[j]) can=false;
        }
        if(can==true){
            ans++;
        }
    }

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

Measured memory_bytes: 3604
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();
			if((n|m|p) == 0) break;
			int sum = 0;
			int data = -1;
			for(int i = 0; i < n; i++){
				int now = sc.nextInt();
				if(i == m - 1){
					data = now;
				}
				sum+= now;
			}
			
			sum = sum * (100 - p);
			System.out.println(data == 0 ? 0 : sum / data);
		}
	}

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

Measured memory_bytes: 12000
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b,c;cin>>a>>b>>c;
    if(a%2==0 || b%2==0 || c%2==0)return cout<<"0" , 0;
    cout<<min({a*b , b*c , c*a});
}



Measured memory_bytes: 256
#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[i];

  int cnt = 0;
  int flag = 1;
  while (flag) {
    flag = 0;
    for (int i=n-1; i>0; i--) {
      if (a[i] < a[i-1]) {
        int temp = a[i];
        a[i] = a[i-1];
        a[i-1] = temp;
        flag = 1;
        cnt++;
      }
    }
  }

  for (int i=0; i<n-1; i++) cout << a[i] << " ";
  cout << a[n-1] << endl;
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int n;
   cin >> n;

   double cnt = 0;
   for(int i=1;i<=n;i++){
      if(i%2 != 0)cnt++;
   }
   double ans = 0;
   ans = cnt /n ;

   printf("%.6f\n",ans);


   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll a[3];
    scanf("%lld %lld %lld", a, a+1, a+2);
    printf(((100*a[0]+10*a[1]+a[2])%4==0)?"YES\n":"NO\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<ll>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl;
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod2 998244353
#define INT_MAX1 900000000
//////////////////////////////////////////////////////////////////////////////////////////////


int dp[101][100001];


void solve()
{
    int n,k;
    cin >> n >> k;
    int arr[n];
    inp(arr, n);
    for(int i=0; i<=k; i++)
    {
        if(arr[n-1]>=i)
        dp[n-1][i] = 1;
        else
            dp[n-1][i] = 0;
    }


    for(int i=n-2; i>=0; i--)
    {
        rep(j,1,k)
            dp[i+1][j] += dp[i+1][j-1], dp[i+1][j]%mod;
        for(int j=0; j<=k; j++)
        {
            int l = max((int)0,j-arr[i]);
            int r = j;
            if(l!=0)
                dp[i][j] = ((dp[i+1][r] - dp[i+1][l-1])%mod+mod)%mod;
            else
                dp[i][j] = (dp[i+1][r])%mod;
        }
    }

    cout << dp[0][k] << endl;
}

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

Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,a[10000],sum[1000000]={},ma=0;
  cin>>n;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    ma = max(ma,a[i]);
  }
  for(ll i=0;i<ma;i++){
    for(ll j=0;j<n;j++){
      sum[i] += pow(a[j]-(i+1),2);
    }
  }
  sort(sum,sum+ma);
  cout<<sum[0]<<"\n";
  return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
	    int b = s.nextInt();
	    int check = Math.max(a, b);
	    if(a == b) System.out.println("a == b");
	    else if(check == a ) System.out.println("a > b");
	    else System.out.println("a < b");
	    
	}
	public static void main(String[] args) {
		
		new Main().run();
		
	}
}

Measured memory_bytes: 26108
n = int(input())
siritori_list = list()
for i in range(n):
    siritori_list.append(input())
for ii in range(n):
    word = siritori_list.pop(0)
    if siritori_list:
        if not(word[-1] == siritori_list[0][0]) or word in siritori_list:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		int au = a / 1000;
		int aur = au % 10 * 10 + au / 10;
		int am = a / 100 % 10;
		int al = a % 100;
		if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		}

		int bu = b / 1000;
		int bur = bu % 10 * 10 + bu / 10;
		int bm = b / 100 % 10;
		int bl = b % 100;
		if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		}

		int num = (bu - au - 1) * 10 + 11 - am + bm;

		System.out.println(num);
	}
}


Measured memory_bytes: 21844
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e4 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL n, k, x, y;

	cin >> n >> k >> x >> y;
	k = min(k, n);
	cout << x * k + (n - k)*y << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  var lines = input.split('\n');
  var count = 0;
  for (var i = 1; i < lines.length; i++) {
    var xu = lines[i].split(' ');
    if (xu[1] == 'JPY') {
      count += parseFloat(xu[0]);
    } else {
      count += (380000.0 * xu[0]);
    }
  }
	console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
N,K = map(int,input().split())

a = list(map(int,input().split()))
sum_a = [0]

for i in range(K):
    sum_a[0] += a[i]

j = 0

max_v = sum_a[0]
ele = K-1
expected_value = 0
# 範囲の初めの値と範囲外の値を比較
for i in range(K,N):
    sum_a.append(sum_a[j]+(a[i]-a[i-K]))
    if max_v < sum_a[j+1]:
        max_v = sum_a[j+1]
        ele = i
    j += 1
s_ele = ele+1-K
for n in range(s_ele,ele+1):
    expected_value += (a[n]*0.5)+0.5
print(expected_value)


Measured memory_bytes: 32160
#include <stdio.h>
#include <algorithm>

#define BUF 200002
#define LIM_N 100001

char str[BUF];

int N;

int a1[LIM_N];
int a2[LIM_N];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d", &N);

	for (size_t i = 0; i < N; i++) {
		scanf("%d", &a1[i]);
	}

	for (size_t i = 0; i < N; i++) {
		scanf("%d", &a2[i]);
	}
}

int solve() {
	int sum = a1[0];
	for (size_t i = 0; i < N; i++) {
		sum += a2[i];
	}

	int max = sum;
	for (size_t i = 1; i < N; i++) {
		sum -= a2[i-1];
		sum += a1[i];
		max = max > sum ? max : sum;
	}

	return max;
}

int main(void) {
	receive_input();

	printf("%d\n", solve());

	return 0;
}


Measured memory_bytes: 128
// https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/precompiled/stdc%2B%2B.h
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
//#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int INF = 1001001001;
const double PI = acos(-1);
const int mod=1e9+7;
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; }
ll gcd (ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm (ll a, ll b) { return a/gcd(a,b)*b; }
/*------------------------------------------------------------------------------
...................................ENTRY POINT..................................
------------------------------------------------------------------------------*/
int main(void){
  int k;
  cin >> k;
  string ret = "";
  for(int i=0;i<k;i++) ret += "ACL";
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3624
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


LL a[3000], n, m, b[3000];
int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  cin >> n >> m;
  rep(i, n) cin >> a[i], b[i] = a[i];
  LL res = 0;
  rep(i, n) res += a[i];
  rep(i, 1, n) {
    rep(j, n) smin(b[j], a[(j - i + n) % n]);
    LL s = 0;
    rep(j, n) s += b[j];
    smin(res, s + i * m);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> //调用lower_bound 
const int N = 44721; 
using namespace std;
int sum[N];    //全局变量清0 
int main()
{
      int x,i; 
    scanf("%d", &x);
    for (int i = 1; i <= N; i++)
        sum[i] = sum[i-1] + i;
        
        
    i=lower_bound(sum,sum+N,x)-sum;//函数用法熟练 
    printf("%d", i);
    return 0;
}

Measured memory_bytes: 384
#include<iomanip>
#include<iostream>
#include<cstring>
#include<cmath>
#include<time.h>
#include<stdlib.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0)return puts("Yes"),0;
		a-=d;
		if(a<=0)return puts("No"),0;
	}
    return 0;
}


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

int main()
{
	int n, d;
	cin >> n >> d;
	int point[10][10];
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < d; ++j)
		{
			cin >> point[i][j];
		}
	}
	int ans = 0;
	int now;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			now = 0;
			for (int k = 0; k < d; ++k)
			{
				now += pow(abs(point[i][k] - point[j][k]), 2);
			}
			ans += (pow((int)sqrt(now),2) == now);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
 
const double PI=acos(-1.0);
int main(){
	double r;
	scanf("%lf",&r);
	printf("%.5lf",2.0*r*PI);
    return 0;
}

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


int main()
{
  int n;
  cin >> n;
  ll mx = 1e18;
  vector<ll> a(n);
  rep(i, n)
    cin >> a[i];
  sort(a.begin(), a.end());
  if (a[0] == 0)
  {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  rep(i, n)
  {
    if ((ans > (mx + a[i] - 1)/ a[i]) || (ans * a[i] > mx))
    {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3964
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Integral Rectangles
// 2013/08/13
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int h, w;

	void run(){
		for(;;){
			h=sc.nextInt();
			w=sc.nextInt();
			if((h|w)==0){
				break;
			}
			solve();
		}
	}

	void solve(){
		int ww=200, hh=200;
		for(int i=1; i<200; i++){
			for(int j=1; j<i; j++){
				if(comp(i, j, w, h)>0&&comp(i, j, ww, hh)<0){
					ww=i;
					hh=j;
				}
			}
		}
		println(hh+" "+ww);
	}

	int comp(int w1, int h1, int w2, int h2){
		if(w1*w1+h1*h1!=w2*w2+h2*h2){
			return (w1*w1+h1*h1)-(w2*w2+h2*h2);
		}else{
			return h1-h2;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 20592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n;
    string s;
    cin >> n;
    int ans = 0;
    int res=1;
    for (int i=1;i <= n;i++){
       int cnt = 0;
       int tmp;
       tmp = i;
       while (tmp%2 == 0){
          cnt++;
          tmp/=2;
       }
       if (ans < cnt) {
          ans = max(ans,cnt);
          res = i;
       }
    }
    cout << res << endl;
    
    return 0;
    
}



Measured memory_bytes: 256
package main

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

const mod = 998244353
const facNum = 300001
const INF = 2 << 31
const MAX_N = 100005

func main() {
	sc := newScanner(os.Stdin)
	N := sc.i()
	A := sc.is(N)
	Q := sc.i()
	dp := make([]int, MAX_N)
	for _, a := range A {
		dp[a] += 1
	}
	sum := 0
	for i, a := range dp {
		sum += i * a
	}

	ans := make([]int, Q)
	for i := 0; i < Q; i++ {
		b, c := sc.i(), sc.i()
		a := dp[b]
		dp[b] = 0
		dp[c] += a
		sum += (c - b) * a
		ans[i] = sum
	}
	for i := range ans {
		fmt.Println(ans[i])
	}

}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//------------------------------

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];
    ll tmp = h.back();
    REPD(i, n-1){
        if(tmp < h[i]) h[i]--;
        tmp = h[i];
    }
    tmp = h[0];
    REP(i, n-1){
        if(tmp > h[i+1]){
            cout << "No";
            return 0;
        }
        tmp = h[i+1];
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3984
from itertools import accumulate

N, K = map(int, input().split())
Ps = list(map(int, input().split()))

Es = [(P+1)/2 for P in Ps]
accEs = list(accumulate([0]+Es))

ans = 0.0
for i in range(N-K+1):
    e = accEs[i+K] - accEs[i]
    if e > ans:
        ans = e

print(ans)


Measured memory_bytes: 34472
#include <bits/stdc++.h>
using namespace std;
const int sticks[10]={6,2,5,5,4,5,6,3,7,6};
int dp[5005][10005];
int pre[5005][10005];
int dij[5005][10005];
int can[10];
int n,m;
void out(int i,int j)
{
	if(i==0)return;
	cout<<dij[i][j];
	out(i-1,pre[i][j]);
}
int main()
{
	memset(dp,0x80,sizeof(dp));
	dp[0][0]=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x;
		can[x]=true;
	}
	for(int i=1;i<=n/2;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=1;k<=9;k++)
			{
				if(!can[k])continue;
				if(j<sticks[k])continue;
				if(dp[i][j]<dp[i-1][j-sticks[k]]+1)
				{
					dp[i][j]=dp[i-1][j-sticks[k]]+1;
					dij[i][j]=k;
					pre[i][j]=j-sticks[k];
				}
				else if(dp[i][j]==dp[i-1][j-sticks[k]]+1)
				{
					pre[i][j]=j-sticks[k];
					dij[i][j]=k;
				}
			}
		}
	}
	for(int i=n/2;i>=1;i--)
	{
		if(dp[i][n]>0)
		{
			out(i,n);
			break;
		}
	}
	return 0;
} 

Measured memory_bytes: 587008