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

int main(){
	int n,k;
	cin>>n>>k;
	double arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
		arr[i]++;
		arr[i]/=2.0;
	}
	double curr = 0;
	for(int i=0; i<k; i++) curr+=arr[i];
	double mx = curr;
	for(int i=k; i<n; i++){
		curr+=arr[i];
		curr-=arr[i-k];
		mx = max(mx,curr);
	}
	cout.precision(7);
	cout<<mx;
}

Measured memory_bytes: 5352
import java.util.Scanner;

//import jdk.internal.org.jline.utils.InputStreamReader;

//import java.io.*;

public class Main{
        public static void main(final String[] args){
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            int[] a = new int[n];
            for(int i = 0; i < n; i++){
                a[i] = scanner.nextInt();
            }
            for(int j = n-1; j>=0; j--){
                System.out.printf("%d", a[j]);
                if(j != 0){
                    System.out.printf(" ");
                }
            }
            System.out.printf("\n");
            scanner.close();
        }
         

}


Measured memory_bytes: 26288
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int64_t get_long(void) {
  int64_t num;
  scanf("%lld", &num);
  return num;
}

int get_int2(int64_t *a1, int *a2) {
  scanf("%lld %d", a1, a2);
  return 0;
}

// sort
int asc(const void *a1, const void *a2) {
    int64_t aa1 = *(int64_t*)a1;
    int64_t aa2 = *(int64_t*)a2;
    if(aa1 > aa2) return 1;
    if(aa1 == aa2) return 0;
    return -1;
}

#define NUM_MAX 100000



int main(void) {
    int num = get_int();
    int64_t circle = get_long();
    static int64_t pos[NUM_MAX+1];
    static int64_t value[NUM_MAX+1];

    int i;
    pos[0] = value[0] = 0;
    for(i = 1; i <= num; i++) {
        int64_t p;
        int val;
        get_int2(&p, &val);
        pos[i] = p;
        value[i] = val;
    }
    int64_t ans = 0;

    static int64_t rcum[NUM_MAX+2];
    int64_t prev = 0;
    int64_t profit = 0;
    for(i = num; i >= 1; i--) {
        int64_t cur = circle - pos[i];
        profit = profit -(cur-prev) + value[i];
        rcum[i-1] = max(rcum[i], profit - cur);
        prev = cur;
    }

    // cw
    prev = 0;
    profit = 0;
    static int64_t cum[NUM_MAX+2];
    for(i = 1; i <= num; i++) {
        int64_t cur = pos[i];
        profit = profit - (cur-prev) + value[i];
        cum[i+1] = max(cum[i], profit - cur);
#ifdef DEBUG
        printf("[<-%lld] %lld %lld\n", cur, profit, rcum[i]);
#endif
        // profit: [1, i] rcum: (i, n]
        ans = max(ans, profit + rcum[i]);
        prev = cur;
    }

    prev = 0;
    profit = 0;
    for(i = num; i >= 1; i--) {
        int64_t cur = circle - pos[i];
        profit = profit - (cur-prev)+value[i];
#ifdef DEBUG
        printf("[->%lld] %lld %lld\n", cur, profit, cum[i]);
#endif
        // cum: [1, i), profit: [i, num]
        ans = max(ans, profit + cum[i]);
        prev = cur;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a1(n), a2(n), counter1(n, 0), counter2(n, 1);
  for (auto & x : a1) std::cin >> x;
  for (auto & x : a2) std::cin >> x;
  counter1[0] = a1[0];
  counter2[0] = a1[0] + a2[0];
  for (int ni = 1; ni < n; ++ni) {
    counter1[ni] = counter1[ni - 1] + a1[ni];
    counter2[ni] = std::max(counter2[ni - 1], counter1[ni]) + a2[ni];
  }
  std::cout << counter2[n - 1] << std::endl;
  return 0;
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
// Template END

int inv( int x ){
	return power( x, mod - 2 ) ;
}
const int mxn = (int)1e6 ;

signed main(){
	int n ; cin >> n ;
	vector<int> a(n) ;
	for( int i = 0 ; i < n ; i++ ) {
		cin >> a[i] ;
	}
	int cnt[mxn + 1] = {0} ;
	for( int i = 0 ; i < n ; i++ ){
		cnt[a[i]]++ ;
	}
	int ans = n ;
	for( int i = 0 ; i < n ; i++ ){
		bool ok = true ;
		for( int j = 1 ; j * j <= a[i] ; j++ ){
			if( a[i] % j == 0 ){
				if( j == 1 && a[i] != 1 ){
					int f = a[i] ;
					if( cnt[f] > 1 || cnt[1] > 0 ){
						ok = false ;
						break ;
					}
				}
				else if( j == 1 && a[i] == 1 ){
					if( cnt[1] > 1 ){
						ok = false ;
						break ;
					}
				}
				else {
					int f = j ;
					int s = a[i] / j ;
					if( cnt[f] > 0 || cnt[s] > 0 ){
						ok = false ;
						break ;
					}
				}
			}
		}
		if( !ok ) --ans ;
	}
	cout << ans ;
	return 0 ;
}













Measured memory_bytes: 12776
#include <bits/stdc++.h>
using namespace std;
using s32 = int32_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main() {
	u32 N;
	cin >> N;
	
	vector<s32> X(N);
	s32 amin = 100;
	s32 amax = 1;
	
	for(u32 i=0; i<N; i++) {
		cin >> X[i];
		amin = min(amin, X[i]);
		amax = max(amax, X[i]);
	}
	
	u64 ans = UINT64_MAX;
	
	for(s32 i=amin; i<=amax; i++) {
		u64 tans = 0;
		for(u32 j=0; j<N && tans < ans; j++) {
			tans += pow((X[j] - i) , 2);
		}
		ans = min(ans, tans);
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
def comb(n,k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk
n,a,b=map(int,input().split())
mod=10**9+7
ans=(2**n-1)%mod
aa=comb(n,a)%mod
bb=comb(n,b)%mod
ans-=aa+bb
print(ans%mod)

Measured memory_bytes: 311856
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

int a,b;

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(x+r>W||x-r<0||y+r>H||y-r<0){
printf("No\n");
}
else{
printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 2000
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define p2(x) (x)*(x)
#define endl "\n"
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < n; i++)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()

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

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

int main(){
	ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	cout << gcd(a, b) << endl;
}

Measured memory_bytes: 3216
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()

arr=sorted(limii())

mat=[]
for i in range(m):
    b,c=mii()
    mat.append([b,c])

mat.sort(key=lambda x: x[1],reverse=True)
maxboundary=mat[0][1]
ans=0
i=0
temp=0
while maxboundary>arr[temp] and temp<n and i<m:
    ans+=mat[i][1]
    
    temp+=1
    if temp==n:
        break
    mat[i][0]-=1
    if mat[i][0]==0:
        i+=1
        if i<m:
            maxboundary=mat[i][1]
    #print(ans,temp,i,mat,maxboundary)

print(ans+sum(arr[temp:]))

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

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

using namespace std;


int main() {

    int n; cin >> n;
    int a[100001],v[100001];
    int Max = -1;
    rep(i,n) cin >> a[i];

    memset(v,0,sizeof(v));
    rep(i,n){
        v[a[i]+1] ++;
        if(a[i] != 0) v[a[i]-1] ++;
        v[a[i]] ++;
    }

    rep(i,100001){
        Max = max(Max,v[i]);
    }

    cout << Max;

    return 0;
}











Measured memory_bytes: 4292
n, t = map(int, input().split())
tl = list(map(int, input().split()))

time = 0
for i in range(1, n):
    if tl[i] - tl[i-1] > t:
        time += t
    else:
        time += tl[i] - tl[i-1]

print(time + t)

Measured memory_bytes: 26708
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string s, c, Forward, back;
ll q, t, f;
bool Reverse = false;

int main() {
	cin >> s;
	cin >> q;
	rep(i, q) {
		cin >> t;
		if (t == 1) {
			Reverse = !Reverse;
		}
		else {
			cin >> f >> c;
			if (f == 1) {
				if (Reverse) {
					back = back + c;
				}
				else {
					Forward = c + Forward;
				}
			}
			else {
				if (Reverse) {
					Forward = c + Forward;
				}
				else {
					back = back + c;
				}
			}
		}
	}
	string ans = Forward + s + back;
	if (!Reverse) {
		cout << ans << endl;
	}
	else {
		for (int i = sz(ans) - 1; i >= 0; i--)cout << ans[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1464
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, x;
        cin >> N >> x;
        vll a(N);
        rep(i, 0, N) cin >> a[i];

        ll ans = 0;
        rep(i, 1, N) {
                ll tmp = a[i] + a[i-1];
                if (tmp > x) {
                        tmp -= x;
                        if (tmp > a[i]) {
                                ll diff = tmp - a[i];
                                a[i] = 0;
                                a[i-1] -= diff;
                                ans += tmp;
                        } else {
                                a[i] -= tmp;
                                ans += tmp;
                        }
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 4052
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N, L;
  std::cin >> N >> L;

  // Main
  int iMin = -1;
  int minV = IINF;
  for (int i = 1; i <= N; ++i) {
    if (chmin(minV, std::abs(L + i - 1)))
      iMin = i;
  }

  int res = 0;
  for (int i = 1; i <= N; ++i) {
    if (i == iMin)
      continue;
    res += L + i - 1;
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string yes[2] = {"No", "Yes"};

int main(){
    ll d, t, s; cin >> d >> t >> s;
    ll res = d<=s*t;
    cout << yes[res] << endl;
}   


Measured memory_bytes: 3628
s = input()
alp = list("abcdefghijklmnopqrstuvwxyz")
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(s) < 26:
    for i in alp:
        if i not in s:
            print(s+i)
            break
else:
    ans = ""
    for i in range(len(s)-1):
        f = True
        for j in range(i, len(s)-1):
            if ord(s[j]) < ord(s[j+1]):
                f = False
                break
        if f:
            t = sorted(list(s[i:]))
            for k in t:
                if ord(s[i-1]) < ord(k):
                    print(s[:i-1] + k)
                    break
            exit()
    print(s[:-2] + s[len(s)-1])

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
  int b1,b2,b3;
  scanf("%d" , &b1);
  scanf("%d" , &b2);
  scanf("%d" , &b3);
  if(b1==1&&b2==1)
    {
      printf("Open\n");
    }
  else if(b3==1)
    {
      printf("Open\n");
    }
  else
    {
      printf("Close\n");
    }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  string S;
  cin >> S;
  
  if (N % 2 == 1 ){
    cout << "No" << endl;
    return 0;
  }
  
  bool ans = true;
  for (int i = 0; i < N/2; i ++){
    if (S.at(i) != S.at(i + N/2)) {
      ans = false;
    }
  }
  
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No "<< endl;
  }
  
}

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

int main(){
  string S,month,day;
  int m,d;
  cin>>S;
  month=S.substr(5,2);
  day=S.substr(8,2);
  m=atoi(month.c_str());
  d=atoi(day.c_str());
   if(m<=4){cout<<"Heisei"<<endl;}
   else if(m>4){cout<<"TBD"<<endl;}
  return 0;
}

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

const long long MOD = 1000000007LL;

int b, c, d;
long long memo[1001][1001];
vector<long long> fact, inv_fact;

long long power(long long _x, long long _n){
    long long res = 1;
    _x %= MOD;
    while(_n > 0LL){
        if(_n & 1LL){
            res *= _x;
            res %= MOD;
        }
        _x *= _x;
        _x %= MOD;
        _n >>= 1;
    }
    return res;
}

void initialize(int n){
    fill(memo[0], memo[n + 1], -1LL);

    fact.resize(n + 1);
    inv_fact.resize(n + 1);

    fact[0] = 1;
    inv_fact[0] = 1;
    for(long long i = 1 ; i <= n ; i++){
        fact[i] = (fact[i - 1] * i) % MOD;
        inv_fact[i] = power(fact[i], MOD - 2);
    }

    return;
}

inline long long perm(int n, int r){
    return fact[n] * inv_fact[n - r] % MOD;
}

// 残りn人で、今はa人組を作ろうとしている
long long rec(int n, int a){
    if(n == 0){
        return 1LL;
    }else if(n < 0 || a > b){
        return 0LL;
    }else if(memo[n][a] >= 0LL){
        return memo[n][a];
    }

    // a人組の数が0の場合
    long long res = rec(n, a + 1);

    // a人組をi組作る
    for(int i = c ; i <= d ; i++){
        if(a * i > n){
            break;
        }
        // このとき、遷移を nPa*i / (a!)^i / i! 倍する
        res += ((rec(n - a * i, a + 1) * perm(n, a * i) % MOD) * power(power(fact[a], i), MOD - 2) % MOD) * inv_fact[i] % MOD;
        res %= MOD;
    }

    return memo[n][a] = res;
}

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

    initialize(n);

    long long ans = rec(n, a);
    cout << ans << endl;

    return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    print(a * b);

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back
#define INF 100000001
 
typedef long long int ll;
 
 
using namespace std;
 

ll dp[100010+1]; 

int main()
{
    sll(n);
    sll(w);
    ll a[n]; ll val[n];
    ll sum=0;
    fr(i,0,n)
    {
        cin>>a[i]>>val[i];
        sum+=val[i];
    }
    memset(dp,INF,sizeof(dp));
    dp[0]=0;
    for(int i=1;i<n+1;i++)
    {
        for(int j=sum;j>=val[i-1];j--)
        {
            dp[j]=min(dp[j],dp[j-val[i-1]]+a[i-1]);    
        }
    }
    
    ll ans=0;
    for(int i=sum;i>=0;i--)
    {
        
        if(dp[i]<=w)
        {
            ans=i; break;
        }
    }
    cout<<ans;
 
}

Measured memory_bytes: 4540
import java.io.*;
class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] str_Fifth_Number = br.readLine().split(" ");
    int[] five_Numbers = new int[5];
    
    for(int i = 0 ; i < five_Numbers.length; i++){
      five_Numbers[i] = Integer.parseInt(str_Fifth_Number[i]);
    }
    boolean x_Check = size_Check(five_Numbers[0], five_Numbers[2], five_Numbers[4]);
    boolean y_Check = size_Check(five_Numbers[1], five_Numbers[3], five_Numbers[4]);
    if(x_Check && y_Check){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }

  private static boolean size_Check(int range, int circle_position, int radius){
    if(range < circle_position + radius) return false;
    if(0 > circle_position - radius) return false;
    return true;
  }

}



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

int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> xy(n);
  for (auto&& e : xy) cin >> e.first >> e.second;
  multiset<pair<int, int>> ms;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      ms.emplace(xy[j].first - xy[i].first, xy[j].second - xy[i].second);
    }
  }

  int x = 0;
  for (const auto& e : ms) {
    x = max(x, int(ms.count(e)));
  }
  cout << n - x << endl;
}


Measured memory_bytes: 384
def Main(N, A):
    ans = [0]*N
    hist = [0]*N
    for i in range(N):
        hist[A[i]-1] += 1
    whole = 0
    for i in range(N):
        whole += hist[i]*(hist[i]-1)//2
    for i in range(N):
        ans[i] = whole - hist[A[i]-1] + 1
    return ans

def main():
    N = int(input())
    A = list(map(int, input().split()))
    out = Main(N, A)
    for e in out:
        print(e)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var xArray = Console.ReadLine().Split().Select(double.Parse).ToList();
            var yArray = Console.ReadLine().Split().Select(double.Parse).ToList();

            var oneDiv = CalcMinkowski(xArray, yArray, 1);
            Console.WriteLine(oneDiv.ToString("F5"));
            var twoDiv = CalcMinkowski(xArray, yArray, 2);
            Console.WriteLine(twoDiv.ToString("F5"));
            var threeDiv = CalcMinkowski(xArray, yArray, 3);
            Console.WriteLine(threeDiv.ToString("F5"));
            var infinityDiv = CalcMinkowski(xArray, yArray, -1);
            Console.WriteLine(infinityDiv.ToString("F5"));
        }

        public static double CalcMinkowski(IEnumerable<double> xArray, IEnumerable<double> yArray, int n)
        {
            if (n < 0)
            {
                var dxy = xArray.Zip(yArray, (x, y) => Math.Abs(x - y)).Max();
                return dxy;
            }
            else
            {
                var sum = xArray.Zip(yArray, (x, y) => Math.Abs(Math.Pow(x - y, n))).Sum();
                var dxy = Math.Pow(sum, 1.0 / n);
                return dxy;
            }
        }
    }
}



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

int main(void){
    string input;
    
    cin >> input;
    
    if(input == "SUN"){
        cout << 7;
    }else if(input == "SAT"){
        cout << 1;
    }else if(input == "FRI"){
        cout << 2;
    }else if(input == "THU"){
        cout << 3;
    }else if(input == "WED"){
        cout << 4;
    }else if(input == "TUE"){
        cout << 5;
    }else if(input == "MON"){
        cout << 6;
    }
}

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

int main() {
    int n;cin>>n;
    char c;
    for(int i=0;i<n;++i){
        cin>>c;
        if(c=='Y'){
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int query(string s){
	cout << "? " << s << endl;
	int d; cin >> d;
	return d;
}

int main(){
	const int X = 62;
	string A;
	rep(i,26) A += char('a'+i);
	rep(i,26) A += char('A'+i);
	rep(i,10) A += char('0'+i);
	V<int> cnt(X);
	rep(i,X) cnt[i] = 128 - query(string(128,A[i]));
	int L = accumulate(all(cnt),0);
	string s;
	
	rep(c_,X){
		char c = A[c_];
		int n = cnt[c_];
		V<int> where;
		rep1(i,n){
			int lb = 0, ub = si(s)+1;
			while(ub-lb>1){
				int m = (lb+ub)/2;
				string q = s.substr(0,m) + string(i,c);
				int d = query(q);
				if(d+si(q) == L) lb = m;
				else ub = m;
			}
			where.pb(lb);
		}
		sort(all(where));
		show(where);
		string ns;
		int j = 0;
		rep(i,si(s)+1){
			while(j<n&&where[j]==i) ns += c, j++;
			if(i<si(s)) ns += s[i];
		}
		s = ns;
		show(s);
	}
	cout << "! " << s << endl;
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
using namespace std;
int main (void){

    int k, i, j;
    string s;

    cin >> k >> s;

    i = s.size();

    if(i <= k)
        cout << s << endl;
    else{
        for(j = 0;j < k;j++){
            cout << s[j];

        }

        cout << "..." << endl;
    }
        





    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
#define limit 1000005
#define lol (ll) sqrt((double)limit)
#define pb push_back
#define sci(x) scanf("%d",&x)
#define scl(y) scanf("%lld",&y)


int main()
{
    int n;
    double p;
    cin>>n;
    if(n%2==0)
    {
       p=(double)(n/2)/n;
    }
    else
    {
        int o=n/2;
        ++o;
        p=(double) o/n;

    }
    printf("%.10f\n",p);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define N 2010
int l[N][N], r[N][N], f[N][N];
bool mp[N][N];
char str[N];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", str + 1);
		for (int j = 1; j <= m; j++) mp[i][j] = str[j] == '#';
	}
	int ans = max(n, m);
	n--; m--;
	for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) mp[i][j] = mp[i][j] ^ mp[i][j + 1] ^ mp[i + 1][j] ^ mp[i + 1][j + 1];

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
			if (!mp[i][j]) l[i][j] = l[i][j - 1] + 1;
		for (int j = m; j >= 1; j--)
			if (!mp[i][j]) r[i][j] = r[i][j + 1] + 1;
	}
	for (int i = 1; i <= m; i++) l[0][i] = r[0][i] = 100000000;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
		{
			if (mp[i][j])
			{
				f[i][j] = 0;
				l[i][j] = r[i][j] = 100000000;
			}
			else
			{
				f[i][j] = f[i - 1][j] + 1;
				l[i][j] = min(l[i][j], l[i - 1][j]);
				r[i][j] = min(r[i][j], r[i - 1][j]);
				ans = max(ans, (f[i][j] + 1) * (l[i][j] + r[i][j]));
			}
		}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 51456
h, n = map(int, input().split())

dp = [float("inf") for _ in range(h+1)]
dp[0] = 0

for i in range(n):
    a, b = map(int, input().split())
    for j in range(h):
        nj = min(j+a, h)
        dp[nj] = min(dp[nj], dp[j]+b)

print(dp[h])


Measured memory_bytes: 54108
#include <cstdio>
using namespace std;

int main() {
  int n, c;
  while (1) {
    scanf("%d\n", &n);
    if (!n) break;
    c = 0;
    while (n!=1) {
      if (n&1) {
        n *= 3;
        ++n;
      } else {
        n >>= 1;
      }
      ++c;
    }
    printf("%d\n", c);
  }
  return 0;
}

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

int main() {
  ll n,m;
  cin >> n >> m;
  if(n*2>=m)cout<<m/2<<endl;
  else cout << n+(m-2*n)/4<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		long[][] dp = new long[11][100100];
		dp[0][0] = 1;
		for(int i = 0; i <= 100; i++) {
			for(int j = 9; j >= 0; j--) {
				for(int k = 0; k <= 1000; k++) {
					dp[j+1][k+i] += dp[j][k];
				}
			}
		}
		
		while(true) {
			int s = sc.nextInt();
			int n = sc.nextInt();
			if(n == 0 && s == 0) break;
			out.println(dp[s][n]);
		}
		out.flush();
		//
		
	}
}
		
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
    	return (int)nextLong();
    }
    
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
    

}

Measured memory_bytes: 29056
// agc046_b
// Extension

#include <bits/stdc++.h>
using namespace std;

#define nl "\n"
#define nf endl
#define ll long long
#define pb push_back
#define jn treapdidsu

#define INF (ll)1e18
#define mod 998244353
#define maxn 3010

ll i, i1, j, k, k1, t, n, m, res, flag[10], a, b, c, d, dp[maxn][maxn];

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

    #if !ONLINE_JUDGE && !EVAL
        ifstream cin("input.txt");
        ofstream cout("output.txt");
    #endif

    cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    for (i = a; i <= c; i++) {
        for (j = b; j <= d; j++) {
            if (i + j == a + b) continue;
            dp[i][j] = 0;
            if (i > a) dp[i][j] += j * dp[i - 1][j];
            if (j > b) dp[i][j] += i * dp[i][j - 1];
            if (i > a && j > b) dp[i][j] -= (i - 1) * (j - 1) * dp[i - 1][j - 1];
            dp[i][j] %= mod; dp[i][j] += mod; dp[i][j] %= mod;
        }
    }

    cout << dp[c][d];

    return 0;
}


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

int main()
{

int n,m;
cin>>n>>m;

int h[n];
bool ans[n];
for(int index =0;index<n;index++)
{
    cin>>h[index];
    ans[index]= true;
}

while(m--)
{
    int from,to;
    cin>>from>>to;
    from--;
    to--;
    
    if(h[from]<=h[to])
    ans[from]= false;
    if(h[from]>=h[to])
    ans[to]= false;
}
int res = 0;
for(int index =0;index<n;index++)
if(ans[index])
res++;
cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    int h[100000];
    cin >> n >> m;
    vector<vector<int>> G(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    for(int j = 0; j < m; j++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    LL ans = 0;
    LL max = 0, tmp;
    for(int i = 1;i <= n; i++){
        max = 0;
        for(int j = 0; j < G[i].size(); j++){
            tmp = h[G[i][j]];
            if(max < tmp)max = tmp;
        }
        if(max < h[i])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8744
n = int(input())
s = [input() for x in range(n)]

m = int(input())
t = [input() for x in range(m)]

ans = 0
for i in s:
  plus = s.count(i)
  minus = t.count(i)
  temp = plus - minus

  ans = max(ans, temp)

if ans < 0:
  ans = 0

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

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

int main(int argc, char const *argv[])
{
	int a,L;
	int max,min;
	string s;
	vector<int>::iterator it;
	int i,j;

	while(1){
		cin>>a>>L;
		if(a+L==0) break;

		vector<int> v;
		v.push_back(a);

		while(1){

			s=toString<int>(a);

			while(s.size()<L){
				s+="0";
			}
			
			sort(s.begin(), s.end());
			min=toInt(s);
			//sort(s.begin(), s.end(),greater<int>());
			reverse(s.begin(), s.end());
			max=toInt(s);
			
			a=max-min;
			it=find(v.begin(), v.end(),a);
			if(it!=v.end()) break;

			v.push_back(a);

		}
		j=distance(v.begin(),it);
		cout<<j<<" "<<a<<" "<<v.size()-j<<endl;


	}

	return 0;
}

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

int main(void)
{
    int X;
    cin >> X;
    
    int t = 0;
    for (t = 0; t <= X; t++)
    {
        int range = (t + 1) * t / 2;
        if(range >= X) break;
    }
    
    cout << t << endl;

    return 0;
}


Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split()))
c = [0 for _ in range(n)]
count = 0
for i in range(n):
  c[a[i]-1] += 1
for i in range(n):
  if(c[i] >= 2):
    count += int(c[i]*(c[i]-1)/2)

for i in range(n):
  sum = count
  now = a[i]
  now_c = c[now-1]
  sum -= now_c-1
  print(sum)

Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<char,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

ll MAX=200005;
vector<ll> F(MAX,1);
 
void fact(){
    for(ll i=1;i<MAX;i++){
    F[i]=F[i-1]*i%MOD;
    }
return;
}


// mod. m での a の逆元 a^{-1} を計算する
//ただしmとaが互いにその時のみ
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long comb(long long a, long long b){
    return (((F[a]*modinv(F[b],MOD))%MOD)*modinv(F[a-b],MOD))%MOD;
}

//↓↓↓↓↓↓fact()ってちゃんとつける！！！！！！！！！！！↓↓↓↓↓↓
//↓↓↓↓↓↓fact()ってちゃんとつける！！！！！！！！！！！↓↓↓↓↓↓
//↓↓↓↓↓↓fact()ってちゃんとつける！！！！！！！！！！！↓↓↓↓↓↓
//↓↓↓↓↓↓fact()ってちゃんとつける！！！！！！！！！！！↓↓↓↓↓↓
//↓↓↓↓↓↓fact()ってちゃんとつける！！！！！！！！！！！↓↓↓↓↓↓


int main(){
    fact();
    ll N;
    cin >> N;
    ll k;
    cin >> k;
    ll ans=0;
    if(k==1){
        cout<<N*(N-1)<<endl;return 0;
    }
    if(k>=N){k=N-1;}

    //iは0の個数
    for(ll i=0;i<=k;i++){
        //残りN-i個
        ans+=comb(N-1,i)*comb(N,i)%MOD;
        ans%=MOD;
    ;}

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


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int x;
  cin >> x;
  int count = 0;
  count += (x/500)*1000;
  if (x%500 != 0) {
    count += ((x%500)/5)*5;
  }
  cout << count << endl;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    sort(P.begin(), P.end(), greater<int>());
    
    int result = P[0]/2;
    for (int i = 1; i < N; i++) {
        result += P[i];
    }
    cout << result << endl;
}

Measured memory_bytes: 256
def solve():
    s = list(input())

    ans = []
    for i in range(len(s)):
        if s[i] != 'B':
            ans.append(s[i])
        elif s[i] == 'B' and ans:
            ans.pop(len(ans)-1)

    return ''.join(ans)

    
print(solve())


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
   int n;
   int a;
   n=10000;
   for(int i=0;i<n;i++){
        cin>>a;
   if(a==0){cout<<"";
   return 0;
    }
  else
  {
  cout<<"Case"<<" "<<i+1<<":"<<" "<<a<<endl;}
     } return 0;}





Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int f(int n){
    if(n == 0) return 1;
    return (n * f(n - 1));
}
int main(){
    int n, a = 0, b = 0;
    scanf("%d",&n);
    int p[n], q[n];
    for(int i = 0; i < n; i++)
        scanf("%d",&p[i]);
    for(int i = 0; i < n; i++)
        scanf("%d",&q[i]);
    for(int i = 0; i < n; i++){
        int c = 0, d = 0;
        for(int j = 0; j < i; j++){
            if(p[j] < p[i]) c ++;
            if(q[j] < q[i]) d ++;
        }
        if(p[i] - c - 1 > 0) a += (p[i] - c - 1) * f(n - i - 1);
        if(q[i] - d - 1 > 0) b += (q[i] - d - 1) * f(n - i - 1);
    }
    printf("%d\n",abs(a - b));
    return 0;
}

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

const int N = 100005;
int n, t;
int a[N];
map<int, int> cnt;

int main() {
	scanf("%d %d", &n, &t);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	
	int lst = 0;
	int mx = 0;
	for (int i = n; i >= 1; --i) {
		if (a[i] < lst) mx = max(mx, lst - a[i]), cnt[lst - a[i]]++;
		else lst = a[i];
	}

	cout << cnt[mx] << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  int yymm = 0, mmyy = 0;
  if (s.at(0) == '0'){
    if (s.at(1) != '0')
      mmyy = 1;
  }
  else if (s.at(0) == '1'){
    if (s.at(1) == '1' || s.at(1) == '2')
      mmyy = 1;
  }
  
  if (s.at(2) == '0'){
    if (s.at(3) != '0')
      yymm = 1;
  }
  else if (s.at(2) == '1'){
    if (s.at(3) == '1' || s.at(3) == '2')
      yymm = 1;
  }
  
  if (yymm == 1 && mmyy == 1)
    cout << "AMBIGUOUS" << endl;
  else if (yymm == 1 && mmyy == 0)
    cout << "YYMM" << endl;
  else if (yymm == 0 && mmyy == 1)
    cout << "MMYY" << endl;
  else
    cout << "NA" << endl;
}

Measured memory_bytes: 3596
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := scanInt()
	fmt.Fprintln(wr, a+a*a+a*a*a)
}


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

using namespace std;

typedef long long ll;

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

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

	int n, k;
	cin >> n >> k;

	vector<int> a(n+1, 0);
	rep(i, n) cin >> a[i];

	vector<int> b = a;
	vector<int> bef = a;
	rep(i, k){
		vector<int> imos(n+1, 0);
		rep(j, n){
			int l = max(j - b[j], 0);
			int r = min(j + b[j], n-1) + 1;
			imos[l]++;
			imos[r]--;
		}
		rep(j, n) imos[j+1] += imos[j];
		b = imos;

		bool updated = false;
		rep(j, n) {
			if(b[j] != bef[j]) {
				updated = true;
				break;
			}
		}
		if(!updated) break;
		bef = b;
	}

	rep(i, n) cout << b[i] << (i == n - 1 ? "\n" : " ");

}


Measured memory_bytes: 6508
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
int lcm(int a, int b){return(a*b)/gcd(a, b);}  


int32_t main()
{
	int n;
	cin >> n;
	int a[n+1];
	bool one = false;
	for(int i = 1 ;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]== 1)one = true;
	}
	if(!one){
		cout << -1<<endl;
		return 0;
	}
	int need = 1;
	int k = 0;
	for(int i=  1;i<= n;i++)
	{
		if(a[i] != need)
		{
			k++;
		}else{
			need++;
		}
	}
	cout << k << endl;
}

Measured memory_bytes: 4436
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for i in range(n):
  a = list(map(int, input().split()))
  ab = 0
  for i in range(len(a)):
    ab += a[i] * b[i]
  if ab > -c:
    count += 1
print(count)

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;
    cout << (a * b) << " " << (2 * (a+b)) << endl;

    return 0;
}

Measured memory_bytes: 1164