akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC021B {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int num = 50000;
            //double[] max = new double[num];
            //double[] min = new double[num];
            double[] max = Enumerable.Repeat(-100000000.0, num).ToArray();
            double[] min = Enumerable.Repeat(100000000.0, num).ToArray();
            int[] maxNum = new int[num];
            int[] minNum = new int[num];
            double[] stdx = new double[num];
            double[] stdy = new double[num];
            int l = 0;
            for(int i = 0; i < num; i++) {
                stdx[i] = Math.Cos(i / (double)num * Math.PI);
                stdy[i] = Math.Sin(i / (double)num * Math.PI);
            }
            int[] xs = new int[N];
            int[] ys = new int[N];
            for(int i = 0;i < N; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                xs[i] = input[0];
                ys[i] = input[1];
            }
            for(int i = 0; i < N; i++) {
                for (int j = 0;j < num; j++) {
                    double p = xs[i] * stdx[j] + ys[i] * stdy[j];
                    if(p < min[j]) {
                        min[j] = p;
                        minNum[j] = i;
                    } else if(p == min[j]) {
                        int k = minNum[j];
                        double dis1 = Math.Pow(xs[i], 2) + Math.Pow(ys[i], 2);
                        double dis2 = Math.Pow(xs[k], 2) + Math.Pow(ys[k], 2);
                        if(dis1 < dis2) {
                            minNum[j] = i;
                        }
                    }
                    if(p > max[j]) {
                        max[j] = p;
                        maxNum[j] = i;
                    } else if (p == max[j]) {
                        int k = maxNum[j];
                        double dis1 = Math.Pow(xs[i], 2) + Math.Pow(ys[i], 2);
                        double dis2 = Math.Pow(xs[k], 2) + Math.Pow(ys[k], 2);
                        if (dis1 < dis2) {
                            maxNum[j] = i;
                        }
                    }
                }
            }
            double[] P = new double[N];
            for(int i = 0; i < num; i++) {
                P[maxNum[i]]++;
                P[minNum[i]]++;
            }
            for(int i = 0; i < N; i++) {
                P[i] = P[i] / (num * 2);
                Console.WriteLine(P[i]);
            }
        }
    }
}

Measured memory_bytes: 17248
n=int(input())
a=[0]*n
x=[[0]*n for i in range(n)]
y=[[0]*n for i in range(n)]

for i in range(n):
  a[i]=int(input())
  for j in range(a[i]):
    x[i][j],y[i][j]=map(int,input().split())
    x[i][j]-=1
    
def check(honest):
  for i in range(n):
    if not honest[i]:
      continue
    for j in range(a[i]):
      if y[i][j]==1 and not honest[x[i][j]]:
        return 0
      if y[i][j]==0 and honest[x[i][j]]:
        return 0
  return 1

def dfs(honest):
  if len(honest)==n:
    if check(honest):
      return sum(honest)
    else:
      return 0
  return max(dfs(honest + [1]),
             dfs(honest + [0]))
 
print(dfs([]))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <cmath>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;

#define rep(i, m) for(ll i=0;i<(m);i++)
#define rep1(i, m) for(ll i=1;i<=(m);i++)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int L[20];

int maxval = 0;
int sum = 0;
int main() {
   int N;
   cin >> N;
   rep(i, N) {
      cin >> L[i];
      sum += L[i];
      maxval = max(L[i], maxval);
   }
   if (sum - maxval > maxval) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }
}

Measured memory_bytes: 888
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n]
    }

    let mut all_xor = a[0];
    for i in 1..n {
        all_xor ^= a[i];
    }

    for i in 0..n {
        print!("{}", a[i] ^ all_xor);

        if i != n - 1 {
            print!(" ");
        }
    }
    println!("");

    let mut ans = 0;
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 4212
n, m = map(int, input().split())

A = []
b = []
c = [0 for i in range(n)]

# input A
for _ in range(n):
    a = list(map(int, input().split()))
    A.append(a)
# input b
for _ in range(m):
    b.append(int(input()))

for i in range(n):
    for j in range(m):
        c[i] += A[i][j]*b[j]
    print(c[i])


Measured memory_bytes: 6016
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}

struct A{
    string s;
    int p;
    int order;
};
bool cmp(const A &a,const A &b){
    if(a.s==b.s){
        return a.p>b.p;
    }else{
        return a.s<b.s;
    }
}

int main(){
    int A,P;
    cin  >> A>>P;
    int piece=A*3 +P;

    cout << piece/2 <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h1, m1, h2, m2, k;
  cin>>h1>>m1>>h2>>m2>>k;
  int t1 = h1*60 + m1;
  int t2 = h2*60 + m2;
  int a = t2 - t1;
  cout<<abs(k-a);
}
  

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int b[111];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
        scanf("%d",&b[i]);
    for(int i=2;i<n;i++)
        ans+=min(b[i],b[i-1]);
    ans+=b[1]+b[n-1];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const ll mod = 1e9 + 7;
const int N = 1e5 + 10;
ll a[N], b[N], c[N], f[N], g[N], pref[N], suf[N];

ll binpow(ll x, ll y) {
    ll res = 1;
    while (y) {
        if (y & 1) {
            res = res * x % mod;
        }
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll x) {
    return binpow(x, mod - 2);
}

ll C(ll n, ll k) {
    if (k > n) return 0;
    return (f[n] * g[k] % mod) * g[n-k] % mod;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    f[0] = g[0] = 1;
    for (ll i=1; i<=N-1; i++) {
        f[i] = f[i-1] * i % mod;
        g[i] = inv(f[i]);
    }
    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    int m = 0;
    b[0] = 1e18;
    for (int i=1; i<=n; i++) {
        if (a[i] == b[m]) {
            c[m]++;
        }
        else {
            b[++m] = a[i];
            c[m] = 1;
        }
    }
    pref[1] = c[1];
    for (int i=2; i<=m; i++) {
        pref[i] = pref[i-1] + c[i];
    }
    suf[m] = c[m];
    for (int i=m-1; i>=1; i--) {
        suf[i] = suf[i+1] + c[i];
    }
    ll x = 0, y = 0;
    for (int i=1; i<=m; i++) {
        x += (C(pref[i], k) - C(pref[i-1], k)) * b[i];
        x %= mod;
    }
    for (int i=m; i>=1; i--) {
        y += (C(suf[i], k) - C(suf[i+1], k)) * b[i];
        y %= mod;
    }
    ll ans = (x - y) % mod;
    cout << (ans % mod + mod) % mod << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 5504
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

struct obj 
{
    ll x, y ;
    char c;
}
;
ve(obj) p;

double foo(double val)
{
    double xmin = 1e12 ,  xmax = -1e12  , ymax =  -1e12 , ymin = 1e12;
    f(i,0,p.size())
    {
        double xx = p[i].x ;double yy= p[i].y;
        if(p[i].c == 'U')
        {
            yy +=val;
        }
        if(p[i].c == 'D')
        {
            yy -=val;
        }
        if(p[i].c == 'L')
        {
            xx -=val;
        }
        if(p[i].c == 'R')
        {
            xx +=val;
        }
        xmin = min(xmin , xx);
        xmax = max(xmax , xx);
        ymin = min(ymin , yy);
        ymax = max(ymax , yy);
    }
    return (xmax- xmin)*(ymax - ymin);

}

double ternary_Search(int n)
{
    double lo = 0 ; double hi = 2e8;
    f(i,0,500)
    {
        // dbg2(lo,hi)
        double m1 = (lo*2+hi) /3;
        double m2 = (lo+2*hi) /3;
        // dbg2(m1,m2)
        if(foo(m1) <foo(m2)) hi  = m2;
        else lo = m1;
    }
    return foo(lo);
}

// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(n)
    
    p.resize(n);
    f(i,0,n)
    {
        cin>>p[i].x>>p[i].y>>p[i].c;
    }
    double ans = ternary_Search(n);
    cout<<fixed<<setprecision(18)<<ans;
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 2560
import sys

def MultiBurger(n,x):
    """
    レベルnバーガーの下からx枚に含まれるパティの量を計算する関数
    nBurger = 0 + n-1Burger + 1 + n-1Burger + 0
    0Burger = 1
    b=0
    p=1
    """
    sum=( 1<<n+2 )-3
    #sum: 総数
    middle=( 1<<n+1 )-1
    #middle: 真ん中のパティの番号
    num=(middle-1)//2
    #num: 1レベル小さいバーガーのパティの数

    if n==0 and x==1:
        return 1
    elif x==1:
        return 0

    elif x<middle-1:
        return MultiBurger(n-1,x-1)
    elif x==middle-1:
        return num
    elif x==middle:
        return num+1
    elif middle<x<sum-1:
        return num+1+MultiBurger(n-1,x-middle)
    else:
        return num*2+1
    
INPUT=input().split()
N=int(INPUT[0])
X=int(INPUT[1])
Paty=MultiBurger(N,X)

print(Paty)

Measured memory_bytes: 3064
a = []
for i in range(3):
    a1, a2, a3 = map(int, input().split())
    a.append(a1)
    a.append(a2)
    a.append(a3)

n = int(input())

for j in range(n):
    b = int(input())
    for k in range(9):
        if a[k] == b:
            a[k] = 0
        
if a[0] == 0 and a[1] == 0 and a[2] == 0:
    print('Yes')
elif a[3] == 0 and a[4] == 0 and a[5] == 0:
    print('Yes')
elif a[6] == 0 and a[7] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[3] == 0 and a[6] == 0:
    print('Yes')
elif a[1] == 0 and a[4] == 0 and a[7] == 0:
    print('Yes')
elif a[2] == 0 and a[5] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[4] == 0 and a[8] == 0:
    print('Yes')
elif a[2] == 0 and a[4] == 0 and a[6] == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
import itertools
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
permute = list(map(list,list(itertools.permutations(range(1,n+1)))))


index_a = permute.index(a)
index_b = permute.index(b)
print(abs(index_a-index_b))

Measured memory_bytes: 15092
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
namespace fio {
	streambuf* in = cin.rdbuf();
	char bb[1000000], * s = bb, * t = bb;
#define gc() (s==t&&(t=(s=bb)+in->sgetn(bb,1000000), s==t)?EOF: *s++)
	inline int read() {
		int x = 0;
		char ch = gc();
		while (ch < 48)ch = gc();
		while (ch >= 48)x = x * 10 + ch - 48, ch = gc();
		return x;
	}
}using fio::read;
int n, k;
vector<int>road[100005];
int arr[100005], ans;
int dfs(int x, int dep) {
	int maxn = dep; for (int it : road[x])maxn = max(maxn, dfs(it, dep + 1));
	if (arr[x] - 1 && maxn - dep == k - 1)return ans++, 0; return maxn;
}
int main() {
	n = read(), k = read();
	arr[1] = 1, ans = read() != 1;
	for (int i = 2; i <= n; i++)road[arr[i] = read()].push_back(i);
	dfs(1, 0), cout << ans;
}


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

a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

a.sort()
b.sort()
if n % 2 == 0:
    mi = a[n//2-1] + a[n//2]
    ma = b[n//2-1] + b[n//2]
    print(ma - mi + 1)
else:
    mi = a[n//2]
    ma = b[n//2]
    print(ma - mi + 1)


Measured memory_bytes: 25396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
  int N, K, index;
  char S[10];
  char check;

  scanf("%d %s %d", &N, &S, &K);
  check = S[K-1];
  for (index < 0; index < N; ++index) {
    if (S[index] != check) S[index] = '*';
  }
  printf("%s\n", S);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

int N,M;
int** dp;

void func(){
	int codeTable[M];

	for(int i = 0; i < M; i++){
		scanf("%d",&codeTable[i]);
	}

	int num;//初期化
	dp[0][128] = 0;

	for(int count = 1; count <= N; count++){
		scanf("%d",&num);

		for(int i = 0; i <= 255; i++){
			if(dp[count-1][i] != BIG_NUM){
				for(int k = 0; k < M; k++){
                    int now;
                    now = i + codeTable[k];
					if(now > 255){
						dp[count][255] = min(dp[count][255],dp[count-1][i]+(num-255)*(num-255));
					}else if(now < 0){
						dp[count][0]  = min(dp[count][0],dp[count-1][i]+(num)*(num));
					}else{
						dp[count][now] = min(dp[count][now],dp[count-1][i] + (num-now)*(num-now));
					}
				}
			}
		}
	}

	int minimum = BIG_NUM;

	for(int i = 0; i <= 255; i++){
		minimum = min(minimum,dp[N][i]);
	}

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

}

int main(){

	dp = new int*[20001];
	for(int i = 0; i <= 20000; i++){
		dp[i] = new int[256];
	}

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		for(int i = 0; i <= N; i++){
			for(int k = 0; k <= 255; k++)dp[i][k] = BIG_NUM;
		}

		func();
	}

	return 0;
}


Measured memory_bytes: 23052
// B - Comparing Strings
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int a,b;

int solve(){
	int A= 0, B=0;
	rp(i,0,b) A = A*10 + a;
	rp(i,0,a) B = B*10 + b;
	return to_string(A) < to_string(B)? A:B;
}

int main(){
	cin>>a>>b;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def dfs(v):
    if dp[v] != 0: return dp[v]
    cnt = 0
    for i in g[v]:
        cnt = max(cnt, dfs(i) + 1)
    dp[v] = cnt
    return dp[v]

N, M = map(int, input().split())
dp = [0] * (N + 1)
g = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    g[x - 1].append(y - 1)

for i in range(N):
    dfs(i)

print(max(dp))

Measured memory_bytes: 115200
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rep2(i,a,b) for(int i = a; i >= b; i--)
#define die return 0;

using namespace std;

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;

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

int testcases;
testcases=1;
//cin>>testcases;

while(testcases--)
{
	char ch;
	cin>>ch;
	if(ch>='A'&&ch<='Z')
		cout<<'A'<<'\n';
	else
		cout<<'a'<<'\n';
}

return 0;
}


Measured memory_bytes: 3632
loop do

  num = gets.split(" ")
  h = num[0].to_i
  w = num[1].to_i

  if h == 0 && w == 0 then
    break
  end

  for i in 0..w-1
    print "#"  
  end

  print "\n"

  for i in 0..h-3
   print "#"  
    for j in 0..w-3
      print "."
    end
   puts "#"
  end  

  for i in 0..w-1
    print "#"  
  end

  print "\n"

  print "\n"

end

Measured memory_bytes: 8812
/////////////////////    答案    /////////////// 
/*
注意点：
1. 
*/
//----------------------自打1------------------ 
/*
#include<iostream>
using namespace std;
const int inf=0x3f3f3f3f;
long long cnt;
int a[50000010],l[25000010],r[25000010];
void merge(int a[],int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;++i){
		l[i]=a[left+i];
	}
	for(int i=0;i<n2;++i){
		r[i]=a[mid+i];
	}
	l[n1]=r[n2]=inf;
	int i=0,j=0;
	for(int k=left;k<right;++k){
		++cnt;
		if(l[i]<=r[j]){							//升(<)降(>),=控制稳定性 
			a[k]=l[i];
			++i;
		}else{
			a[k]=r[j];
			++j;
		}
	}
}
void mergesort(int a[],int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergesort(a,left,mid);
		mergesort(a,mid,right);
		merge(a,left,mid,right);
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	mergesort(a,0,n);
	for(int i=0;i<n;++i){
		cout<<a[i]<<" \n"[i==n-1];
	} 
	cout<<cnt<<endl;
	return 0;
} 
*/
//---------------------标准答案--------------------
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;++i){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;++i){
		R[i]=A[mid+i];
	}
	L[n1]=R[n2]=SENTINEL;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
		}
	}
}

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

int main(){
	int A[MAX],n,i;
	cnt=0;
	
	cin>>n;
	for(int i=0;i<n;++i) cin>>A[i];
	
	mergeSort(A,n,0,n);
	
	for(int i=0;i<n;++i){
		if(i) cout<<" ";
		cout<<A[i];
	} 
	cout<<endl;
	
	cout<<cnt<<endl;
	
	return 0;
} 


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

struct Edge{
	int cap,to,cost,rev;
	Edge(){}
	Edge(int c,int t,int st,int r) : cap(c), to(t), cost(st), rev(r) {}
};

void addEdge(vector<vector<Edge>>&g,int from,int to,int cap,int cost){
	g[from].push_back(Edge(cap,to,cost,g[to].size()));
	g[to].push_back(Edge(0,from,-cost,g[from].size()-1));
}

int minCostFlow(vector<vector<Edge>> g,int s,int t,int f,bool negative=false){
	//if( f == 0 ) return 0;

	typedef pair<int,int> P;
	const int n = g.size();
	int res = 0;
	vector<int> h(n),prevv(n),preve(n);
	const int inf = 1000000;
	while( f > 0 ){
		priority_queue<P,vector<P>,greater<P> > que;
		vector<int> dist(n,inf);
		dist[s] = 0;
		que.push(P(0,s));
		while( !que.empty() ){
			P p = que.top(); que.pop();
			int v = p.second;
			if ( dist[v] < p.first ) continue;
			if( v == t ) break;
			for(int i = 0 ; i < g[v].size() ; i++){
				auto &e = g[v][i];
				if( e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to] ){
					dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					que.push(P(dist[e.to],e.to));
				}
			}
		}
		if( dist[t] == inf ) return inf;
		for(int v = 0 ; v < n ; v++){
			h[v] += dist[v];
		}
		int d = f;
		for(int v = t ; v != s ; v = prevv[v]) 
			d = min(d,g[prevv[v]][preve[v]].cap);
		f -= d;
		res += d * h[t];
		for(int v = t ; v != s ; v = prevv[v] ){
			auto &e = g[prevv[v]][preve[v]];
			e.cap -= d;
			g[v][e.rev].cap += d;
		}
	}
	return res;
}

int mat[210][210];
int main(){
	int A,B,K;
	cin >> A >> B >> K;
	for(int u = 0 ; u < A ; u++){	
		string s;
		cin >> s;
		for(int v = 0 ; v < B ; v++){
			if( s[v] == '1' )
				mat[u][v]++;
		}
	}

	for(int u = 0 ; u < B ; u++){
		string s;
		cin >> s;
		for(int v = 0 ; v < A ; v++){
			if( s[v] == '1' )
				mat[v][u]++;
		}
	}
	vector<vector<Edge>> g(A+B+2);
	int S = g.size() - 1;
	int T = g.size() - 2;
	for(int i = 0 ; i < A ; i++)
		addEdge(g,S,i,1,0);
	for(int i = 0 ; i < B ; i++)
		addEdge(g,A+i,T,1,0);
	for(int i = 0 ; i < A ; i++)
		for(int j = 0 ; j < B ; j++){
			addEdge(g,i,A+j,1,mat[i][j]);
			//cout << i << " " << j << ": " << mat[i][j] << endl;
		}
	int l = 0, r = min(A,B);
	while( l != r ){
		int m = (l+r+1) / 2;
		if( minCostFlow(g,S,T,m) <= K ){
			l = m;
		}else{
			r = m-1;
		}
	}
	cout << l << endl;

	



}

Measured memory_bytes: 6104
n = int(input())
slist = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"

mat = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    mat[i] = list(map(int, input().split()))

for i in range(n):
    for j in range(i+1, n):
        for s in slist:
            if s == "N":
                next = list("263415")
            elif s == "E":
                next = list("421653")
            elif s == "S":
                next = list("513462")
            else:
                next = list("326154")

            tmp = [0] * 6
            for k, nex in enumerate(next):
                tmp[k] = mat[j][int(nex)-1]

            mat[j] = tmp

            if mat[i] == mat[j]:
                print("No")
                exit()

print("Yes")



Measured memory_bytes: 5664
#include <cstdio>

using namespace std;

int main()
{
    int a, b, c, x;
    scanf("%d %d %d %d", &a, &b, &c, &x);

    int cnt = 0;
    for (int i = 0; i <= a; i++)
        for (int j = 0; j <= b; j++)
            for (int k = 0; k <= c; k++)
                if (i * 500 + j * 100 + k * 50 == x)
                    cnt++;

    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
const double pi=acos(-1);
using namespace std;
int main()
{
    double a,b,x,angle,t;
    cin>>a>>b>>x;
    if(x>a*a*b/2)
    t=atan(2*(a*a*b-x)/(a*a*a));
    else
    t=atan((a*b*b)/(2*x));
    angle=(t*180)/pi;
    cout<<fixed<<setprecision(10)<<angle<<endl;
    return 0;
}


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

bool func(string S) {
    
    int N = S.length();
    string sub_s1 = S.substr(0,(N-1)/2);
    string sub_s2 = S.substr((N-1)/2 + 1,(N-1)/2 );

    int N1, N2;
    N1 = sub_s1.length();
    N2 = sub_s2.length();
    
    if(sub_s1 == sub_s2) return true;
    else return false;
    
    /*
    if(N1 == 1 && N2 == 1) {
        if(sub_s1 == sub_s2) return true;
        else return false;
    }
    else {
        if(func(sub_s1)) {
            // 左側が回文の場合
            if(func(sub_s2)) {
                // 右側も回文の場合
                return true;
            }
        }
        else return false;
    }
    */

    
    
    

}



int main() {
    string S;
    cin >> S;
    int N = S.length();

    if(N % 2 == 0) {
        cout << "No";
        exit(0);
    }

    if(func(S)) {
        cout << "Yes";
    }
    else {cout << "No";}

    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
static int result;
static List<int> s=new List<int>();
  static List<int> t=new List<int>();
  static int N;
  
    static void Main()
    {
      string st=Console.ReadLine();
      if(st[0]==st[1] && st[2]==st[3] && st[1]!=st[2]){      Console.WriteLine("Yes");return;}
      if(st[0]==st[2] && st[1]==st[3] && st[0]!=st[1]){ Console.WriteLine("Yes");return;}
      if(st[0]==st[3] && st[1]==st[2] && st[1]!=st[3]){ Console.WriteLine("Yes");return;}

      Console.WriteLine("No");
      
      
                    //Console.WriteLine(result.ToString());
    }

static void Read()
{
  string[] tmp=Console.ReadLine().Split(' ');
for(int i=0;i<N;i++){s.Add(int.Parse(tmp[i]));}
}
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,s1,s2,a[110];
int main()
{
	scanf("%d",&n);
	s1=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s1+=a[i];
	}
	scanf("%d",&m);
	s2=s1;
	while(m--)
	{
		int p,x;
		scanf("%d%d",&p,&x);
		if(x>=a[p-1]) s1+=x-a[p-1];
		else s1-=a[p-1]-x;
		printf("%d\n",s1);
		s1=s2;
	}
	return 0;
}

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx;
	int dy = ty - sy;
	for (int i = 0; i < dy; i++)
		cout << 'U';
	for (int i = 0; i < dx; i++)
		cout << 'R';
	for (int i = 0; i < dy; i++)
		cout << 'D';
	for (int i = 0; i < dx; i++)
		cout << 'L';
	cout << 'L';
	for (int i = 0; i < dy + 1; i++)
		cout << 'U';
	for (int i = 0; i < dx + 1; i++)
		cout << 'R';
	cout << 'D';
	cout << 'R';
	for (int i = 0; i < dy + 1; i++)
		cout << 'D';
	for (int i = 0; i < dx + 1; i++)
		cout << 'L';
	cout << 'U';
	return 0;
}


Measured memory_bytes: 256
lines = []
line = input()
s = line.split(' ')
entries = int(s[2]) + 2
for i in range(entries+1):
    lines.append(line.split(' '))
    if i < entries:
        line = input()

discounts = []
for idx, line in enumerate(lines):
    if idx == 0:
        A = line[0]
        B = line[1]
        M = line[2]
    elif idx == 1:
        refrigerators = line
    elif idx == 2:
        microwaves = line
    else:
        discounts.append(line)

ref_reg = int(10 ** 5)
for r in refrigerators:
    reg = int(r)
    if ref_reg > reg:
        ref_reg = reg

ref_mic = int(10 ** 5)
for m in microwaves:
    mic = int(m)
    if ref_mic > mic:
        ref_mic = mic

ref_min = ref_reg + ref_mic
for discount in discounts:
     d = int(refrigerators[int(discount[0])-1]) + int(microwaves[int(discount[1])-1]) - int(discount[2])
     if d < ref_min:
         ref_min = d       
         
print(ref_min)

Measured memory_bytes: 51844
Scanf.scanf "%d %d" (fun n k ->
    let m = 1_000_000_000 + 7 in
    let ( +@) a b = (a + b) mod m in
    let ( -@) a b = (((a - b) mod m) + m) mod m in
    let ( *@) a b = (a * b) mod m in
    let pow_mod a n =
        let rec loop r i acc =
            if i = 0 then acc else
            let acc = if i land 1 = 1 then acc *@ r else acc in
            loop (r *@ r) (i lsr 1) acc
        in
        loop a n 1
    in
    let a = Array.make (k + 1) 0 in
    for i = k downto 1 do
        let rec loop c acc =
            if c > k then acc else loop (c + i) (acc -@ a.(c))
        in
        let r = loop (i + i) (pow_mod (k / i) n) in
        a.(i) <- r
    done;
    let rec loop i acc =
        if i > k then acc else loop (i + 1) (acc +@ i *@ a.(i))
    in
    loop 1 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 6624
N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort()
F.sort(reverse=True)
l=-1
r=10**13
while r-l!=1:
    m=(l+r)//2
    x=0
    for i in range(N):
        x+=max(0,A[i]-m//F[i])
    if x<=K:
        r=m
    else:
        l=m
print(r)


Measured memory_bytes: 120652
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k;
ll n,m;
ll a,c;
ll ans=1;
ll gu=0,ki=0;

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		if(a%2==0)gu++;
		else ki++;
	}
	while(ki>=2){
		ki-=2;
		gu++;
	}
	if(ki==1)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 4992
import sys
from collections import deque, defaultdict
from itertools import combinations, permutations
from heapq import heapify, heappop, heappush

def solve():
    input = sys.stdin.readline
    N, D, A = map(int, input().split())
    M = [tuple(int(m) for m in input().split()) for _ in range(N)]
    M.sort()
    #print(M)
    HP = [0] * (N + 2)
    count = 0
    for i, m in enumerate(M):
        HP[i + 1] += HP[i]
        #print(HP)
        x, h = m
        right = x + 2 * D
        if HP[i + 1] < h:
            add = (h - HP[i + 1]) // A
            if (h - HP[i + 1]) % A > 0: add += 1
            small, large = i, N
            while large - small > 1:
                mid = (small + large) // 2
                if M[mid][0] > right: large = mid
                else: small = mid
            HP[i + 1] += add * A
            HP[small + 2] -= add * A
            count += add
    #print(HP)
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 74332
N = int(input())
T = list(map(int, input().split()))
M = int(input())
L = []
for _ in range(M):
    p, x = map(int, input().split())
    L.append([p, x])

for i in range(M):
    sum_num = 0
    for j in range(N):
        if L[i][0] - 1 == j:
            sum_num += L[i][1]
        else:
            sum_num += T[j]
    print(sum_num)


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

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    int n, cnt = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<int> p(n);
    REP(i, n) {
        cin >> p[i];
        if (p[i] != i + 1) {
            cnt++;
        }
    }

    cout << (cnt <= 2? "YES" : "NO") << "\n";
    return 0;
}

Measured memory_bytes: 256
from functools import reduce
n, *s = open(0).read().split()
u = []
for t in s:
    close_cnt = 0
    tmp = 0
    for c in t:
        tmp += (1 if c == '(' else -1)
        close_cnt = min(close_cnt, tmp)
    u.append((close_cnt, tmp - close_cnt))
M = 10**6 + 1
acc = 0
for a, b in sorted(u, key=lambda z: (- M - z[0] if sum(z)>= 0 else M - z[1])):
    if acc + a < 0:
        print("No")
        exit(0)
    else:
        acc += a + b
print(("No" if acc else "Yes"))

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n,m;
mat g;
mat d;

lli ans;

int main(){
  cin >> n >> m;
  d = g = mat(n,vll(n,INT_MAX));
  for(lli i = 0;i < m;i++){
    lli a,b,c;
    cin >> a >> b >> c;
    d[a-1][b-1] =
    d[b-1][a-1] =
    g[a-1][b-1] =
    g[b-1][a-1] = c;
  }
  for(lli i = 0;i < n;i++){
    d[i][i] = 0;
  }
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j < n;j++){
      for(lli k = 0;k < n;k++){
        d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
  for(lli i = 0;i < n;i++){
    for(lli j = i+1;j < n;j++){
      for(lli k = 0;k < n;k++){
        if(d[k][i]+g[i][j] == d[k][j]){
          m--;
          break;
        }
      }
    }
  }
  cout << m << endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> A(N + 1, vector<int>(3, 0));
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i][0] >> A[i][1] >> A[i][2];
        int dist = abs(A[i - 1][1] - A[i][1]) + abs(A[i - 1][2] - A[i][2]);
        int t = A[i][0] - A[i - 1][0];
        if ((t < dist) || ((t - dist) % 2 != 0))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

#define NIL -1

struct Point{
    int location;
    int x;
    int y;
};

bool asc_x(const Point& l, const Point& r) {
    return l.x < r.x;
}

bool asc_y(const Point& l, const Point& r) {
    return l.y < r.y;
}

struct Node{
    Point p;
    Node* left;
    Node* right;
};

class Tree{
private:
    Node* top;
    Node* AddNode(vector<Point>& P, int l, int r, int depth){
        if (l > r) return NULL;
        Node* N = new Node;
        int m = (l + r) / 2;
        if (depth % 2) {
            sort(P.begin() + l, P.begin() + r + 1, asc_y);
        } else {
            sort(P.begin() + l, P.begin() + r + 1, asc_x);
        }
        N->p = P[m];
        N->left  = AddNode(P, l    , m - 1, depth + 1);
        N->right = AddNode(P, m + 1, r    , depth + 1);
        return N;
    }
    void findNode(int s_x, int t_x, int s_y, int t_y,
                  Node* N, int depth, vector<int>& ans){
        if (N == NULL) return;
        if (s_x <= N->p.x && N->p.x <= t_x &&
            s_y <= N->p.y && N->p.y <= t_y) {
                ans.push_back(N->p.location);
            }
        if (depth % 2) {
            if (N->p.y <= t_y) {
                findNode(s_x, t_x, s_y, t_y, N->right, depth + 1, ans);
            }
            if (N->p.y >= s_y) {
                findNode(s_x, t_x, s_y, t_y, N->left , depth + 1, ans);
            }
        } else {
            if (N->p.x <= t_x) {
                findNode(s_x, t_x, s_y, t_y, N->right, depth + 1, ans);
            }
            if (N->p.x >= s_x) {
                findNode(s_x, t_x, s_y, t_y, N->left , depth + 1, ans);
            }
        }
    }
public:

    int MakeTree(vector<Point>& P){
        top = AddNode(P, 0, P.size() - 1, 0);
    }

    void find(int s_x, int t_x, int s_y, int t_y, vector<int>& ans){
        findNode(s_x, t_x, s_y, t_y, top, 0, ans);
    }
};

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

    int n;
    scanf("%d", &n);
    // cin >> n;
    vector<Point> P(n);

    for (int i = 0; i < n; i++) {
        // cin >> P[i].x >> P[i].y;
        scanf("%d %d", &P[i].x, &P[i].y);
        P[i].location = i;
    }
    Tree T;
    T.MakeTree(P);
    // T.display();
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s_x, t_x, s_y, t_y;
        // cin >> s_x >> t_x >> s_y >> t_y;
        scanf("%d %d %d %d", &s_x, &t_x, &s_y, &t_y);
        vector<int> ans;
        T.find(s_x, t_x, s_y, t_y, ans);
        sort(ans.begin(), ans.end());
        for (int j = 0; j < ans.size(); j++) {
            // cout << ans[j] << endl;
            printf("%d\n", ans[j]);
        }
        // cout << endl;
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 31332
<?php
    $input = trim(fgets(STDIN));
    
    $cnt = 0;
    $max = 0;
    $base = ["A","T","C","G"];

    foreach(str_split($input) as $a){
        if(in_array($a,$base,true)){
            $cnt++;
        }else{
            $cnt=0;
        }
        
        if($cnt > $max){
            $max = $cnt;
        }
    }

    echo $max;
?>


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    vector<int> A(3);
    set<int> b;
    rep(i,3){
        cin>>A[i];
        b.insert(A[i]);
    }
    if(b.size() == 2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 892
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	int n;
	cin>>n;
	set<string> s;
	char last = '1';
	while(n--) {
		string val;
		cin>>val;
		if(last =='1')last=val[0];
		if(last!=val[0]||s.count(val)==1) {
			cout<<"No";
			return;
		}
		last = val[(int)val.length()-1];
		s.insert(val);
	}
	cout<<"Yes";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int sum=0,n,a,maxn=0,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		sum+=a;
		maxn=max(maxn,a);
	}
	printf("%d",sum-maxn/2);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    int dif = b - a;
    int bt = 0;
    for (int i = 1; i <= dif; i++) {
        bt += i;
    }
    cout << bt - b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100][51000];
int main(){
    int n,m;
    cin>>n>>m;
    int c[m];
    for(int i=1;i<m+1;i++) cin>>c[i];
    for(int i=0;i<25;i++) fill(dp[i],dp[i]+51000,1000000000);
    dp[0][0]=0;
    for(int i=1;i<m+1;i++){
        for(int j=0;j<n+1;j++){
            if(j-c[i]<0) dp[i][j]=dp[i-1][j];
            else dp[i][j]=min(dp[i-1][j],dp[i][j-c[i]]+1);
        }

    }
    cout<<dp[m][n]<<endl;
}



Measured memory_bytes: 8096
#include<iostream>

int main(){
    int n = 0;

    std::cin >> n;
    n = n % 10;
    n = n % 10;
    if(n == 3){
        std::cout << "bon";
    }
    else if( n == 0 || n == 1 || n == 6 || n == 8){
        std::cout << "pon";
    }
    else{
        std::cout << "hon";
    }
    
    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  int k;
  cin >> k;

  vector<string> v;

  FOR (i, 0, s.size()) {
    FOR (j, 1, 10) {
      v.push_back(s.substr(i, j));
    }
  }

  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());

  cout << v[k - 1] << endl;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
int n,a[N],bc[N];ll ans,t;
ll cl(ll x) {return x>1?x*(x-1)>>1:0;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]),++bc[a[i]];
	for(int i=1;i<=n;++i) ans+=cl(bc[i]);
	for(int i=1;i<=n;++i) printf("%lld\n",ans-cl(bc[a[i]])+cl(bc[a[i]]-1));
	return 0;
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n,m;
    cin>>n>>m;
    vec<queue<ll>> a(n);
    REP(i,n){
        REP(j,m){
            ll aa;
            cin>>aa;
            a[i].push(aa);
        }
    }

    map<ll,ll> mp;
    ll ma=0;
    REP(i,n){
        ll v = a[i].front();
        mp[v]++;
        chmax(ma,mp[v]);
    }

    set<ll> st;
    ll ans=n;
    REP(i,m){
        auto it=mp.begin();
        while(it!=mp.end()){
            if(it->second==ma){
                st.insert(it->first);
                it=mp.erase(it);
            }else{
                it++;
            }
        }
        chmin(ans,ma);
        ma=0;
        bool flag=true;
        REP(j,n){
            if(st.find(a[j].front()) == st.end()){
                chmax(ma,mp[a[j].front()]);
                continue;
            }
            while(a[j].size() && st.find(a[j].front())!=st.end()) a[j].pop();
            if(a[j].empty()){
                flag=false;
                break;
            }
            mp[a[j].front()]++;
            chmax(ma,mp[a[j].front()]);
        }
        if(!flag) break;
    }
    cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

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

  if(k == 0){
    cout << 1 << '\n';
    return 0;
  }

  vector < vector < ll > > dp(MAXN, vector < ll > (105));
  vector < vector < ll > > p(MAXN, vector < ll > (105, 0));

  for(int i = 0; i <= k; i++){
    p[i][0] = 1;
    if(i < 105){
      dp[0][i] = 1;
      p[0][i] = 1;
    }
  }
  for(int i = 1; i <= k; i++){
    for(int j = 1; j <= n; j++){
      if(i - a[j] >= 1) dp[i][j] = p[i][j - 1] - p[i - a[j] - 1][j - 1] + mod;
      else dp[i][j] = p[i][j - 1];
      dp[i][j] %= mod;

      p[i][j] = (p[i - 1][j] + dp[i][j]) % mod;
    }
  }

  cout << dp[k][n] << '\n';
}


Measured memory_bytes: 170624
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
int mod = 1e9 + 7;
using namespace std;
int main(){
    int N;
    cin >> N;
    long ans = 1;
    for(int i = 1; i <= N; i++){
        ans = (ans * i) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256