akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((int)(1e9)+9)
using namespace std;

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

int orig_d[303][303];
int d[303][303];

void warshall_floyd(int V){
	for (int k = 0; k < V; ++k){
		for (int i = 0; i < V; ++i){
			for (int j = 0;j < V; ++j){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			} // end for
		} // end for
	} // end for
}
	
int main()
{
	memset(orig_d, 0, sizeof(orig_d));
	memset(d, 0, sizeof(d));
	rep (i, 303) rep (j, 303){
		if (i != j){
			orig_d[i][j] = INF;
			d[i][j] = orig_d[i][j];
		} // end if
	} // end rep

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	rep (i, N){
		rep (j, N){
			cin >> orig_d[i][j];
			d[i][j] = orig_d[i][j];
		} // end rep
	} // end rep

	warshall_floyd(N);
	bool ok = true;
	rep (i, N){
		rep (j, N){
			ok &= (orig_d[i][j] == d[i][j]);
		} // end rep
	} // end rep

	ll res = -1LL;
	if (ok){
		rep (k, N){
			rep (i, N){
				rep (j, N){
					if (i == j || j == k || k == i) continue; 
					if (orig_d[i][j] == orig_d[i][k] + orig_d[k][j]){
						d[i][j] = 0;
					} // end if
				} // end rep
			} // end rep
		} // end rep

		res = 0LL;
		rep (i, N){
			for (int j = i + 1; j < N; ++j){
				res += (ll)d[i][j];
			} // end for
		} // end rep
	} // end if
	
	cout << res << endl;
		
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>




#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

//

int main(void) {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	rep(0, 2) {
		if (a > b) {
			ans += a;
			a--;
		}
		else {
			ans += b;
			b--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;

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

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int parent[114514];
long long connectSize[114514];
int tall[114514];
 
int searchRoot(int V){
    //頂点Vの親==頂点Vということは頂点Vはその木の根である。
    if(parent[V] == V){
        return V;
    }
    else{
        //一回ごとにparent[V]を更新する。辺の縮約
        return parent[V] = searchRoot(parent[V]);
    }
}
 
bool same(int X,int Y){
    if(searchRoot(X) == searchRoot(Y)) return true;
    else return false;
}
 
void unite(int X,int Y){
    //X,Yの高さが高い方の木の「高さ0の根」に高さが低い方の根を付ける
    int Xroot = searchRoot(X);
    int Yroot = searchRoot(Y);
    //同じ根を持つ木を併合することはしなくてよい
    if(Xroot == Yroot) return;
    if(tall[Xroot] > tall[Yroot]){
        parent[Yroot] = Xroot;
        connectSize[Xroot] += connectSize[Yroot];
        connectSize[Yroot] = connectSize[Yroot];
    }
    else if(tall[Xroot] == tall[Yroot]){
        parent[Yroot] = Xroot;
        //高さが同じとき、YがXの根の下に入るのでYの深さはXより1深くなる
        tall[Yroot]++;
        connectSize[Xroot] += connectSize[Yroot];
    }
    else {
        parent[Xroot] = Yroot;
        connectSize[Yroot] += connectSize[Xroot];
        connectSize[Xroot] = connectSize[Yroot];
    }
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N,M;cin >> N >> M;
    for(int i = 0;i<114514;i++){
        parent[i] = i;
        tall[i] = 0;
        connectSize[i] = 1;
    }
    for(int i = 0;i<M;i++){
        int a,b;cin >> a >> b;a--;b--;
        unite(a,b);
    }
    set<int> S;
    for(int i = 0;i<N;i++){
        S.insert(searchRoot(i));
    }
    cout << S.size()-1 << endl;
}


Measured memory_bytes: 9448
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int dp[1<<21];

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

    dp[0] = 1;
    for(int S=1; S<(1<<n); S++){
        bitset<22> tmp(S);
        int i = tmp.count();
        for(int j=0;j<n;j++){
            if( S & (1<<j) && a[i-1][j]){
                dp[S] += dp[S ^ (1<<j)];
                dp[S] %= MOD;
            }
        }
    }

    cout << dp[(1<<n)-1] << endl;



}

Measured memory_bytes: 8448
from collections import deque

D=list(map(str,input().split()))

S=deque([])

for i in range(len(D)):
    if str.isnumeric(D[i])==True:
        S.append(int(D[i]))
    else:
        A=S.pop()
        B=S.pop()
        if D[i]=="+":
            S.append(A+B)
        elif D[i]=="-":
            S.append(B-A)
        else:
            S.append(A*B)
    
print(S[0])


Measured memory_bytes: 6004
#include <iostream>
using namespace std;
int main(void){
    int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10;
    cin >>a1>>a2>>a3>>a4>>a5>>a6>>a7>>a8>>a9>>a10;
    
    cout << a1+a2+a3+a4+a5+a6+a7+a8+a9+a10 <<endl;
}



Measured memory_bytes: 3096
//https://atcoder.jp/contests/dp/tasks/dp_g
#include <bits/stdc++.h>
#define ALL(e) e.begin(), e.end()
#define RALL(e) e.rbegin(), e.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define dbg(x) (cerr << #x << ":" << x)
#define mid (l + r) / 2
#define fi first
#define sc second
#define N 1000000009

using namespace std;

typedef long long int lli;

vector <vector <int>> adj(100005);

int res;
bool visited[100005];
vector <int> dp(1000005, 0);

int dfs(int i){
	if(dp[i]) return dp[i];

	for(auto c: adj[i]){
		dp[i] = max(dfs(c) + 1, dp[i]);
	}
	
	if(!adj[i].size())
		return dp[i] = 0;

	return dp[i];
}

int main(){
	ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector <int> in_degree(n+5, 0);
	
	for(int i=0 ;i<m; i++){
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		in_degree[b]++;
	}


	for(int i=1 ;i<=n; i++){
		if(!in_degree[i]){
			dfs(i);
		}
	}

	cout << *max_element(ALL(dp)) << endl;

	return 0;
}

Measured memory_bytes: 16256
N=int(input())
T=list(map(int,input().split()))
M=int(input())
ans=[]

for i in range(M):
    p,x=map(int,input().split())
    tmp=list(T)
    tmp[p-1]=x
    ans.append(sum(tmp))
    
for i in range(M):
    print(ans[i])

Measured memory_bytes: 3064
N = int(input())
 
def calculate_n(x, y, z):
  n = x**2 + y**2 + z**2 + x*y + y*z + z*x
  return n
l = []
for x in range(1, N):
  for y in range(1, N):
    for z in range(1, N):
      n = calculate_n(x,y,z)
      if n > N:
        break
      else:
        l.append(n)
    if calculate_n(x, y+1, 1) > N:
      break
  if calculate_n(x+1, 1, 1) > N:
    break

import collections
c = collections.Counter(l)
for i in range(1, N+1):
  if i in c:
    print(c[i])
  else:
    print(0)

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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 modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  vector<vector<ll>> ord(26);

  string s, t;
  cin >> s >> t;
  int tmp;
  for(int i = 0; i < s.length(); i++){
    tmp = s[i] - 'a';
    ord[tmp].push_back(i);
  }

  // t判定
  bool ok = true;
  for(int i = 0; i < t.length(); i++){
    tmp = t[i] - 'a';
    if(ord[tmp].size() == 0){
      ok = false;
      break;
    }
  }

  if(ok){
    ll cur = -1;
    ll cnt_loop = 0;
    for(int i = 0; i < t.length(); i++){
      tmp = t[i] - 'a';
      auto itr = lower_bound(ord[tmp].begin(), ord[tmp].end(), cur);
      if(itr == ord[tmp].end()){
        cur = ord[tmp][0];
        cnt_loop++;
      }else{
        if(cur == *itr){
          itr++;
          if(itr == ord[tmp].end()){
            cur = ord[tmp][0];
            cnt_loop++;
          }else{
            cur = *itr;
          }
        }else{
          cur = *itr;
        }
      }
    }
    ll ans = (cnt_loop * s.length() + cur + 1);
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }

  return 0;
}



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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

string s;

int main() {
	cin >> s;

	int sz = s.size();
	bool ans = ( sz % 2 == 0 ) ^ ( s[0] == s[sz - 1] );

	if( ans ) {
		cout << "Second" << endl;
	}
	else {
		cout << "First" << endl;
	}

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve()
{
	int a,b,k;
	cin>>k>>a>>b;
	int flag = 1;
	for (int i = a; i <= b; ++i)
	{
		/* code */
		if(i%k==0)
		{
			cout<<"OK"<<endl;
			flag = 0;
			break;
		}
	}
	if(flag)
		cout<<"NG"<<endl;
}

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;

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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> v(N);
  rep(i, N) cin >> v[i];
  sort(all(v), greater<ll>());

  ll sum = 0;
  rep(i, A) {
    sum += v[i];
  }

  printf("%.6f\n", (double)sum / A);

  ll k = 0;
  rep(i, A) {
    if (v[i] == v[A - 1])
      k++;
  }

  ll n = 0;
  rep(i, N) {
    if (v[i] == v[A - 1])
      n++;
  }

  ll COM[51][51];

  repp(i, 0, N) {
    repp(j, 0, i) {
      if (j == 0 || j == i)
        COM[i][j] = 1;
      else {
        COM[i][j] = COM[i - 1][j - 1] + COM[i - 1][j];
      }
    }
  }

  ll ans = 0;
  if (k == A) {
    repp(i, A, B) {
      ans += COM[n][i];
    }
  } else {
    ans = COM[n][k];
  }
  cout << ans << endl;
}


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

int main() {
    string s;
    cin >> s;
    
    int n = (int)s.size();
    int a = 0, b = 0;
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'A') {
            a = i;
            break;
        }
    }
    
    for(int i = n-1; i >= 0; --i) {
        if(s[i] == 'Z') {
            b = i;
            break;
        }
    }
    
    cout << b - (a - 1) << endl;
}


Measured memory_bytes: 640
#include <iostream>

long long x;

using namespace std;
long long n, m, h[500000], g[500000];

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
		g[i] = 1;
	}
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b; a--, b--;
		if (h[a] >= h[b]) g[b] = 0;
		if (h[a] <= h[b]) g[a] = 0;
	}
	int s = 0;
	for (int i = 0; i < n; i++) s += g[i];
	cout << s;
}

Measured memory_bytes: 5164
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (s (make-array n :element-type 'bit :initial-element 0)))
    (declare (uint32 n))
    (dotimes (i n)
      (when (char= #\o (read-char))
        (setf (sbit s i) 1)))
    (dotimes (bits 4 (println -1))
      (let ((res (make-array n :element-type 'bit :initial-element 0)))
        (setf (aref res 0) (ldb (byte 1 0) bits))
        (setf (aref res 1) (ldb (byte 1 1) bits))
        (loop for pos from 2 below n
              do (setf (sbit res pos)
                       (logxor (sbit res (mod (- pos 1) n))
                               (sbit res (mod (- pos 2) n))
                               (sbit s (mod (- pos 1) n)))))
        (when (loop for pos below n
                    always (= (sbit s pos)
                              (logxor (sbit res (mod (- pos 1) n))
                                      (sbit res (mod pos n))
                                      (sbit res (mod (+ pos 1) n)))))
          (loop for b across res
                do (write-char (if (zerop b) #\W #\S)))
          (terpri)
          (return-from main))))))

#-swank(main)


Measured memory_bytes: 10728
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  for(int n=0;n<10000;++n){
    int za=n*8/100;
    int zb=n*10/100;
    if(a==za && b==zb){
      printf("%d\n",n);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}

Measured memory_bytes: 128
<?php
$N = intval(trim(fgets(STDIN)));
$A = explode(' ', trim(fgets(STDIN)));
$c1=$c2=$c3=0;
foreach($A as $a){
    if($a == '1')$c1++;
    if($a == '2')$c2++;
    if($a == '3')$c3++;
}
$dp = array_fill(0, $N+1, array_fill(0,$N+1, array_fill(0,$N+1,0)));
for($k = 0; $k <= $c3; ++$k){
    $dpk = &$dp[$k];
    for($j = 0, $J = $c2 + $c3 - $k; $j <= $J; ++$j){
        for($i = 0, $I = $c1+$c2+$c3-$k-$j; $i <= $I ; ++$i){
            if($i==0&&$j==0&&$k==0)continue;
            $tmp = $N;
            if($i>0)$tmp+=$i*$dpk[$j][$i-1];
            if($j>0)$tmp+=$j*$dpk[$j-1][$i+1];
            if($k>0)$tmp+=$k*$dp[$k-1][$j+1][$i];
            $dpk[$j][$i] = $tmp/($i+$j+$k);
        }
    }
}
echo $dp[$c3][$c2][$c1];


Measured memory_bytes: 926200
#include<stdio.h>

int judge(int,int);

int memo[1000001];

int main(void){
  int n,m,i,count;

  for(i=0;i<1000001;i++)
    memo[i]=-1;
  
  memo[0]=1;
  memo[1]=0;

  while(scanf("%d",&n),n){
      scanf("%d",&m);

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

int judge(int x,int fg){

  if(x%2==0)judge(x/2,2);
  else if(x%3==0)judge(x/3,3);
  else if(x%5==0)judge(x/5,5);

  if(memo[x]==0){
    memo[x*fg]=0;
    return 0;
  }
  return memo[x]=1;
}

Measured memory_bytes: 4312
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

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

const double PI=acos(-1.0);

string S;
void input()
{
    cin>>S;
}

void solve()
{
    if(S=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

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

Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
using namespace std;
char p[101000];
int C[3], n;
int main() {
	int i;
	scanf("%s", p);
	for (i = 0; p[i]; i++) {
		C[p[i] - 'a']++;
	}
	if (min(min(C[0], C[1]), C[2]) + 1 >= max(max(C[0], C[1]), C[2]))puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int[] a = new int[100002];
		int ans = 0;
		
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt() + 1;
			a[x - 1]++;
			a[x]++;
			a[x + 1]++;
			if (ans < a[x - 1]) {
				ans = a[x - 1];
			}
			if (ans < a[x]) {
				ans = a[x];
			}
			if (ans < a[x + 1]) {
				ans = a[x + 1];
			}
		}
		
		
		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 49932
import copy

def to_vector(bit):
    res = []
    id = 0
    while(bit > 0):
        if bit & 1: res.append(id)
        id += 1
        bit >>= 1
    return res


H, W, K = map(int,input().split())

c = []
for _ in range(H):
    c.append(list(input()))

ans = 0
for row_bit in range(2 << (H-1)):
    for column_bit in range(2 << (W-1)):
        c_now = copy.deepcopy(c)
        row_vector = to_vector(row_bit)
        column_vector = to_vector(column_bit)
        
        for h in range(H):
            for w in range(W):
                if h in row_vector or w in column_vector:
                    c_now[h][w] = "."

        cnt = 0
        for X in c_now: cnt += X.count("#")
        
        if cnt == K: ans += 1

print(ans)

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

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

    int n; cin >> n;

    vector<pair<int, int> > s;
    REP(i, n) {
        int tmp; cin >> tmp;
        s.push_back(make_pair(tmp, i + 1));
    }
    sort(s.begin(), s.end());

    REP(i, n) {
        cout << s[i].second;
        if (i != n - 1) cout << ' ';
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 1780
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll a, b, h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i=0; i<N; ++i) {
    cin >> L[i];
  }
  
  int max_len = *max_element(L.begin(), L.end());
  int sum_len = accumulate(L.begin(), L.end(), 0);
  
  if (max_len < sum_len - max_len) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}









Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int main() {
	int T; cin >> T;
	while (T--) {
		vector< vector<char> > a(4, vector<char>(8, -1)), b;
		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 7; j++)
				a[i][j] = i * 10 + j;
		b = a;
		for (int i = 0; i < 4; i++)
			for (int j = 1; j < 8; j++) {
				int x; cin >> x;
				x -= 11;
				b[i][j] = (x % 10 ? x : -1);
			}
		map<vector< vector<char> >, int> m;
		m[b] = 0;
		queue< vector< vector<char> > > q;
		q.push(b);
		while (!q.empty()) {
			vector< vector<char> > a = q.front(); q.pop();
			for (int i = 0; i < 4; i++)
				for (int j = 1; j < 8; j++) {
					if (a[i][j] != -1) continue;
					int x = a[i][j - 1];
					if (x == -1 || x % 10 == 6) continue;
					vector< vector<char> > b = a;
					for (int _i = 0; _i < 4; _i++)
						for (int _j = 1; _j < 8; _j++) {
							if (a[_i][_j] != x + 1) continue;
							b[i][j] = x + 1;
							b[_i][_j] = -1;
							if (m.count(b)) continue;
							m[b] = m[a] + 1;
							q.push(b);
						}
				}
		}
		cout << (m.count(a) ? m[a] : -1) << endl;
	}
}

Measured memory_bytes: 21736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//constexpr ll MOD = 1e9 + 7;
constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

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

  vector<ll> A(N);
  vector<ll> mp(N);
  for (ll i = 0; i < N; i++)
  {
    ll a;
    cin >> a;
    A.at(i) = a;
    mp.at(a)++;
  }

  ll Mx = *max_element(A.begin(), A.end());
  ll mn = *min_element(A.begin(), A.end());
  if (mp.at(mn) >= 3)
    FINALANS("Impossible");

  ll shouldMx = 2 * mn - (mp.at(mn) == 2);
  if (Mx != shouldMx)
    FINALANS("Impossible");
  
  for (ll i = mn + 1; i <= Mx; i++)
  {
    if (mp.at(i) < 2)
      FINALANS("Impossible");
  }
  FINALANS("Possible");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=1000000007;
const int nmax=201234;

int n,k,a[nmax];
ll res;
vector<int> v2;
map<int,int> map2;

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;++i)
        scanf("%d",&a[i]);
    for(int pos=0,i=0;i<n;++i){
        int tmp=(a[i]%k-1+k)%k;
        map2[pos]+=1;
        v2.pb(pos);
        pos=(pos-tmp+k)%k;
        if(i-k+1>=0)
            map2[v2[i-k+1]]-=1;
        res+=map2[pos];
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 11124
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void* a, const void *b) {
  return *(int*)b - *(int*)a;
}

int main(void) {
  int n;
  scanf("%d", &n);
  long a[200000];
  for(int i = 0;i < n;i++) {
    scanf("%ld", a + i);
  }
  qsort(a, n, sizeof(long), compare_int);
  long ret = a[0];
  for(int i = 1;i < n / 2;i++) {
    ret += a[i] * 2;
  }
  if(n % 2 ) ret += a[n / 2];
  printf("%ld\n", ret);
  return 0;
}

Measured memory_bytes: 5044
#include <iostream>
using namespace std;
 
int main() {
    
    int D, T, S;
    cin>>D>>T>>S;
 
   
    int d=S*T;
 
    
    if (d>=D) 
    {
        cout <<"Yes"<<endl;
    }
    else 
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
//\\//\\//\\//\\//\\//\\//\\//
#define fio ios::sync_with_stdio(false); cin.tie(nullptr)
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<'\n'
#define endl '\n'
#define eb emplace_back
#define f first
#define s second
//\\//\\//\\//\\//\\//\\//\\//
using namespace::std;
using ll=long long;
using pii=pair<int,int>;
const int inf=INT_MAX,mod=1e9+7;
//\\//\\//\\//\\//\\//\\//\\//


signed main(){
      fio;
      int n,k; cin>>n>>k;
      vector<int>vec(n);
      for (int i=0; i<n; i++) {
            cin>>vec[i];
      }

      sort(all(vec),greater<int>());

      ll ans=0;
      for (int i=0; i<n; i++,k--) {
            if(k<=0) ans+=vec[i];
      }

      cout<<ans<<endl;

      return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int dif[(int) 2e5+2];

int main()
{
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        if(i!=0)
            dif[i]=a[i]-a[i-1];
    }
    int c=k-abs(a[0]-a[n-1]);
    dif[n]=c;
    sort(dif,dif+n+1);
    int ans=0;
    for(int i=0;i<n;i++)
        ans+=dif[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

const double ERR = 1e-6;

typedef pair<double, double> XY;

double getlen(XY p, XY q) {
    return sqrt((p.first-q.first)*(p.first-q.first) + (p.second-q.second)*(p.second-q.second));
}

double area(XY p, XY q, XY r) {
    double pq, pr, qr;
    pq = getlen(p,q); pr = getlen(p,r); qr = getlen(q,r);
    return 0.5 * pq * pr * sin(acos((pq*pq + pr*pr - qr*qr)/2/pq/pr));
}

int main() {
    double x1,y1,x2,y2,x3,y3,xx,yy;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xx>>yy) {
        XY xy1, xy2, xy3, xyp;
        xy1 = make_pair(x1,y1);
        xy2 = make_pair(x2,y2);
        xy3 = make_pair(x3,y3);
        xyp = make_pair(xx,yy);
        if (abs(area(xy1,xy2,xy3) - (area(xy1,xy2,xyp) + area(xy2,xy3,xyp) + area(xy3,xy1,xyp))) < ERR) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

string s,s1,s2;
int n;
int main() {
    cin >> s1 >> s2;
    s = s1+s2;
    n = atoi(s.c_str());
    if((int)sqrt(n)*(int)sqrt(n) == n) puts("Yes");
    else puts("No");
    return 0;
}

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

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

  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    if (a.at(i) == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  long long ans = 1;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    if (a.at(i) > 1000000000000000000 / ans) {
      flag = true;
      break;
    }
    ans *= a.at(i);
  }

  if (flag) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

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


// 
public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        int N = nextInt();
        // we can get total - wrong
        long total = 1;
        long wrong = 0;
        long mod = (long)1e9 + 7;
        
        long[] map8 = new long[N+1];
        long[] map9 = new long[N+1];
        map8[0] = 1; 
        map9[0] = 1;

        for (int i=1; i<=N; i++) {
            map8[i] = 8 * map8[i-1];
            map9[i] = 9 * map9[i-1];
            total *= 10;

            map8[i] %= mod;
            map9[i] %= mod;
            total %= mod;
        }
 
        long no0and9 = map8[N];
        long no9 = map9[N];
        //use venn diagram
        wrong = 2* no9 - no0and9;
        wrong %= mod;

        long ans = total-wrong;
        ans %= mod;
        if(ans<0) ans+=mod;
        System.out.println(ans);
    }

      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 49224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}





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

ll n;cin>>n;

vl a(n+1);

for(int i=1;i<=n;i++)cin>>a[i];

  ll hsf=0;
for(int i=1;i<=n;i++)
{
  if(a[i]>hsf)hsf=a[i]-1;
  else if(a[i]<hsf)
  {
    cout<<"No"<<"\n";
    return 0;
  }
}

cout<<"Yes"<<"\n";

  return 0;


}

Measured memory_bytes: 1024
x, n = map(int, input().split())

if n == 0:
  print(x)

else:
  p = list(map(int, input().split()))
  p.sort()

  res = 100000
  ps = 0
  for i in p:
    ab = abs(x - i)
    if res > ab:
      res = ab
      ps = i
    else:
      break
  flug = False
  iter = 1
  while flug == False:
    ans1 = iter + ps
    ans2 = ps - iter
    if (ans2 in p) is False:
      print(ans2)
      flug = True
    elif (ans1 in p) is False:
      print(ans1)
      flug = True
    else:
      iter += 1

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code here;
	int n,i,j,sum=0;
	cin>>n;
	int ar[n];
	for(i=0;i<n;i++) cin>>ar[i];
	for(i=0;i<n;i++) {
		for(j=i+1;j<n;j++) sum+=ar[i]*ar[j];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }

// これを使うと O(r2 - r1 + 1)
// https://ja.wolframalpha.com/input/?i=%E2%88%91%5Bj%3Dc_1%E2%86%92c_2%5Dcomb%28r%2Bj%2Cr%29

const ll MOD = 1000000007;
struct Modint{
    ll num = 0;
    Modint(){}
    Modint(ll x){ x %= MOD; if(x < 0) x += MOD; num = x; }
    operator ll(){ return num; }
    Modint& operator+=(Modint x){ num += x.num; if(num >= MOD) num -= MOD; return *this; }
    Modint& operator-=(Modint x){ if(num < x.num) num += MOD; num -= x.num; return *this; }
    Modint& operator*=(Modint x){ num = num * x.num % MOD; return *this; }
    Modint& operator/=(Modint x){ return *this *= x.inv(); }
    Modint operator+ (Modint x) const { return Modint(*this) += x; }
    Modint operator- (Modint x) const { return Modint(*this) -= x; }
    Modint operator* (Modint x) const { return Modint(*this) *= x; }
    Modint operator/ (Modint x) const { return Modint(*this) /= x; }
    Modint inv(){
        return pow(MOD - 2); // MOD - 2 乗で逆元を取る
    }
    Modint pow(ll x){
        Modint ans = 1, cnt = *this;
        while(x){
            if(x & 1) ans *= cnt;
            cnt *= cnt;
            x /= 2;
        }
        return ans;
    }
};
Modint operator""_M(unsigned long long x) { return Modint(x); }

const ll MAX = 2020202;
vector<Modint> fac(MAX), inv(MAX);
void init(){
    fac[0] = 1;
    for(ll i = 1; i < MAX; i++) fac[i] = fac[i - 1] * Modint(i);
    inv.back() = fac.back().inv();
    for(ll i = MAX - 1; i > 0; i--) inv[i - 1] = inv[i] * Modint(i);
}

Modint comb(ll n, ll r){
    return fac[n] * inv[r] * inv[n - r];
}

// これを使うと O(1)
// https://ja.wolframalpha.com/input/?i=%E2%88%91%5Bi%3D0%E2%86%92a%5D%E2%88%91%5Bj%3D0%E2%86%92b%5Dcomb%28i%2Bj%2Ci%29
Modint sum(Modint r, Modint c){
    return ((r + 2_M) * comb(c + r + 2_M, r + 2_M) - c - 1_M) / Modint(c + 1_M);
}

int main(){
    init();
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1--; c1--;
    // 2次元累積和
    cout << sum(r2, c2) + sum(r1, c1) - sum(r1, c2) - sum(r2, c1) << endl;
}

Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='?'){
      cout<<'D';
    }else{
      cout<<s[i];
    }
  }
  cout<<endl;
}

Measured memory_bytes: 3720
fun main(args: Array<String>) {
    val (A, B) = readInputLine().split(" ").map { it.toInt() }
    
    var now = 1
    var ans = 0
    
    while (now < B) {
        now += A - 1
        ans++
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37876
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

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

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

void solve(string s) {
    for (auto &c : s) {
        if (c == '?') c = 'a';
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    exit(0);
}

signed main() {
    string s, t;
    cin >> s >> t;
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    const int s_len = (int)s.size();
    const int t_len = (int)t.size();
    rep(i, 0, s_len) {
        if (s[i] == t[0] || s[i] == '?') {
            string sa = s.substr(i, t_len);
            if ((int)sa.size() < t_len) continue;

            bool ok = true;
            rep(j, 0, t_len) {
                if (sa[j] != t[j] && sa[j] != '?') {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                rep(j, 0, t_len) {
                    s[i++] = t[j];
                }
                solve(s);
            }
        }
    }
    puts("UNRESTORABLE");
}


Measured memory_bytes: 256
#include<math.h>
#include<stdio.h>

int main(){
	int month,day,tsuki[13]={0,31,29,31,30,31,30,31,31,30,31,30,31},i;
	
	while(0<=scanf("%d%d",&month,&day)){
		if(month==0 && day==0)
		break;
		
		for(i=1;i<=month;i++){
			day=day+tsuki[i-1];
		}
		
		switch(day%7){
		  case 1:
			printf("Thursday\n");
			break;
		  case 2:
			printf("Friday\n");
			break;
		  case 3:
			printf("Saturday\n");
			break;
		  case 4:
			printf("Sunday\n");
			break;
		  case 5:
			printf("Monday\n");
			break;
		  case 6:
			printf("Tuesday\n");
			break;
		  default:
			printf("Wednesday\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

fn f(a:usize, b:usize, x: usize) -> usize {
    f64::floor((a * x / b) as f64) as usize - a * f64::floor((x / b) as f64) as usize
}

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        n: usize,
    }
    println!("{}", f(a, b, std::cmp::min(b - 1, n)));
}


Measured memory_bytes: 2076
d,g = map(int,input().split())
table = []
for i in range(d):
  table.append( [(i+1) * 100] + list(map(int,input().split())) )
time = [0 for _ in range(d)]
#print(table)
def suc(time):
  cnt = 0
  while cnt < d:
    if time[d-1-cnt] == 0:
      time[d-1-cnt] = 1
      return time
      break
    else:
      time[d-1-cnt] = 0
      cnt += 1
  else:
    return 'over'
def here(time):
  cnt = 0
  while time[d-1-cnt] == 1:
    cnt += 1
    if cnt == d+1:
      return 'full'
      break
  else:
    return cnt
ans = []
while time != 'over':
  now = 0
  scr = 0
  hh = here(time)
  if hh == 'full':
    h = 'fuck'
  else:
    h = table[d-1-here(time)]
  for i in range(d):
    now += time[i] * table[i][1]
    scr += time[i] * (table[i][0] * table[i][1] + table[i][2])
  if scr >= g:
    ans.append(now)
  else:
    rest = g - scr
    if rest < h[0] * h[1]:
      now += (rest-1) // h[0] + 1
      ans.append(now)
  time = suc(time)
print(min(ans))

Measured memory_bytes: 3064
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int max = -1000000;
        int min = 1000000;
        long total = 0;
        
        for(int i = 0; i < N; i++){
            if(max < nums[i]){
                max = nums[i];
            }
            
            if(min > nums[i]){
                min = nums[i];
            }
            
            total += nums[i];
        }
        
        Console.WriteLine(min + " " + max + " " + total);
    }
}



Measured memory_bytes: 20176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b;
 cin >> a>> b;
 int ans = max(max(a+a-1,b+b-1),a+b);
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
using  namespace std;
int main(){
  int h,w,cnt =0;cin >> h >> w;char c[10][10];
  for(int i = 0; i < h;i++){
    for(int j = 0;j < w;j++){
      cin >> c[i][j];
      if(c[i][j] == '#') cnt++;
    }
  }
  if(cnt == h+ w - 1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

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

int main(){
    int N; cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = N-2; i >= 0; i--){
        if(H[i] > H[i+1]){
            if(H[i] - H[i+1] == 1){
                H[i]--;
            }else{
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser


def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N,A,B = map(int, input().split())
    vs = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    vs.sort(reverse=True)
    cs=Counter(vs)
    tot=0
    cnt=0
    pr=-1

    
    for i in range(A):
        cur=vs[i]
        tot+=cur
        if cur!=pr:
            cnt=1
        else:
            cnt+=1
        pr=cur
    ave=tot/A
    print(ave)

    

    
        #float計算用のcombination, 最後にexpを取るのを忘れない、積は和でとること
    maxn=N
    
    lfact=[1]*(maxn+1)#NはnCrの最大のn
    for i in range(1,maxn+1):
        lfact[i]=lfact[i-1]*i
    def lcomb(n,r): return lfact[n]//lfact[n-r]//lfact[r]

    tc=cs[cur]
    if cnt==A:
        ans=0
        for cnt in range(A,B+1):
            ans+=(lcomb(tc,cnt))
    else:
        ans=(lcomb(tc,cnt))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 77512
# coding: utf-8
# Your code here!

def solve():
    dp = [[0 for j in range(W + 1)] for i in range(N + 1)]
    
    for i in range(1, N + 1):
        for j in range(W + 1):
            if j >= w[i-1]:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j - w[i-1]] + v[i-1])
            else:
                dp[i][j] = dp[i-1][j]
    print(max(max(dp)))

N, W = map(int, input().split())

v = [None] * N
w = [None] * N

for i in range(N):
    v[i], w[i] = map(int, input().split())


solve()







Measured memory_bytes: 25952
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll dp[2020][3030][4];

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  sort(A.begin(),A.end());
  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
      for(int j=0;j<=3000;j++){
          for(int k=0;k<4;k++){
              if(dp[i][j][k]==0) continue;
              dp[i+1][j][k]+=dp[i][j][k];

              if(k==3) continue;
              if(k==2){
                  if(j>A[i]) dp[i+1][j+A[i]][3]+=dp[i][j][k];
              }else dp[i+1][j+A[i]][k+1]+=dp[i][j][k];
          }
      }
  }

  ll ans=0;
  for(int j=0;j<=3000;j++) ans+=dp[N][j][3];
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 188928
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
//const ll mod = 1000000007;
//const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

typedef pair<ld, LDP> speP;

ld dist(ld x, ld y) {
	return sqrt(x*x + y * y);
}
void solve() {
	int n; cin >> n;
	vector<speP> v;
	rep(i, n) {
		ld x, y; cin >> x >> y;
		v.push_back({ atan2(y,x),{x,y} });
	}
	sort(v.begin(), v.end());
	rep(i, n) {
		speP p = v[i];
		p.first += 2 * pi;
		v.push_back(p);
	}
	ld sx = 0, sy = 0;
	int ri = 0;
	while (v[ri].first < 0) {
		sx += v[ri].second.first;
		sy += v[ri].second.second;
		ri++;
	}
	ld ans = dist(sx, sy);
	int le = 0;
	ld cur = 0;
	while (ri < v.size()) {
		ld dri = v[ri].first - cur;
		ld dle = v[le].first - (cur - pi);
		if (dle < dri) {
			cur += dle;
			sx -= v[le].second.first;
			sy -= v[le].second.second;
			le++;
		}
		else {
			cur += dri;
			sx += v[ri].second.first;
			sy += v[ri].second.second;
			ri++;
		}
		ans = max(ans, dist(sx, sy));
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(50);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int x;
const int MAX_N = 1000000;
int prime[MAX_N];
bool is_prime[MAX_N + 1];

void sieve(int n){
	int p = 0;
	for (int i = 0; i <= n; i++) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++){
		if (is_prime[i]){
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	cout << p << endl;
}

int main()
{
	while (scanf("%d",&x)!= EOF){
		sieve(x);
	}
	
	return 0;
}

Measured memory_bytes: 2496
n, k = gets.split(' ').map(&:to_i)
h = gets.split(' ').map(&:to_i)
dp = Array.new(100100, 10**9)

dp[0] = 0
0.upto(n-1) do |i|
  1.upto(k) do |j|
    if i+j < n
      dp[i+j] = [dp[i+j], dp[i] + (h[i] - h[i+j]).abs].min
    end
  end
end

print(dp[n-1])


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

int main() {
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  vector<int> v(3);

  int t = 0;
  for (;;) {
    if (s[t].size() == v[t]) {
      cout << (char)('A' + t) << endl;
      break;
    }
    t = s[t][v[t]++] - 'a';
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int n;
	int s[1002];
	cin>>n;
	rep(i,n){
		cin>>s[i];
		if(s[i]%2==0){
			if(s[i]%3!=0&&s[i]%5!=0)
			{
				cout << "DENIED" <<endl;
				return 0;
			}
		}
	}
	cout <<"APPROVED"<<endl;
	return 0;
} 

Measured memory_bytes: 256
def dv(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
A,B,K = map(int,input().split())
C = list(set(dv(A))&set(dv(B)))
C.sort()
C.reverse()
print(C[K-1])

Measured memory_bytes: 38384
n = gets.to_i
h = gets.split.map(&:to_i)
n -= 1
curMin = h[n]
answer = 'Yes'
while n >= 0
  if h[n] >= curMin + 2
    answer = 'No'
    break
  end
  curMin = [ curMin, h[n] ].min
  n -= 1
end
puts answer

Measured memory_bytes: 12676