akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, arr[200005], k;

bool check(ll x) {
	ll res = 0;
	FOR(i, 1, n) {
		res += (arr[i]+x-1)/x - 1;
		if (res > k) return 0;
	}
	return 1;
}

int main() {
	fastio; cin >> n >> k;
	FOR(i, 1, n) cin >> arr[i];
	ll lower = 0, upper = 1e9+1;
	while (upper - lower > 1) {
		ll mid = (upper + lower)/2;
		if (check(mid)) upper = mid;
		else lower = mid;
	}
	cout << upper;
}


Measured memory_bytes: 5176
#include <vector>
#include <iostream>
#include <algorithm>

#define int long long

signed main() {
  int n, k;
  std::cin >> n >> k;
  
  int a[n];
  
  for(int i = 0; i < n; i++)
    std::cin >> a[i];
  
  std::sort(a, a+n);
  
  int ans = 0;
  for(int i = 0; i < k; i++)
    ans += a[i];
  
  std::cout << ans << std::endl;
  return 0;
}


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

int c[3][3];
int a[3],b[3];

int main()
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin>>c[i][j];
        }
    }

    a[0] = 0;
    for (int i = 0; i < 3; i++)
    {
        b[i] = c[0][i] - a[0];
    }

    for (int i = 1; i < 3; i++)
    {
        a[i] = c[i][0] - b[0];
    }

    for (int i = 1; i < 3; i++)
    {
        for (int j = 1; j < 3; j++)
        {
            if(a[i] != c[i][j] - b[j]){
            cout << "No" << endl;
            return 0;
            }
        }

    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+10,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,k,t;
char a[maxn],b[maxn];
int main()
{
    int i,j;
  	//freopen("in.txt","r",stdin);
    scanf("%d%d%s%s",&n,&m,a,b);
    int c=n/__gcd(n,m);
    int d=m/__gcd(n,m);
    for(i=0,j=0;i<n&&j<m;i+=c,j+=d)
    {
        if(a[i]!=b[j])return 0*puts("-1");
    }
    printf("%lld\n",1LL*c*m);
  	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

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

    int w,h,k; cin>>h>>w>>k;

    int emptystart=0;
    vector<vi> ans;
    int id=0;
    FOR(i,h) {
        string s; cin>>s;

        vi berry;
        FOR(j,w)
            if(s[j]=='#')
                berry.push_back(j);

        if(berry.empty()) {
            if(i==emptystart)
                ans.push_back(vi()), emptystart++;
            else
                ans.push_back(ans.back());
            continue;
        }

        id++;
        ans.push_back(vi());

        FOR(j,w) {
            ans.back().push_back(id);
            if(s[j]=='#' && j!=berry.back())
                id++;
        }
    }
    FOR(i,emptystart)
        ans[i] = ans[emptystart];

    FOR(i,h) {
        FOR(j, w)
            cout<<ans[i][j]<<' ';
        cout<<endl;
    }


    return 0;
}



Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
 
#define For(i,n) for(int i = 0;i < n;i++)
#define Forini(i,s,n) for(int i = s;i < n;i++)
 
#define minusFor(i,n) for(int i = n-1;i >= 0;i--)
#define minusForend(i,n,s) for(int i = n-1;i >= s;i--)
 
const int INF = 10000000000;
 
using namespace std;

int main()
{
	
	int n,q;
	while(cin >> n >> q && (n || q))
	{

	int f[100];
	memset(f,0,sizeof(int)*100);

	for(int i = 0;i < n;i++)
	{
		int tmp1;
		cin >> tmp1;

		for(int j = 0;j < tmp1;j++)
		{
			int tmp2;
			cin >> tmp2;
			f[tmp2]++;
		}
	}

	int k = 0;
	int Max = -1;

	for(int i = 0;i < 100;i++)
	{
		if(q <= f[i] && Max < f[i])
		{
			k = i;
			Max = f[i];
		}

	}


		cout << k << endl;
	


	}

	return 0;
}
 

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

int main() {
  long n,baseans=0;
  cin >> n;
  map<long,long> b;
  vector<long> a(n);
  for(long i=0;i<n;i++) {
    cin >> a[i];
    b[a[i]-1]++;
    baseans+=b[a[i]-1]-1;
  }
  for(long i=0;i<n;i++) {
    long ans;
    ans=baseans-b[a[i]-1]+1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 11008
def f(line)
  a, b, c, d, e, f = line.split(" ").map(&:to_f)
  y = (a * f - d * c) / (a * e - d * b)
  x = (c - b * y) / a
  sprintf("%.3f %.3f", x, y)
end

while line = gets
  puts f(line)
end

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


int main(){
    int h,a,ans;

        cin>> h >> a;
        if(h<a)ans = 1;
        else{
        if(h%a==0)ans = h/a;
        else ans = (h/a)+1;
        }

            cout<< ans <<endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl

( my $s = <STDIN> ) =~ s/[\x00-\x20]+$//io;

my $n = 0;
for(my $i=0;$i<4;$i++){
  $n++ if substr($s,$i,1) eq '+';
  $n-- if substr($s,$i,1) eq '-';
}
print "$n\n";



Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int t[6],a[6],i,ans=0,sum=9,poss=1;
    for(i=1; i<=5; i++)
        cin>>t[i];
    for(i=1; i<=5; i++)
    {
        a[i]=t[i]%10;
        if(a[i]<sum&&a[i]!=0)
        {
            sum=a[i];
            poss=i;
        }
    }
    for(i=1; i<=5; i++)
    {
        if(i!=poss)
        {
            if(a[i]!=0)
                ans=ans+t[i]+10-a[i];
            else
                ans=ans+t[i];
        }
    }
    ans=ans+t[poss];
    cout<<ans;
    return 0;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	ll n, d;
	cin >> n >> d;
	int cnt = 0;
	rep(i, n) {
		ll x,y;
		cin >> x >> y;
		if (d * d >= (x * x + y * y)) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3632
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

N = int(input())
RES = dict()
RES["AC"] = 0
RES["WA"] = 0
RES["TLE"] = 0
RES["RE"] = 0
for i in range(N):
    s = input()
    RES[s] += 1
for key,value in RES.items():
    print(key,"x",value)

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

#define DEBUG 1
#define NINF -1
#define PINF 1E9+1

#define RENGE 256UL

unsigned long x,y;
unsigned long ans;

int main()
{
	int i,j;
	
	scanf("%lu %lu",&x,&y);

	ans = 0LU;

	if (x<=3) ans += (4-x)*100000;
	if (y<=3) ans += (4-y)*100000;
	if (x+y==2) ans += 400000;
	
	printf("%lu\n",ans);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String args[]) {
	Scanner sc = new Scanner(System.in);
    
    int A1 = sc.nextInt();
    int A2 = sc.nextInt();
    int A3 = sc.nextInt();
    
    if (A1 + A2 + A3 >= 22) {
      System.out.println("bust");
    } else {
      System.out.println("win");
    }
  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  } else if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  } else {
    cout << "error" << endl;
  }
}

Measured memory_bytes: 3564
#include <stdio.h>

int main(int argc, char *argv[])
{
    long long count;
    int i, delta;
    char s[200001];
    int s_len;
    int b_count;
 
    scanf("%s", s);
    
    count = 0;

    b_count = 0;
    for (i = 0; s[i] != 0; i++) {
        if (s[i] == 'B') {b_count++;}
    }
    s_len = i;
    for (i--; i > 0; i--) {
        while(s[i] == 'B') {
            b_count--;
            i--;
        }
        count += b_count;
    }

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

    return 0;
}

Measured memory_bytes: 384
s=input()
t=input()
n=len(s)
m=len(t)
ind=-1
for i in range(n-m+1):
  f=0
  for j in range(m):
    c=s[n-i-1-j]
    if t[m-1-j]!=c and c!='?':
      break
    else:
      f+=1
  if f==m:
    ind=i
    break

if ind==-1:
  print("UNRESTORABLE")
else:
  s=s[:n-ind-m]+t+s[n-ind:]
  s=s.replace('?','a')
  print(s)

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef array<LL,2> A;

const int L=200000+1;
LL a[L];
LL up[L];
LL dn[L];
int N;
LL t[L];
void f()
{
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			t[j]=a[j];
		}
		{
		int b=0;
		if(i-1>=0){
			t[i-1]*=-2;
			b++;
			for(int k=i-2;k>=0;k--){
				while(t[k]>t[k+1]){
					t[k]*=-2;
					b++;
				}
			}
			if(dn[i-1]+i!=b){
				cerr << i << ", " << dn[i-1] << ", " << b << endl;
				for(int k=0;k<N;k++){
					cerr << t[k] << endl;
				}
			}
			assert(dn[i-1]+i==b);
		}
		}
		{
		int b=0;
		for(int k=i+1;k<N;k++){
			while(t[k-1]>t[k]){
				t[k]*=-2;
				b++;
			}
		}
		if(up[i]!=b){
			cerr << i << ", " << b << ", " << up[i] << endl;
			for(int k=0;k<N;k++){
				cerr << t[k] << endl;
			}
		}
		assert(up[i]==b);
		}
	}
}
int main() {
#if 1
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
#else
	N=10;
	mt19937 mt(100);
	uniform_int_distribution<> dist(0,5);
	for(int i=0;i<N;i++){
		a[i]=dist(mt);
		cerr << a[i]+1;
	}
	cerr << "aaa" << endl;
#endif
	vector<A> p;
	p.push_back(A{{1LL<<60,1}});
	for(int i=N-2;i>=0;i--){
		up[i]=up[i+1];
		if(a[i]<=a[i+1]){
			int c=0;
			LL v=a[i];
			while(4*v<=a[i+1]){
				v*=4;
				c++;
			}
			if(c==0){
				p.back()[1]++;
			}
			else{
				p.push_back(A{{c,1}});
			}
		}
		else{
			LL v=a[i+1];
			while(a[i]>v){
				v*=4;
				p.back()[0]--;
				up[i]+=2*p.back()[1];
				if(p.back()[0]==0){
					int s=p.back()[1];
					p.pop_back();
					p.back()[1]+=s;
				}
			}
			p.back()[1]++;
		}
	}
	p.clear();
	p.push_back(A{{1LL<<60,1}});
	for(int i=1;i<N;i++){
		dn[i]=dn[i-1];
		if(a[i]<=a[i-1]){
			int c=0;
			LL v=a[i];
			while(4*v<=a[i-1]){
				v*=4;
				c++;
			}
			/*
			if(i==1){
				cerr << c << endl;
			}
			*/
			if(c==0){
				p.back()[1]++;
			}
			else{
				p.push_back(A{{c,1}});
			}
		}
		else{
			LL v=a[i-1];
			while(a[i]>v){
				v*=4;
				p.back()[0]--;
				dn[i]+=2*p.back()[1];
				/*
				if(i==2){
					cerr << "aaa " << p.back()[0] << ", " << p.back()[1] << ", " << p.size () << endl;
				}*/
				if(p.back()[0]==0){
					int s=p.back()[1];
					p.pop_back();
					p.back()[1]+=s;
				}
			}
			p.back()[1]++;
		}
		//cerr << i << ": " << dn[i] << endl;
	}
	LL ret=up[0];
	//cerr << up[0] << endl;
	for(int i=1;i<N;i++){
		//cerr << i+dn[i-1] << ", " << up[i] << endl;
		ret=min(ret,i+dn[i-1]+up[i]);
	}
	ret=min(ret,N+dn[N-1]);
	//f();
	cout << ret << endl;

	return 0;
}



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

int main() {
    int N, M, N_max=0, M_max=0, max;
    cin >> N;
  	vector<string> N_s(N);  
  	for(int i=0;i<N;i++){
    	cin >> N_s.at(i);
    }
  	cin >> M;
  	vector<string> M_t(M);
  	for(int i=0;i<M;i++){
    	cin >> M_t.at(i);
    }
  	for(int i=0;i<N;i++){//
      	int cnt = 0;
		for(int j=0;j<N;j++){//
        	if(N_s.at(i)==N_s.at(j)){//
            	cnt++;
            }
        }
     	for(int j=0;j<M;j++){
			if(M_t.at(j)==N_s.at(i))cnt--;
    	}
      	if(i==0){
          	N_max=cnt;
        }
      	else if(cnt>N_max){
          	N_max = cnt;
        }
    }
  
  	for(int i=0;i<M;i++){//
      	int cnt = 0;
		for(int j=0;j<M;j++){//
        	if(M_t.at(i)==M_t.at(j)){//
            	cnt--;
            }
        }
     	for(int j=0;j<N;j++){
			if(N_s.at(j)==M_t.at(i))cnt++;
    	}
      	if(i==0){
          	M_max=cnt;
        }
      	else if(cnt>M_max){
          	M_max = cnt;
        }
    }
  	if(M_max > N_max)max = M_max;
  else max=N_max;
  	if(max<0)max = 0;
    cout << max << endl;
}


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

int A,B,C;

int main(){
  cin >> A >> B >> C;
  if(max(A,max(B,C)) == A) cout << A*10 + B + C;
  else if(max(A,max(B,C)) == B) cout << B*10 + A + C;
  else cout << C*10 + A + B;
}

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



int main() {
    ll N, K; cin >> N >> K;
    vector<pair<int, int>> V(N);
    for(int i = 0; i < N; i++){
        int a, b; cin >> a >> b;
        V[i] = make_pair(a, b);
    }
    sort(V.begin(), V.end());
    ll cnt=0;
    for(auto v : V){
        int a = v.first;
        int b = v.second;
        cnt += b;
        if(K <= cnt){
            cout << a << endl;
            return 0;
        }
    }
}

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

int main(){
  int n;
  scanf("%d",&n);
  if(n <= 9) printf("%d",n);
  else if(n <= 99) printf("9");
  else if(n <= 999) printf("%d",n-99+9);
  else if(n <= 9999) printf("909");
  else if(n <= 99999) printf("%d",n-9999+909);
  else printf("90909");
  return 0;
}


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

int main(){
    int K, A, B; cin >> K >> A >> B;
    for(int i = A; i <= B; i++){
        if (i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3592
def dfs(node, paths, visited, n):
  # 全て訪問済みだったら全部を訪問できる経路として1を返す
  if not False in visited:
    return 1

  count = 0

  for nn in paths[node]:
    # 既に訪問済みなら処理をしない
    if(visited[nn]):
      continue

    visited[nn] = True
    count += dfs(nn, paths, visited, n)
    visited[nn] = False

  return count

def main():
  N, M = list(map(int, input().split()))
  paths = [[] for i in range(N)]
  visited = [False] * N

  for i in range(M):
    a, b = list(map(int, input().split()))
    paths[a-1].append(b-1)
    paths[b-1].append(a-1)

  visited[0] = True
  print(dfs(0, paths, visited, N))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int64_t solve(vector<int64_t>& a) {
    int64_t res = 0;
    int64_t sum = 0;
    for (int64_t i = 0; i < a.size(); ++i) {
        if (i % 2 == 0) {
            if (sum + a[i] <= 0) {
                res += abs(sum + a[i] - 1);
                sum = 1;
            } else {
                sum += a[i];
            }
        }
        else {
            if (sum + a[i] >= 0) {
                res += abs(sum + a[i] + 1);
                sum = -1;
            } else {
                sum += a[i];
            }
        }
    }

    return res;
}

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(6
-1 4 3 2 -5 4
)");
#endif
    size_t n;
    in >> n;
    vector<int64_t> a(n);
    for (int i = 0; i < n; ++i) in >> a[i];

    int64_t ans = solve(a);
    for (int i = 0; i < n; ++i) a[i] *= -1;
    ans = min(ans, solve(a));
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int rmax = 200;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    
    int imax = 0;
	while (a) {
      if ((a % 2) == 0) {
        a /= 2;
        imax ++;
      } else {
        break;
      }
    }
    
    if (imax < rmax) {
      rmax = imax;
    }
  }
  
  cout << rmax << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, Y;
	cin >> N >> Y;
	Y /= 1000;

	REP(i, 2001) REP(j, 2001){
		ll k = N - i - j;
		if(k<0) continue;
		if(10*i+5*j+k==Y){
			printf("%d %d %d \n", i, j, k);
			return 0;
		}
	}
	cout << "-1 -1 -1" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 105;

const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    long long res = 0;
    for(int i = 1; i <= 1e7; i++){
        res = (res * 10 + 7) % n;
        if(res == 0){
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	bool flag=false;
	for(int i=0;i<n;++i)
		if(a[i]==1){
			flag=true;
			break;
		}
	if(flag==false){
		cout<<-1;
		return 0;
	}
	int cnt=0;
	int i=0,j=1;
	while(i<n){
		if(a[i]!=j)
			++cnt;
		else
			++j;
		++i;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010

bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll n,ans=0,maxp=0;
    cin  >> n;
    ll p[n];
    for (ll i=0;i<n;i++){
        cin >> p[i];
        maxp=max(maxp,p[i]);
        ans+=p[i];
    }
    cout << ans-(maxp/2) << endl;
    return 0;
}






Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt).filter { x -> x%2==0 }.all { x -> x%3==0 || x%5==0 }
    println(if (A) "APPROVED" else "DENIED")
}

Measured memory_bytes: 38016
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  ll n;
  cin >> n;
  ll ans = 0;

  for(ll i = 0; i < n;i++){
    ans += i;
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		long x = Long.parseLong(sc.next());
		sc.close();
		long sum = x / 11 * 2;
		x %= 11;
		if(x > 0){
			sum++;
			x -= 6;
		}
		if(x > 0){
			x -= 5;
			sum++;
		}
		ou.println(sum);
		ou.flush();
    }
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll a, b = 0; cin >> a;
  string s; cin >> s;
  for (char &ch: s) {
    if (ch == '.') continue;
    b = b*10 + ch-'0';
  }
  cout << a*b/100;
  return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n,k,sum,a[200500];
	cin>>k>>n;
	long long max=0,po; 
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<n;i++)
	{
		long long t=a[i]-a[i-1];
		if(t>max) max=t,po=i;
	}
	if((k-a[n-1])+a[0] > max) po=0;
	if(po!=0)
	{
		sum=k-a[po]+a[po-1];
	}
	else sum=a[n-1]-a[0];
	cout<<sum;
	return 0;
 } 


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

  int n, m;
    int k[10];
    int p[10];
    int s[10][10];
    int ans=0;


  void dfs(int S, int d){
    if(d!=n){
      dfs((S|(1<<d)), d+1);
      dfs(S, d+1);
      return;
    }
    else{
      REP(i, m){
        int c=0;
        REP(j, k[i]){
          if(((S>>(s[i][j]-1))&1)==1) ++c;
        }
        if(c%2!=p[i]) return;
      }
      ++ans;
      return;
    }
  }

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

  REP(i, m)REP(j, 10) s[i][j]=0;
  REP(i, m){
    cin>>k[i];
    REP(j, k[i]){
      cin>>s[i][j];
    }
  }

  REP(i, m) {
    cin>>p[i];
  }
  dfs(0, 0);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
/* 
 Author:N_o_o_B 
 Created:November 26 2019 21:12:01
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    ll n,m,d;
    cin >> n >> m >> d;
    ld mul=2.00;
    if(d==0) mul=1;
    cout << (n-d)*mul/(n*n)*(m-1) << endl;

    time_taken();
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int res = 0;
    for(int i = a;i <= b;i++){
        if(i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  long long a,b;cin>>a>>b;
  if ((a+b)%2==0) {
    cout<<(a+b)/2<<endl;
  }
  else {
    cout<<"IMPOSSIBLE"<<endl;
  }
}


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

const int maxn = 1e5+10, MOD = 1e9+7;

int N, K;

long long P(int n, int k) {
	if (n < k) return 0;
	long long ans = 1;
	for (int i = 0; i < k; ++i) {
		ans = ans*(n-i)%MOD;
	}
	return ans;
}

struct graph{
	vector<int> e[maxn];
	long long f[maxn];
	void add(int u, int v) {
		e[u].push_back(v);
	}
	void add2(int u, int v) {
		add(u, v), add(v, u);
	}
	int dfs(int u, int fa) {
		f[u] = 1;
		for (int i = 0; i < e[u].size(); ++i) {
			int v = e[u][i];
			if (v == fa) continue;
			dfs(v, u);
			f[u] = f[u]*f[v]%MOD*P(K-2, e[v].size()-1)%MOD;
		}
		return P(K-1, e[u].size())*f[u]%MOD*K%MOD;
	}
}g;

int main() {
	scanf("%d%d", &N, &K);
	int u, v;
	for (int i = 1; i < N; ++i) {
		scanf("%d%d", &u, &v);
		g.add2(u, v);
	}
	printf("%d", g.dfs(1, 0));
}


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

L=list(map(int,input().split()))
L.sort()

# print(L)

ntri=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i] < L[j]:
            Lij = L[i]+L[j]
            for k in range(j+1, N):
                if L[j]<L[k] and Lij>L[k]:
                    ntri+=1

print(ntri)
                    

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  bitset<200005> bs;

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

  for(int i=n/2; i>=1; i--) {
    int tmp = i+i;
    while(tmp <= n) {
      bs[i] = (bs[i]^bs[tmp]);
      tmp += i;
    }
  }

  cout << bs.count() << endl;
  if (bs.count() == 0) return 0;
  for(int i=1; i<=n; i++) {
    if (bs[i]) {
      cout << i << ' ';
    }
  }
  cout << endl;

}

Measured memory_bytes: 1152
<?php
fscanf(STDIN, '%d %d', $n, $q);
for ($i  = 0; $i < $n - 1; $i++) {
    fscanf(STDIN, '%d %d', $a, $b);
    $a--;
    $b--;
    $g[$a][] = $b;
}
$r = array_fill(0, $n, 0);
for ($i  = 0; $i < $q; $i++) {
    fscanf(STDIN, '%d %d', $p, $x);
    $r[$p - 1] += $x;
}
$point = array_fill(0, $n, 0);
dfs($g, 0, 0, $r, $point);
$ans = implode(' ', $point);
echo $ans . PHP_EOL;

function dfs($g, $v = 0, $x = 0, $r, &$point) {
    if (isset($r[$v])) $x += $r[$v];
    $point[$v] += $x;

    if (!isset($g[$v])) return;
    foreach ($g[$v] as $next_v) {
        dfs($g, $next_v, $x, $r, $point);
    }
}

Measured memory_bytes: 176632
import java.util.Scanner;

public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int D = sc.nextInt();
      
      if((A * B) > (C * D)){
      System.out.println(A * B);
      }else{
      System.out.println(C * D);
      }
   }
}

Measured memory_bytes: 23124
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N, M = map(int, input().split())
    quantity = [1] * N
    red = [True] + [False] * (N - 1)

    for i in range(M):
        x, y = map(int, input().split())
        quantity[x - 1] -= 1
        quantity[y - 1] += 1
        if red[x - 1] == True:
            red[y - 1] = True

        if quantity[x - 1] == 0:
            red[x - 1] = False
    print(red.count(True))


resolve()

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

const int MAXN = 100005;

int N;
vector <int> ch[MAXN];

int dfs(int x) {
  vector <int> tmp;
  for (int i = 0; i < ch[x].size(); i++)
    tmp.push_back(dfs(ch[x][i]));
  sort(tmp.begin(), tmp.end());
  int mx = 0;
  for (int i = 0; i < tmp.size(); i++)
    mx = max(mx, tmp[i] + (int)tmp.size() - i);
  return mx;
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    int p;
    scanf("%d", &p);
    ch[--p].push_back(i);
  }
  
  printf("%d\n", dfs(0));
  
  return 0;
} 

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

int main() {
	int N;
	cin >> N;
	int P[N], Q[N], R[N];
	for (int i=0;i<N;i++) cin >> P[i];
	for (int i=0;i<N;i++) cin >> Q[i];
	for (int i=0;i<N;i++) R[i]=i+1;
	int a=0, b=0, cnt=0;
	do {
		bool flag = true;
		for (int i=0;i<N;i++) if (R[i]!=P[i]) flag = false;
		if (flag) a = cnt;

		flag = true;
		for (int i=0;i<N;i++) if (R[i]!=Q[i]) flag = false;
		if (flag) b = cnt;

		cnt++;
	} while (std::next_permutation(R, R+N));
	cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val N = sc.nextInt()
    val K = sc.nextInt()
    val P = (1..N).map { sc.nextInt() + 1 }

    var n = P.subList(0, K - 1).sum()
    val r = (0..(N - K)).map { i ->
        n += P[i + K - 1]
        val nn = n
        n -= P[i]
        nn
    }

    val result = r.max()!!.toDouble() / 2
    println(result)
}


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

int main(void) {
  int n, sum = 0;
  cin >> n;
  vector <int> l(n);
  for(int i = 0;i < n;i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  for(int i;i < n - 1;i++) {
    sum += l.at(i);
  }
  if(l.at(n-1) < sum) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100010;
int n,a[N],rak[N];
ll ans[N];
int cmp(int aa,int bb){
	if(a[aa]==a[bb]) return aa>bb;
	return a[aa]>a[bb];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=0;i<=n;i++) rak[i]=i;
	sort(rak,rak+n+1,cmp);
	int now,nxt=0;
	ll tot1=0,tot2=0;
	while(nxt<n){
		now=nxt;
		while(rak[nxt]>=rak[now]) tot1+=a[rak[nxt]],nxt++,tot2++;
		ans[rak[now]]+=tot1-tot2*a[rak[nxt]];
		tot1=tot2*a[rak[nxt]];
	}
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

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

int main(){
  
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0;i<n;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  
  for(int j=1;j<n;j++){
    v.at(j)=(v.at(j-1)+v.at(j))/2;
  }
  
  cout << fixed << setprecision(6);
  cout << v.at(n-1) << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [input() for _ in range(H)]
A = []
for _ in range(H):
    A.append([0]*W)
B = [(1,0),(0,1),(-1,0),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            A[i][j] = "#"
for i in range(H):
    for j in range(W):
        if A[i][j] != "#":
            for dx,dy in B:
                if 0<=j+dx<=W-1 and 0<=i+dy<=H-1:
                    if A[i+dy][j+dx] == "#":
                        A[i][j] += 1
for i in range(H):
    for j in range(W):
        print(A[i][j], end = "")
    print("")

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = a - (b < a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
import bisect

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

SA = [0] + list(accumulate(A))
SB = [0] + list(accumulate(B))

max_count = 0
for i in range(N + 1):
    a_count = i
    b_count = bisect.bisect_right(SB, K - SA[a_count]) - 1
    if b_count >= 0:
        count = a_count + b_count
        if count > max_count:
            max_count = count
        
print(max_count)

Measured memory_bytes: 50680
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

ll p[10000001];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n, k;

  cin >> n >> k;
  
  REP(i, n) cin >> p[i];

  SORT(p, n);
  
  ll ans = 1e12;

  REP(i, n-k+1){
    //cout << ans << endl;    
    ans = std::min(ans, (p[k-1+i] - p[i]));
  }

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



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

using namespace std;

int main() {
	int n, k; scanf("%d %d", &n, &k);
	vector<pair<int, int>> elist;
	if ((n - 1) * (n - 2) / 2 < k) {
		printf("-1\n");
		return 0;
	}
	for (int i = 1; i < n; ++i) {
		elist.emplace_back(0, i);
	}
	k = (n - 1) * (n - 2) / 2 - k;
	for (int i = 1; i < n; ++i) {
		for (int j = 1; j < i; ++j) {
			if (k > 0) {
				elist.emplace_back(j, i);
				--k;
			}
		}
	}
	printf("%lu\n", elist.size());
	for (auto pp : elist) {
		printf("%d %d\n", pp.first + 1, pp.second + 1);
	}
	return 0;
}


Measured memory_bytes: 384
# ABC166 B
n,k = map(int, input().split())
# お菓子を持っているすぬけ君かを判断する配列d 1ならもってる 0はもってない
d = [0] * n
# お菓子iを持っているのはどのすぬけ君か？
for i in range(k):
    # お菓子iを持っている人数m人
    m = int(input())
    # お菓子iを持っているすぬけ君のリスト
    a = list(map(int, input().split()))
    for j in range(m):
        # すぬけ君a[j]は少なくとも一つ以上のお菓子を持っている
        d[a[j]-1] = 1 
        
#いたずらされる人数ans人
ans = 0
for i in range(n):
    if d[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N;cin>>N;
    if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9)cout<<"hon"<<endl;
    if(N%10==0||N%10==1||N%10==6||N%10==8)cout<<"pon"<<endl;
    if(N%10==3)cout<<"bon"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;

    vector<int> x;
    vector<int> d;
    int ans = 0;

    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        x.push_back(k);
    }
    sort(x.begin(),x.end());

    for(int i = 0; i < m - 1; i++)d.push_back(x[i+1] - x[i]);
    sort(d.rbegin(),d.rend());
    for(int i = n - 1; i < d.size(); i++)ans += d[i];
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    std::vector<int> as(3);
    for (auto &a: as) std::cin >> a;

    std::sort(as.begin(), as.end());
    
    for (int i = 0; i < 3; ++i) {
        std::cout << as[i] << (i + 1 == 3 ? "\n" : " ");
    }
}



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

const int N = 2000;
const int M = N*N + 2;
int A[N];

void solve() {
   int n;
   scanf("%d",&n);
   int sum = 0;
   bitset<M> s;
   s[0]= 1;
   for(int i=0;i<n;++i) {
      scanf("%d",&A[i]);
      sum += A[i];
      s |= (s<<A[i]);
   }
   sum= (sum+1)/2;
   for(int i= sum;i<M;++i) {
      if(s[i]==1) {
         printf("%d\n", i);
         break;
      }
   }
   
}
int main() {
   //freopen("input.txt","r",stdin);
   solve();
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<pair<int, int>> x;
    for (int i = 0; i < n; ++i) {
      int y;
      cin >> y;
      x.push_back(make_pair(y, i));
    }
    sort(x.begin(), x.end());

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      if (i < n/2) {
        a[x[i].second] = x[n / 2].first;
      } else {
        a[x[i].second] = x[n / 2 - 1].first;
      }
    }

    each (i, a) cout << i << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4592
/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 16 August 2020 12:24:48 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int x,k,d;
    cin>>x>>k>>d;

    int t = (abs(x))/d;
    //cout<<t<<endl;
    if(t < k ){
        if( (k-t)%2 == 0){
            int pos = min({abs(x-t*d),abs(x+t*d)});
            cout<<pos<<endl;
            return;
        }
        else{
            int pos = min({abs(x-(t+1)*d),abs(x+(t+1)*d),abs(x-(t-1)*d),abs(x+(t-1)*d)});
            cout<<pos<<endl;
        }
    }else{
        cout<<min({abs(x-k*d),abs(x+k*d)})<<endl;
        return;
    }
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    COMinit();
    int n,m,k;
    long long x=0,y=0,z,d,nn,mm,kk;
    cin >> n >> m >> k;
    z=COM(n*m-2,k-2); nn=n; mm=m; kk=k;
    for(d=1;d<n;d++) x=(x+(((d*(nn-d)%MOD)*mm%MOD)*mm%MOD))%MOD;
    for(d=1;d<m;d++) y=(y+(((d*(mm-d)%MOD)*nn%MOD)*nn%MOD))%MOD;
    cout << ((x+y)%MOD)*z%MOD << endl;
}

Measured memory_bytes: 12160
#include<stdio.h>
struct CARD{
	char color;
	int num;
};
void bubbleSort(struct CARD A[],int N);
void selectSort(struct CARD A[],int N);
void trace(struct CARD A[],int N);
void isStable(struct CARD input[],struct CARD output[],int N);

int main(void)
{
	struct CARD A[36],B[36],C[36];
	int N;
	int i; 
	
	scanf("%d",&N);
	getchar();
	for (i=0;i<N;i++){
		scanf("%c%d",&A[i].color,&A[i].num);
		getchar();
	}
	for (i=0;i<N;i++)B[i]=C[i]=A[i];
	
	bubbleSort(B,N);
	trace(B,N);
	isStable(A,B,N);
	
	selectSort(C,N);
	trace(C,N);
	isStable(A,C,N);
	
	return 0;
	
}

void bubbleSort(struct CARD A[],int N)
{
	struct CARD t;
	int flag=1,j;
	int i=0;
	for (i=0;flag;i++){
		flag=0;
		for (j=N-1;j>=i+1;j--){
			if (A[j].num<A[j-1].num){
				t=A[j];A[j]=A[j-1];A[j-1]=t;
				flag=1;
			}
		}
	}
}

void selectSort(struct CARD A[],int N)
{
	struct CARD t;
	int minj,j,i;
	for (i=0;i<N-1;i++){
		minj=i;
		for (j=i+1;j<N;j++){
			if (A[j].num<A[minj].num)minj=j;
		}
		t=A[i];A[i]=A[minj];A[minj]=t;
	}
}

void trace(struct CARD A[],int N)
{
	int i;
	for (i=0;i<N;i++){
		if (i>0)printf(" ");
		printf("%c%d",A[i].color,A[i].num);
	}
	printf("\n");
 } 
 
void isStable(struct CARD input[],struct CARD output[],int N)
 {
 	int i,j,k,m,ct;
 	for (i=0;i<N-1;i=i+m){
 		ct=1;
 		for (j=i+1;j<N;j++){
 			if (output[i].num==output[j].num)
 			ct++;
		 }
		 m=ct;
		 if (ct>1){
		 	for(k=0;ct>1;k++){
		 		if (output[i+m-ct].num==input[k].num){
		 			if (output[i+m-ct].color==input[k].color){
		 				ct--;
		 				continue;
					 }
					 else{
					 	printf("Not stable\n");
					 	return;
					 }
				 }
			 }
		 }
	 }
	 printf("Stable\n");
}

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

int main(){
  char c;
  cin >> c;
  
  if('A'<=c && c<='Z') cout << 'A' << endl;
  else cout << 'a' << endl;
}


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

using namespace std;

  
int main(){
 string str;
 int i,N;
 
  cin>>N;
  cin>>str;
  
  if(N%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  
  for(i=0;i<N/2;i++){
    if(str.at(i)!=str.at(N/2+i)){
      cout<<"No"<<endl;
      return 0;
    }
  
	}
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    int m, f, r;

    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;

        if(m == -1 || f == -1) cout << "F" << endl;
        else if(m + f >= 80) cout << "A" << endl;
        else if(m + f >= 65) cout << "B" << endl;
        else if(m + f >= 50) cout << "C" << endl;
        else if(m + f >= 30) {
            if(r >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        }
        else  cout << "F" << endl;
    }
}


Measured memory_bytes: 3060
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  vs = list(map(int, input().strip().split()))
  cs = list(map(int, input().strip().split()))
  sum = 0
  for x in sorted([v - c for (v, c) in zip(vs, cs)], reverse=True):
    if x <= 0:
      break
    sum += x
  print(sum)

if __name__=='__main__':
  main()



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

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

    map <string,int> mp;
    mp["SAT"] = 1;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    string s;
    cin >> s;
    cout << mp[s] << '\n';

    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
b=False
sum=0
count=0
absmin=10000000
for i in l:
  if i==0:
    b=True
  elif i<0:
    count+=1
  if absmin>abs(i):
    absmin=abs(i)
  sum+=abs(i)
if b:
  print(sum)
else:
  if count%2==1:
    print(sum-2*absmin)
  else:
    print(sum)

Measured memory_bytes: 14284