akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
ll a[N],suf[N];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]; 
	for(int i=n;i>=1;i--) 
		suf[i]=(suf[i+1]+a[i])%mod;
	ll s=0;
	for(int i=1;i<n;i++)
		s=(s+a[i]*suf[i+1])%mod;
	cout<<s<<endl;
 	return 0;
}

Measured memory_bytes: 6744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = ReadLine().Split().Select(int.Parse).ToArray();
		WriteLine(Max(n[0] - n[1], 0));
	}
}


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

double pow3(double x){
  return x*x*x;
}

int main() {
  double x;
  double l;
  cin>>l;
  
  x=pow3(l)/27;
  //cout <<b<<endl;
  //cout<<x<<endl;
  printf("%.10f\n",x);
}



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

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

    long long x, y, ans = 0;
    x = n / (a + b);
    ans += a * x;

    y = n % (a + b);
    if (y > a) ans += a;
    else ans += y;

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#define N 500000
int heap_size;

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
} 
int right(int i){
  return 2*i+1;
}
void maxHeapify(int A[], int i){
  int l,r,largest,temp;  

  l = left(i);
  r = right(i);
  if(l <= heap_size && A[l] > A[i]){
    largest = l;
  }
  else largest = i;
  if(r <= heap_size && A[r] > A[largest]){
    largest = r;
  }

  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int  A[]){
  int i;
  for(i = (heap_size/2); i > 0; i--){
    maxHeapify(A,i);
  }
}
  
int main(){
  int i;
  int A[N];
  scanf("%d",&heap_size);
  for(i = 1; i <= heap_size; i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A);
  for(i = 1; i <= heap_size; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}


void func(void)
{
//DEBUG_OUT("----\n");
    string s;
    cin >> s;
    
    int insertXCnt = 0;
    int i = 0;
    int j = s.size()-1;
    for(; i<=j; i++, j--){
        bool skip = false;
        if(s[i]=='x' && s[j]=='x'){
            continue;
        }
        if(s[i]=='x' && s[j]!='x'){
            insertXCnt++;
            j++;
            continue;
        }
        if(s[i]!='x' && s[j]=='x'){
            insertXCnt++;
            i--;
            continue;
        }

        if(s[i] != s[j]){
            cout << -1 << endl;
            return;
        }
    }

    cout << insertXCnt << endl;
    
    return;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b, c, d;
  string A, B, C, D;
  cin >> a;
  vector<int> x(a);
  vector<int> y;
  vector<int> z;
  vector<int> w;
  vector<string> X;
  vector<string> Y;
  vector<string> Z;
  vector<string> W;
  rep(i, a) cin >> x[i];

  double ans = 0;
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  int cnt = 0;
  rep(i, a){
    ans += 1.0 / x[i];
  }
  cout << 1.0 / ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n,l,ans;
    cin>>n>>l;
    if(l + n - 1 < 0){
        ans = l * (n - 1) + (n - 2) * (n - 1) / 2;
    }else if(l > 0){
        ans = l * (n - 1) + n * (n - 1) / 2;
    }else{
        ans = l * n + n * (n - 1) / 2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-Ofast"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 307;

ld f[MX + 5][MX + 5][MX + 5];

int main(int argc, char*argv[]) {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x == 1) {
            c1++;
        } else if (x == 2) {
            c2++;
        } else {
            c3++;
        }
    }

    for (int k = 0; k < MX; k++) {
        for (int j = 0; j + k < MX; j++) {
            for (int i = 0; i + j + k < MX; i++) {
                if (i == 0 && j == 0 && k == 0) {
                    continue;
                }
                if (i + j + k > MX) {
                    continue;
                }
                ld wait = 1.0 * n / (i + j + k);
                ld pi = 1.0 * i / (i + j + k);
                ld pj = 1.0 * j / (i + j + k);
                ld pk = 1.0 * k / (i + j + k);

                if (i) {
                    f[i][j][k] += pi * f[i - 1][j][k];
                }
                if (j) {
                    f[i][j][k] += pj * f[i + 1][j - 1][k];
                }
                if (k) {
                    f[i][j][k] += pk * f[i][j + 1][k - 1];
                }
                f[i][j][k] += wait;
            }
        }
    }

    cout.precision(10);
    cout << fixed << f[c1][c2][c3] << "\n";
    return 0;
}



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

void zero();

struct p{
	int x, y, cnt;
};
int H, W, N;
int tizu[1001][1001];
bool flag[1001][1001] = { false };
int main(){
	queue<p> que;
	char a;
	char h[10] = "123456789";
	cin >> H >> W >> N;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			cin >> a;
			if (a == 'S'){
				tizu[i][j] = 0;
				p temp;
				temp.x = j;
				temp.y = i;
				temp.cnt = 0;
				que.push(temp);
			}
			else if (a == 'X'){
				tizu[i][j] = -1;
			}
			else if (a == '.'){
				tizu[i][j] = 0;
			}
			else {
				for (int k = 0; k < 9; k++){
					if (h[k] == a){
						tizu[i][j] = k + 1;
					}
				}

			}
			//cout << tizu[i][j];
		}
		//cout << endl;
	}
	int max = 1;
	int step = 0;
	zero();
	while (!que.empty()){
		p temp = que.front();
		que.pop();
		if (tizu[temp.y][temp.x] == max){
			max++;
			while (!que.empty()) que.pop();
			if (max - 1 == N) {
				max = temp.cnt;
				break;
			}
			zero();
		}
		if (flag[temp.y][temp.x] == true) continue;
		flag[temp.y][temp.x] = true;
		for (int i = 0; i < 4; i++){
			int dx[4] = { 1, -1, 0, 0 };
			int dy[4] = { 0, 0, 1, -1 };
			int yy = temp.y + dy[i];
			int xx = temp.x + dx[i];
			if (yy > -1 && xx > -1 && yy < H && xx < W && tizu[yy][xx] != -1 && flag[yy][xx] == false){
				p tt;				
				tt.y = yy;
				tt.x = xx;
				tt.cnt = temp.cnt + 1;
				que.push(tt);
			}
		}
	}
	cout << max << endl;
	return 0;
}
void zero(){
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			flag[i][j] = false;
		}
	}
}

Measured memory_bytes: 7980
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int N;
	vector<int> h;
	int dp() {
		static vector<int> memo(100000);
		memo[1] = abs(h[1] - h[0]);
		FOR(i, 2, N) {
			memo[i] = min(memo[i - 1] + abs(h[i] - h[i - 1]), memo[i - 2] + abs(h[i] - h[i - 2]));
		}
		return memo[N - 1];
	}
	void ans() {
		cin >> N;
		h.resize(N);
		REP(i, N) cin >> h[i];
		cout << dp() << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var points = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
        var a = points.Select(x => x[0] + x[1]).ToArray();
        var b = points.Select(x => x[0] - x[1]).ToArray();
        Console.WriteLine(Max(a.Max() - a.Min(), b.Max() - b.Min()));
    }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H + 2, vector<char>(W + 2, '.'));
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> s.at(i).at(j);
    }
  }
  bool ok = true;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s.at(i).at(j) == '#') {
        if (s.at(i - 1).at(j) == '.' && s.at(i + 1).at(j) == '.' && s.at(i).at(j + 1) == '.' && s.at(i).at(j - 1) == '.') {
          ok = false;
          break;
        }
      }
    }
    if (ok == false) {
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3648
line = input().rstrip().split(' ')
h = int(line[0])
n = int(line[1])

line = input().rstrip().split(' ')
a = [0] * n
sum = 0
for i in range(n):
    a[i] = int(line[i])
    sum += a[i]

if h <= sum:
    print('Yes')
else:
    print('No')

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

using namespace std;

#define forn(i, n) for (int64_t i = 0; i < (int64_t) (n); ++i)
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, k, q;
int a[N];

bool read() {
    if (!(cin >> n >> k >> q))
        return false;

    return true;
}

void solve() {
    fill(a, a + n, k - q);

    forn (i, q) {
        int j;
        cin >> j;
        ++a[j - 1];
    }
    
    forn (i, n)
        if (a[i] > 0)
            cout << "Yes\n";
        else
            cout << "No\n";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 1408
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *h = map(int, read().split())
    if n == 1:
        print(h[0])
        sys.exit()
    r1 = h[0]
    for i1 in range(n - 1):
        if h[i1] < h[i1 + 1]:
            r1 += (h[i1 + 1] - h[i1])
    print(r1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9096
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_N 100002
int par[MAX_N];
int rank[MAX_N];
int n,o,temp[MAX_N];

struct  node {
   int parent,mark;
} ;
struct node p[MAX_N];


void node_init(int n){
  int i;
  for (i = 0; i <= n; ++i) {
    p[i].parent = temp[i];
    if (i == 1) p[i].mark = 1;
    else p[i].mark = 0;
  }
}

//Union Find Tree?????????????????????
//????????¶?????§??????????????????????????§???
//?????¨??????????´???????????????????
void init(int n){
  int i;
  for(i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}


//x?????????????´?????±??????????????????£??¨????????????
int find(int x){
  if(par[x]==x){
    return x;
  }else {
    return par[x] = find(par[x]);
  }
}


//x,y????±?????????????????????¨??????
void unite(int x,int y){
  
  if(x==y){
    return ;
  }

    par[y] = x;

}


//x,y????±?????????????????????????????????????
int same(int x,int y){
  return find(x)==find(y);
}

void Tree_print(){
  int i;
  for (i = 1 ;i <= n;i++) printf("%d",par[i]);
  printf("\n");
}

int main() {
  int i,ob,current;
  long long int ans;
  char str[16],op;

  while(1){
    ans = 0;
    memset(temp,0, sizeof(temp));
    scanf("%d %d",&n,&o);
    //printf("%d %d\n",n,o);
    if( n == 0 && o == 0) break;
    init(n+1);

    for (i = 2; i <= n; ++i) {
      scanf("%d",&temp[i]);
      //printf("%d get\n",i);
    }

    node_init(n);

    for (i = n; i > 1 ; --i) {
      unite(p[i].parent,i);
      //Tree_print();
    }
    //Tree_print();

    for ( i= 0;  i < o; ++i) {
      if(i == 0 )getchar();
      fgets(str,16,stdin);
      sscanf(str,"%c %d",&op,&ob);
      //printf("%c %d\n",op,ob);
      if (op == 'M'){
        p[ob].mark = 1;
      }
      else{
        if (p[ob].mark == 1) ans += ob;
        else{
          current = par[ob];
          //printf("%d\n",current);
          while(p[current].mark != 1){
            if(par[current]  == current ) break;
            current =par[current];
          }
          ans+= current;

        }
      }
    }
    printf("%lld\n",ans);
    //printf("%d %d\n ",n,o);
  }

  return 0;
}

Measured memory_bytes: 2580
from sys import stdin
from math import factorial
n,a,b = map(int,stdin.readline().rstrip().split())
if n <= 2:
    print(0)
    exit()
def combination(n,r,mod=10**9+7):
    r=min(r,n-r)
    up,down=1,1
    for i in range(r):
        up=up*(n-i)%mod
        down=down*(i+1)%mod
    return up*pow(down,mod-2,mod)%mod
kotae = 2**n-combination(n,a)-combination(n,b)-1
kotae %= 10**9+7
print(kotae)

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

typedef long long LL;

LL a[100];

int main(){
	int n;
	scanf("%d",&n);
	a[0]=2;
	a[1]=1;
for(int i=2;i<=n;i++){
	a[i]=a[i-1]+a[i-2];
}
printf("%lld\n",a[n]);
}

 


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

using ll = long long int;

long long int N, M;

int main() {

	cin >> N >> M;
	vector<int>ans;
	while (N) {
		vector<int>hu(N);
		for (int i = 0; i < N; i++) {
			cin >> hu[i];
		}
		vector<int>de(M);
		vector<vector<pair<int, int>>>dp(1 << N, vector<pair<int, int>>(M));
		vector<int>sum(1 << N, INT_MAX);
		sum[0] = 0;
		for (int i = 0; i < M; i++) {
			cin >> de[i];
			dp[0][i].second = 1;
			sum[0] += de[i];
		}
		for (int i = 0; i < 1 << N; i++) {
			for (int j = 0; j < N; j++) {
				if ((i >> j)&1)continue;
				int box = 0;
				vector<pair<int, int>>v(M);
				for (int k = 0; k < M; k++) {
					if (!dp[i][k].second) {
						box += abs(de[k] - dp[i][k].first);
						v[k].first = dp[i][k].first;
					}
					else {
						if (abs(de[k] - dp[i][k].first)>abs(de[k] - (dp[i][k].first + hu[j]))) {
							v[k].first = dp[i][k].first + hu[j];
							v[k].second = 1;
							box += abs(de[k] - v[k].first);
						}
						else {
							v[k].first = dp[i][k].first;
							box += abs(de[k] - v[k].first);
						}
					}
				}
				if (sum[i + (1 << j)] > box) {
					sum[i + (1 << j)] = box;
					dp[i + (1 << j)] = v;
				}
			}
		}
		ans.push_back(sum[(1 << N) - 1]);
		cin >> N >> M;
	}
	for (auto i : ans) {
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 29772
def resolve():
    '''
    code here
    '''
    N = int(input())

    delta = 0
    if N > 1:
        for i in range(1, N+1):
            if (i-1)*i < 2*N < i*(i+1):
                delta = i*(i+1)//2 - N
                res_list = list(range(1, i+1))
                break
            elif 2*N == i*(i+1):
                res_list = range(1, i+1)
    else:
        res_list = [1]

    if delta > 0:
        while delta > res_list[-1]:
            delta -= res_list[-1]
            del res_list[-1]

        res_list.remove(delta)    
    

    for item in res_list:
        print(item)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9232
import sys
def input(): return sys.stdin.readline().rstrip()

from collections import Counter

def main():
  N = int(input())
  bosses = tuple(map(int, input().split()))

  c = Counter(bosses)
  for i in range(1, N+1):
    print(c[i])

if __name__ == '__main__':
  main()

Measured memory_bytes: 35316
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
  /// Return `true` if the slice was permuted, `false` if it is already
  /// at the last ordered permutation.
  fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
  /// Original author in Rust: Thomas Backman <serenity@exscape.org>
  fn next_permutation(&mut self) -> bool {
    // These cases only have 1 permutation each, so we can't do anything.
    if self.len() < 2 { return false; }

    // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
    let mut i = self.len() - 1;
    while i > 0 && self[i-1] >= self[i] {
      i -= 1;
    }

    // If that is the entire vector, this is the last-ordered permutation.
    if i == 0 {
      return false;
    }

    // Step 2: Find the rightmost element larger than the pivot (i-1)
    let mut j = self.len() - 1;
    while j >= i && self[j] <= self[i-1]  {
      j -= 1;
    }

    // Step 3: Swap that element with the pivot
    self.swap(j, i-1);

    // Step 4: Reverse the (previously) weakly decreasing part
    self[i..].reverse();

    true
  }
}
fn main() {
  let (n, k) = {
    let tmp: Vec<usize> = read_vec();
    (tmp[0], tmp[1])
  };

  let mut n2 = n;
  let mut count = 0;

  while (n2 > 0) {
    count += 1;
    n2/= k;
  }

  println!("{}", count);
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int a, b, c;
    int ab, ac, bc;
    cin >> a >> b >> c;
    
    ab = abs(a-b);
    ac = abs(a-c);
    bc = abs(c-b);

    if(ab >= ac && ab >= bc)
    {
        cout << ac+bc << endl;
    }else    if(ac >= ab && ac >= bc)
    {
        cout << ab+bc << endl;
    }else    if(bc >= ab && bc >= ac)
    {
        cout << ab+ac << endl;
    }

    
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrt(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-15;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

// 条件はa[i]<b[j]<c[k]。
// 解説しましたが、a[i]<b[j]とb[j]<c[k]は切り離して、取り敢えず後者を考えます。
// 予めcをソートしておくと、c.size()-upper_bound(all(c), b[j]) がb[j]に対応するcの個数です。
// これが各jについて記録できます。
// aについてもこれをやりたいのですが、数えたいのはさっき記録した「a[i]と一緒に使える各b[j]について、使えるcの個数の総和」です。
// bを最初にソートしておいて、さっき作った記録の累積和を逆向きに取るとそれのカウントが出来ます。

int main() {
	int n;	cin >> n;
	vint a(n), b(n), c(n);
	rep(i, n)	cin >> a[i];
	rep(i, n)	cin >> b[i];
	rep(i, n)	cin >> c[i];
	
	// bとcはソートします。
	sort(all(b));	sort(all(c));

	// 各b[j]について何個のcを使えるか
	vint usenum(n);
	rep(i, n) {
		usenum[i] = c.size() - distance(c.begin(), upper_bound(all(c), b[i]));
	}
	// その逆向きの累積和
	vector<ll> sum(n + 1);
	rrep(i, n)	sum[i] = sum[i + 1] + usenum[i];
	
	// aに行きます
	ll ret = 0;
	rep(i, n) {
		int idx = distance(b.begin(), upper_bound(all(b), a[i]));
		ret += sum[idx];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m), c(m);
	rep(i,m) cin >> a[i] >> b[i] >> c[i];
	vector<vector<int>> dist(n, vector<int>(n,INF));
	rep(i,n) dist[i][i] = 0;
	rep(i,m) {
		dist[a[i]-1][b[i]-1] = c[i];
		dist[b[i]-1][a[i]-1] = c[i];
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}
	int ans = 0;
	rep(i,m) {
		if (dist[a[i]-1][b[i]-1] != c[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
using namespace std;
int N,K;
LL fac[5000010],inv[5000010],ifac[5000010],d[2010][2010];
int main()
{
	cin>>N>>K;
	if(K==1)
	{
		cout<<1<<endl;
		return 0;
	}
	fac[0]=inv[0]=ifac[0]=fac[1]=inv[1]=ifac[1]=1;
	for(int i=2;i<=5000000;i++)
	{
		fac[i]=(fac[i-1]*i)%MOD;
		inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
		ifac[i]=(ifac[i-1]*inv[i])%MOD;
	}
	d[0][1]=1;
	for(int i=2;i<=N;i++)
	{
		d[0][i]=d[0][i-1]*(fac[i*(K-1)-1]*ifac[K-2]%MOD*ifac[(i-1)*(K-1)]%MOD)%MOD;
	}
	for(int i=1;i<=N;i++)
	{
		for(int j=i;j<=N;j++)
		{
			d[i][j]=(d[i-1][j]+d[i][j-1]*(fac[i+j*(K-1)-1]*ifac[K-2]%MOD*ifac[i+(j-1)*(K-1)]%MOD))%MOD;
// 			cout<<i<<' '<<j<<' '<<d[i][j]<<endl;
		}
	}
	cout<<(d[N][N]*fac[N])%MOD<<endl;
	return 0;
}

Measured memory_bytes: 148992
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int N, M;
    cin >> N >> M;
    int A[M];
    long long dist[100001] = {0};
    rep(i, M) cin >> A[i];
    sort(A, A + M);
    loop(i, 1, M) dist[i] = A[i] - A[i - 1];
    sort(dist, dist + M, greater<int>());
    int ans = 0;
    rep(i, N - 1) dist[i] = 0;
    rep(i, M) ans += dist[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 int n,k;
   cin>>n>>k;
  cout<<n-k+1<<endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    vector<ll> x(n), y(n), h(n);
    rep(i,n) cin >> x[i] >> y[i] >> h[i];
    rep(i,101) rep(j,101){
        ll hh = 0;
        bool count = true;
        vector<ll> rex(0), rey(0);
        rep(k,n){
            if(hh == 0 && h[k] > 0){
                hh = h[k]+abs(i-x[k])+abs(j-y[k]);
            }
            else if(hh == 0 && h[k] == 0){
                rex.push_back(x[k]);
                rey.push_back(y[k]);
            }
            else if(h[k] > 0){
                ll nh = h[k]+abs(i-x[k])+abs(j-y[k]);
                if(hh != nh){
                    count = false;
                    break;
                }
            }
            else if(h[k] == 0){
                if(hh > abs(i-x[k])+abs(j-y[k])){
                    count = false;
                    break;
                }
            }
        }
        if(count){
          int s = rex.size();
            rep(k,s){
                if(hh > abs(i-rex[k])+abs(j-rey[k])){
                    count = false;
                    break;
                }
            }
        }
        if(count){
            cout << i << " " << j << " " << hh << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  string s;
  cin >> s;
  int ans = 1;
  bool two = false;
  FOR(i, 1, s.length())
  {
    if (two)
    {
      two = false;
      ans++;
      continue;
    }
    if (s[i - 1] == s[i])
    {
      if (i != s.length() - 1)
      {
        ans++;
      }
      i++;
      two = true;
    }
    else
    {

      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int pos;

int parse(string s) {
	char c = s[pos];
	switch(c) {
	case '0':
	case '1':
	case '2':
		++pos;
		return c - '0';
	case '-':
		++pos;
		return 2 - parse(s);
	case '(':
		++pos;
		int a = parse(s);
		char op = s[pos];
		++pos;
		int b = parse(s);
		++pos;
		if(op == '+') {
			return max(a, b);
		} else if(op == '*') {
			return min(a, b);
		}
	}
}

int main() {
	string s;

	while(cin >> s, s != ".") {
		int ans = 0;
		REP(p, 3) {
			REP(q, 3) {
				REP(r, 3) {
					string tmp = s;
					pos = 0;
					REP(i, s.size()) {
						if(tmp[i] == 'P') {
							tmp[i] = p + '0';
						} else if(tmp[i] == 'Q') {
							tmp[i] = q + '0';
						} else if(tmp[i] == 'R') {
							tmp[i] = r + '0';
						}
					}
					
					if(parse(tmp) == 2) {
						ans++;
					}
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1e6+5;
char c1[N],c2[N];
int main()
{
	scanf("%s%s",c1+1,c2+1);
	int len=strlen(c1+1);
	int ans=0;
	for(int i=1;i<=len;i++){
		if(c1[i]!=c2[i]){
			ans++;
		}
	} 
	printf("%d",ans);
}


Measured memory_bytes: 4148
#include<stdio.h>
int main()
{
	int d[10],i,j;
	while(1)
	{
		for(i=0;i<10;i++)
			if(scanf("%1d",&d[i])==EOF)
				return 0;
		for(i=0;i<11;i++)
			for(j=0;j<9-i;j++)
				d[j]=(d[j]+d[j+1])%10;
		printf("%d\n",d[0]);
	}
}

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

struct Trie{
	int value;
	Trie *next[0x100];
	Trie(){ fill(next, next + 0x100, (Trie*)0); }
};
Trie *find(const string& t, Trie *r){
	for(int i = 0; t[i]; ++i){
		char c = t[i];
		if(!r->next[c]) r->next[c] = new Trie;
		r = r->next[c];
	}
	return r;
}
string s[100000];
Trie root;

ll L;
ll gr;
string state;

void dfs(Trie* node, int d){
	if(node == nullptr || d == L){
		if(node == nullptr){
			ll rem = L - d + 1;
			//cout << state << " " << rem << endl;
			gr ^= rem & (-rem);
			//cnt += rem % 4;
		}
		return;
	}
	//state += '0';
	dfs(node->next['0'], d + 1);
	//state.pop_back();
	//state += '1';
	dfs(node->next['1'], d + 1);
	//state.pop_back();
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif


	int n;
	cin >> n >> L;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	sort(s, s + n);
	for(int i = 0; i < n; i++){
		find(s[i], &root);
	}
	dfs(&root, 0);
	if(gr) cout << "Alice" << endl;
	else cout << "Bob" << endl;
}


Measured memory_bytes: 204240
#include<cstdio>
#include<algorithm>
using namespace std;
#define MN 50
#define MOD 1000000007
int c[MN+5][MN+5],f[MN+5][2][MN+5];
inline void rw(int&a,int b){if((a+=b)>=MOD)a-=MOD;}
int main()
{
	int n,i,j,k,l;
	scanf("%d",&n);
	for(i=0;i<=n;++i)for(c[i][0]=j=1;j<=i;++j)c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
	f[1][0][0]=f[1][1][1]=n;
	for(i=1;i<n;++i)for(j=0;j<=i;++j)
		for(k=0;i+k<=n;++k)for(l=(j+k)&1;i+k+l<=n;l+=2)if(k+l&&k+l>=j)
		{
			if((k+l+j)/2<k)rw(f[i+k+l][1][k-(k+l+j)/2],1LL*f[i][0][j]*c[n-i][k]%MOD*c[n-i-k][l]%MOD);
			else rw(f[i+k+l][0][(k+l+j)/2-k],1LL*f[i][0][j]*c[n-i][k]%MOD*c[n-i-k][l]%MOD);
			if((k+l-j)/2<k)rw(f[i+k+l][1][k-(k+l-j)/2],1LL*f[i][1][j]*c[n-i][k]%MOD*c[n-i-k][l]%MOD);
			else rw(f[i+k+l][0][(k+l-j)/2-k],1LL*f[i][1][j]*c[n-i][k]%MOD*c[n-i-k][l]%MOD);
		}
	printf("%d",f[n][0][0]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e7;
const int inf=1e9;
int N;
vector<pair<int,int>> g[10][10];
void dfs(int m,int v,string s){
    s += (char)(v + 'a');
	for(pair<int,int> p:g[m][v]){
        if(s.size() < N){
            dfs(p.first , p.second , s);
        }else{
            cout<<s<<endl;
            return;
        }
	}
	return;
}
int main(){
	cin>>N;
	rep(i,0,N)rep(j,0,i+1){
		rep(k,0,i+1) g[i][j].push_back({i,k});
		g[i][j].push_back({i+1,i+1});
	}
    //print(g[1][1],.first,10);
    //print(g[1][1],.second,10);
	dfs(0,0,"");
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void ppp(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int jank(int a){
  char s[4]="spr";
  FOR(3)if(a==s[i])return i;
}

int main(void){
  int h,n,ans=0;
  scanf(" %d %d",&h,&n);
  int a;
  FOR(n){
    scanf("%d",&a);
    ans+=a;
  }
  char s[2][4]={"Yes","No"};
  PRS(s[ans<h]);
  return 0;
}


Measured memory_bytes: 128
string = input()
num = int(input())
orders = [input().split() for _ in range(num)]

for order in orders:
    start = int(order[1])
    end = int(order[2]) + 1
    if order[0] == "reverse":
        string = string[:start] + string[start:end][::-1] + string[end:]
    elif order[0] == "replace":
        string = string[:start] + order[3] + string[end:]
    elif order[0] == "print":
        print(string[start:end])



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N, D;
  IN(N, D);
  ll ans = N/(2*D+1);
  if(N%(2*D+1)!=0) ans++;
  OUT(ans);

  return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

// <---------------------- > //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	vll a(n);
	for(ll i=0;i<n;i++) cin>>a[i];
		sort(all(a));
	reverse(all(a));
	a[0]/=2;

	cout<<accumulate(all(a),0);
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {

		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3412
def main():
    n, m = list(map(int, input().split()))
    x = []
    for _ in range(m):
        x.append(list(map(int, input().split())))
    for i in range(1000):
        y = str(i)
        if len(y) != n:
            continue
        
        for s, c in x:
            if y[s-1] != str(c):
                break
        else:
            print(i)
            return
    print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
N,M,X,Y = map(int,input().split())
XX = list(map(int,input().split()))
YY = list(map(int,input().split()))
XX.append(X)
YY.append(Y)
XX.sort()
YY.sort()
if(XX[-1]<YY[0]):
    print('No War')
else:
    print('War')


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<ll> a(n + 2, 0);
    ll sum = 0;
    for(int i = 1; i < n + 1; i++){
        cin >> a[i];
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n]);
    for(int i = 1; i < n + 1; i++){
        ll x = abs(a[i] - a[i - 1]);
        ll y = abs(a[i + 1] - a[i]);
        ll z = abs(a[i - 1] - a[i + 1]);
        ll ans = sum - (x + y) + z;
        cout << ans << endl;
    }
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include<vector>
#include <string>

using namespace std;

int main() {
	string S;
	cin >> S;
	if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) cout << "Yes";
	else cout << "No";
	//cout << S.at(2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int n;

int dfs(int rem, int x)
{
	if(rem == 0){
		if(x > n) return 0;
		bool f3, f5, f7;
		f3 = f5 = f7 = false;
		for(;x;x/=10){
			if(x%10 == 3) f3 = true;
			if(x%10 == 5) f5 = true;
			if(x%10 == 7) f7 = true;
		}
		if(!f3 || !f5 || !f7) return 0;
		return 1;
	}
	int ret = 0;
	ret += dfs(rem-1, x*10+3);
	ret += dfs(rem-1, x*10+5);
	ret += dfs(rem-1, x*10+7);
	return ret;
}

int main(void)
{
	cin >> n;
	
	int ans = 0;
	for(int i = 3; i <= 9; i++) ans += dfs(i, 0);
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

void solve() {
    int n;
    cin >> n;

    string s;
    cin >> s;

    map<string, int> mp;

    ll ans = 0;
    for (int mask = 0; mask < (1 << n); mask++) {
        string frw = "", bkw = "";
        for (int i = 0; i < n; i++) {
            if ((mask & (1 << i)) != 0)
                frw.push_back(s[i]);
            else
                bkw.push_back(s[i]);
        }

        reverse(bkw.begin(), bkw.end());
        mp[frw + "@" + bkw]++;
    }

    for (int mask = 0; mask < (1 << n); mask++) {
        string frw = "", bkw = "";
        for (int i = 0; i < n; i++) {
            if ((mask & (1 << i)) != 0)
                frw.push_back(s[i + n]);
            else
                bkw.push_back(s[i + n]);
        }

        reverse(frw.begin(), frw.end());
        string str = frw + "@" + bkw;
        reverse(str.begin(), str.end());

        ans += mp[str];
    }

    cout << ans;
}

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

Measured memory_bytes: 66432
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Wed Feb  6 12:11:20 2019
//
package main

import "fmt"

func pow2(n int) int {
	if n == 0 {
		return 1
	}
	return 2 * pow2(n-1)
}

func main() {
	var X, Y int
	fmt.Scan(&X, &Y)

	for i := 0; i < 1000; i++ {
		if X*pow2(i) <= Y && Y < X*pow2(i+1) {
			fmt.Println(i + 1)
			return
		}
	}
}


Measured memory_bytes: 512
import math
def main():
    N, D = map(int, input().split())
    points = [[int(a) for a in input().split()] for i in range(N)]
    counts = 0
    for i in range(N-1):
        for j in range(i + 1, N):
            d = 0
            for k in range(D):
                d += (points[i][k] - points[j][k])**2
            d = math.sqrt(d)
            if d.is_integer() == True:
                counts += 1
    print(counts)
main()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
    double a, b, c;
    cin >> a >> b >> c;
    c = c * (M_PI/180);
    double S = ((a*b)*sin(c))/2;
    double L = a + b + sqrt((a*a+b*b)-(2*a*b*cos(c)));
    double h = b * sin(c);
    cout << fixed << setprecision(6) << S << endl;
    cout << fixed << setprecision(6) << L << endl;
    cout << fixed << setprecision(6) << h << endl;
    return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    rep(i, M) cin >> A[i];
    ll s = accumulate(A.begin(), A.end(), 0L);
    if (s <= N) {
        cout << N - s << '\n';
    } else {
        cout << -1 << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(){
  ll n, k;
  cin >> n >> k;
  int a[n];
  rep(i,n) {
    cin >> a[i];
    a[i]--;
  }
  vector<vector<int>> v(n,vector<int>(62));
  rep(i,n) v[i][0] = a[i];
  for(int i = 1; i < 62; i++) {
    rep(j,n) {
      v[j][i] = v[v[j][i-1]][i-1];
    }
  } 
  int p = 0;
  for(ll i = 61; i >= 0; i--) {
    if(k & ((ll)1<<i)) p = v[p][i]; 
  }
  cout << p+1 << endl;
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<double> x(N), y(N);
	rep(i, N) {
		cin >> x[i] >> y[i];
	}

	vector<int> path;
	rep(i, N) path.push_back(i);

	double ans = 0;
	do {
		rep(i, N - 1) {
			ans += sqrt((x[path[i + 1]] - x[path[i]]) * (x[path[i + 1]] - x[path[i]]) + (y[path[i + 1]] - y[path[i]]) * (y[path[i + 1]] - y[path[i]]));
		}
	} while (next_permutation(path.begin(), path.end()));
	int c = 1;
	for (int i = 1; i <= N; i++) c *= i;
	cout << setprecision(14);
	cout << ans / c << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
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> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};

int a, b, c, d;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> a >> b >> c >> d;
  if (b < c || d < a) cout << 0 << endl;
  else {
    if (a < c && d < b) cout << d - c << endl;
    else if (c < a && b < d) cout<< b - a << endl;
    else cout << min(b - c, d - a) << endl;
  }
  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 09 20:51:06 2018

@author: Fujiichang
"""

if __name__ == "__main__":
    sec = input()

    h = sec / 3600
    m = (sec % 3600) / 60
    s = (sec % 60) % 60

    print '%d:%d:%d' % (h, m, s)



Measured memory_bytes: 4644
import io.StdIn._

object Main extends App {
  val NM = readLine.split(" ").map(_.toInt)
  val N = NM(0)
  val M = NM(1)

  val constraints = Range(0, M).map { _ =>
    val SC = readLine.split(" ").map(_.toInt)
    (SC(0) - 1, SC(1))
  }

  val ans = Range.inclusive(0, 999).find { n =>
    val ketaToDigit = n.toString.map(_.toInt - 48)

    ketaToDigit.length == N &&
      constraints.forall { case (s, c) => ketaToDigit(s) == c }
  }

  println(ans.getOrElse(-1))
}


Measured memory_bytes: 25408