akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

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

    int n;
    cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];
    sort(A.begin(), A.end());

    vector<int> B;
    REP(i, min(n, 4)){
        REP(j, min(n, 4)){
            if(i == j) continue;
            B.emplace_back(stoi(to_string(A[i]) + to_string(A[j]))); 
        }
    }
    
    sort(B.begin(), B.end());

    cout << B[2] << endl;

    return 0;
}


Measured memory_bytes: 3280
# 問題: https://atcoder.jp/contests/abc144/tasks/abc144_b

n = int(input())
has_multiple = False
for a in range(1, 10):
    if n % a > 0:
        continue
    b = n / a
    if 0 < b < 10:
        has_multiple = True
        break

if has_multiple:
    print('Yes')
else:
    print('No')


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

using namespace std;

int main(void)
{
	string n,k,s;
	cin >> n >> k >> s;

	cout << "A" << k[0] << "C" << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()

while True:
    if S == '':
        print('YES')
        break
    elif len(S) >= 5 and S[-5:] == 'dream':
        S = S[:-5]
    elif len(S) >= 7 and S[-7:] == 'dreamer':
        S = S[:-7]
    elif len(S) >= 5 and S[-5:] == 'erase':
        S = S[:-5]
    elif len(S) >= 6 and S[-6:] == 'eraser':
        S = S[:-6]
    else:
        print('NO')
        break

Measured memory_bytes: 3316
# include <stdio.h>
# include <string.h>
int main ()
{   
  int n;
	char s[100],t[100],g;
	while(gets (s)!=0)
	   {gets(t);
	n=strlen(s);
	int flag=0,i,j;
	for (i=0;i<n;++i){
		  g=s[n-1];
		for (j=n-1;j>0;j--)
		    s[j]=s[j-1];
	   	    s[0]=g;
	   	if (strcmp(s,t)==0)
	   	  {flag=1;
	   	   break;
		  }
	   }
	if (flag)
	  printf ("Yes\n");
	else
	  printf ("No\n");
   } 
}
	

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
 
int main(){
  ll N;
  std::string S;
  cin >> N >> S;
  int count = 0;
  for(int i=0;i<N;i++) if(S.substr(i,3)=="ABC") count++;
  
  cout << count;
  
  return 0;
	
}

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

int data[30];

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

    string w;
    cin >> w;

    for(size_t i = 0; i < w.size(); ++i){
        data[w[i] - 'a'] ++;
    }

    bool check = true;
    for(int i = 0; i < 26; ++i){
        if(data[i] % 2 != 0){
            check = false;
        }
    }

    cout << (check ? "Yes" : "No") << endl;

    return 0;
}

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

int main() {
  int N;
  int answer = 0;
  int count = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for(int i = 0; i < N; i++){
    if(vec.at(i) % 2 == 0) {
      count += 1;
      if(vec.at(i) % 3 == 0 || vec.at(i) % 5 == 0){
        answer += 1;
      }
    }
  }
  if (count == answer){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	cout<<((n-1)/2+1>=k ? "YES" : "NO")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

typedef vector<string> vs;
typedef vector<int> vi;

#define rep(i,b) loop(i,0,b)
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define all(c) (c).begin(), (c).end()

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

int h,w;
inline bool in(int x, int y){
    return 0<=x && 0<=y && x<w && y<h;
}

vi id{0,1,2,3};
bool solve(vs const& g1, vs const& g2){
    int sx1, sy1, sx2, sy2;
    rep(i,h)rep(j,w){
        if(g1[i][j]=='L'){
            sx1=j;sy1=i;
        }
        if(g2[i][j]=='R'){
            sx2=j;sy2=i;
        }
    }
    queue<vi> q;
    static bool vis[64][64][64][64];
    memset(vis,0,sizeof(vis));
    q.push(vi{sx1,sy1,sx2,sy2});
    while(q.size()){
        vi s=q.front();q.pop();
        int x1=s[0],y1=s[1],x2=s[2],y2=s[3];
        if(vis[x1][y1][x2][y2])continue;
        vis[x1][y1][x2][y2]=true;
        if(g1[y1][x1]=='%' && g2[y2][x2]=='%') return true;
        if(g1[y1][x1]=='%' || g2[y2][x2]=='%') continue;

        random_shuffle(all(id));
        rep(i,4){
            int d=id[i];
            int nx1=x1+dx[d],ny1=y1+dy[d];
            int nx2,ny2;
            if(d&1){
                nx2=x2+dx[d],ny2=y2+dy[d];
            }else{
                nx2=x2-dx[d],ny2=y2-dy[d];
            }
            if(!in(nx1,ny1) || g1[ny1][nx1]=='#')nx1=x1,ny1=y1;
            if(!in(nx2,ny2) || g2[ny2][nx2]=='#')nx2=x2,ny2=y2;
            q.push(vi{nx1,ny1,nx2,ny2});
        }
    }
    return false;    
}

int main(){
    while(cin>>w>>h && w|h){
        vs g1(h), g2(h);
        rep(i,h) cin>>g1[i]>>g2[i];
        vs ans{"No","Yes"};
        cout << ans[solve(g1,g2)] << endl;
    }
}

Measured memory_bytes: 29868
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main(void){
  int N, M; cin >> N >> M;
  vector<int> broken(N+1, false);
  int a;
  for(int i = 0; i < M; i++){
    cin >> a;
    broken[a] = true;
  }

  vector<int> answers(N+1, 0);
  answers[0] = 1;
  for(int i = 0; i < N; i++){
    if(!broken[i+2]) answers[i+2] = (answers[i+2] + answers[i])%mod;
    if(!broken[i+1]) answers[i+1] = (answers[i+1] + answers[i])%mod;
  }

  cout << answers[N] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 

ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 

ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;cin>>n;
    ll a[n];f(i,0,n) cin>>a[i];
    ll b[n],c[n];
    f(i,0,n) b[i]=i-a[i],c[i]=i+a[i];
    map<ll,vector<ll>> hi;
    f(i,0,n)
    {
        hi[c[i]].pb(i);
    }
    ll ans=0;
    f(i,1,n)
    {
        if(hi.find(b[i])==hi.end()) continue;
        auto it = LB(hi[b[i]].begin(),hi[b[i]].end(),i);
        ans+=it-hi[b[i]].begin();
    }
    cout<<ans<<endl;
}


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

int getSumDegit(int deci);

int main(){
    int n,min = 0;
    cin >> n;
    for(int a = 1; a < n; a++){
        if(a == 1){
            min = getSumDegit(a) + getSumDegit(n - a);
        }else if(min > getSumDegit(a) + getSumDegit(n-a)){
            min = getSumDegit(a) + getSumDegit(n-a);
        }
    }
    cout << min << endl;
}

int getSumDegit(int deci){
    int sum = 0;
    while(deci > 0){
        sum += deci % 10;
        deci /= 10;
    }
    return sum;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (w, h , x, y) = readListOfLong()
    val multi = if(w == x * 2 && h == y * 2) 1 else 0
    val s = (w.toDouble()/2.0) * h.toDouble()

    println("${s.format(6)} $multi")
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37824
n=int(input())
a=list(map(int,input().split()))

def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

l=[0]*(n+1)
r=[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])
for i in range(n,0,-1):
    r[i-1]=gcd(r[i],a[i-1])

m=[]
for i in range(n):
    m.append(gcd(l[i],r[i+1]))

print(max(m))

Measured memory_bytes: 14400
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type pair struct {
	x, y int
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	m := make(map[pair]int)
	for i := 1; i <= N; i++ {
		s := strconv.Itoa(i)
		f := int(s[0] - '0')
		t := int(s[len(s)-1] - '0')
		m[pair{f, t}]++
	}
	ans := 0
	for t, x := range m {
		y := m[pair{t.y, t.x}]
		ans += x * y
	}
	out(ans)
}


Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;

  ll ans = 0LL;
  for(int b=K+1 ; b<=N ; b++){
    //N=pb+r
    int p = N/b;
    int r = N - p*b;

    ans += p*(b-K) + max(0, r+1-K);
  }

  if(K==0){
    ans -= (N - K);
  }

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

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A
# Result:
import sys

nums_len = int(sys.stdin.readline())
nums_str = sys.stdin.readline().split(' ')
nums = map(int, nums_str)

swap_count = 0
flag = True
while flag:
    flag = False
    for i in reversed(range(1, nums_len)):
        if nums[i] < nums[i - 1]:
            v = nums[i]
            nums[i] = nums[i - 1]
            nums[i - 1] = v
            swap_count += 1
            flag = True

print ' '.join(map(str, nums))
print swap_count

Measured memory_bytes: 4228
def get_digit_num(num):
    num -= 1
    if num < 26:
        return 1,num
    prev_last,digit_num = 25,2
    while True:
        if (prev_last < num < prev_last + (26 ** digit_num) + 1):
            num -= prev_last + 1
            break
        prev_last = prev_last + (26 ** digit_num)
        digit_num += 1
    return digit_num,num

def get_word(digit_num,num_n_digits):
    alpha_arr = [(chr(ord("a") + i)) for i in range(0,26)]
    idx_arr = [0] * digit_num
    for i in range(digit_num-1,-1,-1):
        idx_arr[i] = num_n_digits % 26
        num_n_digits = int(num_n_digits / 26)
    return "".join([alpha_arr[idx_arr[i]] for i in range(digit_num)])

    
if __name__ == "__main__":
    num = int(input())
    digit_num,num_n_digits = get_digit_num(num)
    print(get_word(digit_num,num_n_digits))

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

struct lunlun_build {
    int msd;
    int digit_num;
    ll num;
};

void main_()
{
    ll N;
    cin >> N;
    vector<ll> lunlun_numbers;

    queue<lunlun_build> que;
    for (int i = 0; i < 10; ++i) {
        que.push({ i, 1, i });
        if (i != 0) {
            lunlun_numbers.push_back(i);
        }
    }

    int last_digits_num = 0;
    while (true) {
        auto l = que.front();
        que.pop();
        if (l.digit_num > last_digits_num && (ll)lunlun_numbers.size() >= N) {
            break;
        }
        for (int i = max(l.msd - 1, 0); i <= min(l.msd + 1, 9); i++) {
            ll num = l.num + i * pow(10, l.digit_num);

            que.push({ i, l.digit_num + 1, num });
            if (i != 0) {
                lunlun_numbers.push_back(num);
            }
        }
        last_digits_num = l.digit_num;
    }

    nth_element(begin(lunlun_numbers), begin(lunlun_numbers) + N - 1, end(lunlun_numbers));

    cout << lunlun_numbers[N - 1] << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 7372
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
public class Hello{
    public static void Main(){
        // Your code here!
        int n = int.Parse(Console.ReadLine());
        int ansAC  = 0;
        int ansWA  = 0;
        int ansTLE = 0;
        int ansRE  = 0;
        string[] s = new string[n];
        
        for(int i = 0; i < n; i++){
            s[i] = Console.ReadLine();
            switch(s[i]){
                case "AC":
                    ++ansAC;
                    break;
                case "WA":
                    ++ansWA;
                    break;
                case "TLE":
                    ++ansTLE;
                    break;
                case "RE":
                    ++ansRE;
                    break;
            }

        }
        Console.WriteLine("AC x " + ansAC);
        Console.WriteLine("WA x " + ansWA);
        Console.WriteLine("TLE x " + ansTLE);
        Console.WriteLine("RE x " + ansRE);
    }
}

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

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

    int N,Q;
    int K;
    cin>>N>>K>>Q;

    int a;
    int c[N]={0};

    for(int i=0;i<Q;i++){
        cin>>a;
        c[a-1]++;
    }


    for(int i=0;i<N;i++){

        if(K-(Q-c[i])<=0){
            cout<<"No"<<"\n";

        }else{
            cout<<"Yes"<<"\n";
        }

    }
 
    

}

Measured memory_bytes: 1024
# ??¬????????±
room = [[[0 for a in range(10)] for b in range(3)] for c in range(4)]
n = int(input())
for cnt0 in range(n):
    # ?????°??????????????????
    a,b,c,d = map(int,input().split())
    room[a-1][b-1][c-1]+=d
# ???????????±??????
for cnt1 in range(4):
    for cnt2 in range(3):
        for cnt3 in range(10):
            # OutputPrit
            print(" "+str(room[cnt1][cnt2][cnt3]),end="")
        # ??????
        print ()
    if cnt1<3:
            # ????£???????####################(20??????#)?????????
        print("#"*20)

Measured memory_bytes: 7776
#include <stdio.h>

int main()
{
    int N,i,j,k,sum=0,max=0;
    int A[2][100];

    scanf("%d",&N);
    for(i=0;i<2;i++){
        for(j=0;j<N;j++){
            scanf("%d",&A[i][j]);
        }
    }

    for(k=0;k<N;k++){
        i = 0;
        sum = 0;
        for(j=0;j<N;j++){
            sum += A[i][j];
            if(j==k){
                i++;
                sum += A[i][j];
            }
            if(sum > max){
                max = sum;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
h, w = map(int, raw_input().split())
c = [map(int, raw_input().split()) for i in xrange(h)]
cnt = [[0]*w for i in xrange(h)]

for j in xrange(w):
    seq = 0
    for i in xrange(h):
        if c[i][j] == 0:
            seq += 1
        else:
            seq = 0
        cnt[i][j] = seq
ans = 0
st = [(0, -1)]
for i in xrange(h):
    for j in xrange(w):
        v = cnt[i][j]
        last = j
        while v < st[-1][0]:
            l, k = st.pop()
            last = k
            ans = max(ans, l*(j-k))
        if st[-1][0] < v:
            st.append((v, last))
    while 0 < st[-1][0]:
        l, k = st.pop()
        ans = max(ans, l*(w-k))
print ans

Measured memory_bytes: 55504
using System;

namespace AtCoder.ABC093
{
    class c
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var A = int.Parse(spl[0]);
            var B = int.Parse(spl[1]);
            var C = int.Parse(spl[2]);
            var max = Math.Max(A, Math.Max(B, C));
            var div = 3 * max - (A + B + C);
            if (div % 2 == 0)
            {
                Console.WriteLine(div / 2);
            }
            else
            {
                Console.WriteLine((div + 3) / 2);
            }
        }
    }
}


Measured memory_bytes: 11092
using System;
using static System.Console;
using static System.Int32;
using System.Linq;
using System.Collections.Generic;

class Solution
{
    class Greator : IComparer<int>
    {
        public int Compare(int x, int y) => y - x;
    }

    class RefInt
    {
        public int inner = 1;
        public int Plus() => ++inner;
        public int Minus() => --inner;

        public override string ToString() => inner.ToString();
    }


    static void Main()
    {
        var dic = new SortedDictionary<int, RefInt>(new Greator());
        var sp = ReadLine().Split();
        var m = Parse(sp[1]);
        RefInt val;
        foreach (var a in ReadLine().Split().Select(Parse))
        {
            if (dic.TryGetValue(a, out val)) val.Plus();
            else dic.Add(a, new RefInt());
        }
        for(int i = 0; i < m; ++i)
        {
            var pair = dic.First();
            var key = pair.Key;
            if (pair.Value.Minus() == 0)
            {
                dic.Remove(key);
            }
            key = key >> 1;
            if (dic.TryGetValue(key, out val)) val.Plus();
            else dic.Add(key, new RefInt());
        }
        WriteLine(dic.Sum(p => (long)p.Key * p.Value.inner));
    }
}


Measured memory_bytes: 38748
/* ./a.out < input.dat > output.dat */
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long N, M, XYZ[100009][3];
long long sum[100009];
long long temp_sum;
long long now_result;
long long sign0, sign1, sign2;

// sort(aiTable, aiTable + 5, greater<int>());

int main(){
// input
	scanf("%lld %lld",&N,&M);
	for(int k=0;k<N;k++){
    scanf("%lld %lld %lld",&XYZ[k][0],&XYZ[k][1],&XYZ[k][2]);
  }
  now_result = 0;

// strat main
  for(long long sign=0;sign<8;sign++){
    sign0 = 1 - 2*(sign%2);
    sign1 = 1 - 2*((sign/4)%2);
    sign2 = 1 - 2*((sign/2)%2);
//    printf("sign = %lld %lld %lld\n",sign0,sign1,sign2);
    for(int k=0;k<N;k++){
      sum[k] = sign0*XYZ[k][0] + sign1*XYZ[k][1] + sign2*XYZ[k][2];
    }
    sort(sum,sum+N, greater<long long>());
    temp_sum = 0;
    for(int l=0;l<M;l++){
      temp_sum += sum[l];
    }
    if(temp_sum>now_result){
      now_result = temp_sum;
//      printf("%lld\n",temp_sum);
    }
  }// end sign loop
  printf("%lld",now_result);
} // end main



Measured memory_bytes: 256
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        int N = int.Parse(line);
        line = Console.ReadLine();
        string S = line;

        int MinCount = 200001;
        for(int i = 0; i < N; i++)
        {
            if (S[i] == '#')
            {
                //黒
                //白を全部黒にする or 黒を端っこ以外白にする
                int white_count = 0;
                for(int j = i + 1; j < N; j++)
                {
                    if (S[j] == '.') white_count++;
                }
                if (MinCount > white_count) MinCount = white_count;
                int black_count = N - i - white_count;
                for(int j = N-1; j >= i; j--)
                {
                    if (S[j] == '#') black_count--;
                    else break;
                }
                if (MinCount > black_count) MinCount = black_count;

                //現在地含めた黒の数
                black_count = N - i - white_count;
                //調べたところまでの黒の数（白にする必要のある数)
                int need_white = 0;
                for(int j = i; j < N; j++)
                {
                    if (S[j] == '.')
                    {
                        white_count--;
                    }
                    else
                    {
                        black_count--;
                        need_white++;
                    }
                    if (MinCount > white_count + need_white) MinCount = white_count + need_white;

                }
                break;
            }
            else
            {
                //白
                //無視
                if (i == N - 1)
                {
                    MinCount = 0;
                    break;
                }

            }
        }

        Console.WriteLine(MinCount);
    }
}

Measured memory_bytes: 13112
var n,q,l,r,i,k  :integer;
    c,d:char;
    s:array[1..100000]of char;
    t:array[1..100000]of integer;
begin
  readln(n,q); read(s[1]);
  k:=0;t[1]:=0;
  for i:=2 to n do begin
    read(s[i]);
    if (s[i-1]='A')and(s[i]='C') then k+=1;
    t[i]:=k;
  end;
  for i:=1 to q do begin
    readln(l,r);
    writeln(t[r]-t[l])
  end
end.

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int Q = int.Parse(str);
		for(var i=0;i<Q;i++){
			string[] str2 = Console.ReadLine().Split();
			double A = double.Parse(str2[0]);
			double B = double.Parse(str2[1]);
			double C = Math.Sqrt(A*B);
			long D;
			long D1 = (long)C;
			long ans = D1*2-2;
			long D2 = D1;
			if((D1+1)*D2 < A*B){
				ans += 1;
			} else if(D1 * D2 >= A*B && A!=B){
				ans -= 1;
			}
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13140
/*
*/

#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 220220;

long long n, ans1, ans2, val1, val2;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n;
	cin >> ans1 >> ans2;

	for (int i = 2; i <= n; i++)
	{
		cin >> val1 >> val2;
		long long P = ans1/val1 + (ans1%val1> 0);
		P = max(P, ans2/val2+ (ans2%val2 > 0));
		//cout << P << endl;
		ans1 = val1*P;
		ans2 = val2*P;
		//cout << ans1 << "%" << ans2 << endl;
	}
	cout << ans1 + ans2 << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 256
/*
* @Author: hannibal_lecter
* @Date:   2018-09-24 13:51:57
* @Last Modified by:   hannibal_lecter
* @Last Modified time: 2018-09-24 14:04:48
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
int Case = 1, n, m;
int mul(int a, int b) {
	return 1ll*a*b%mod;
}
int power(int a, int b) {
	int res = 1;
	while(b) {
		if(b&1) res = mul(res, a);
		a = mul(a, a);
		b = b>>1;
	}
	return res;
}
int res = 1;
void C(int a, int b) {
	for(int i = 1; i <= b; i++) {
		res = mul(res, a+i);
		res = mul(res, power(i, mod-2));
	}
}
void solve(){
    scanf("%d%d", &n, &m);int tmp = sqrt(m);
    for(int i = 2; i <= tmp; i++) {
    	int cnt = 0;
    	while(m%i == 0) ++cnt, m/=i;
    	C(n-1, cnt);
    }
    if(m!=1) C(n-1, 1);
    printf("%d\n", res);
    return;
}

int main() {
    //ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    //freopen("/Users/hannibal_lecter/Desktop/code/in.txt", "r", stdin);
    //freopen("/Users/hannibal_lecter/Desktop/code/out.txt","w",stdout);
#endif
    while(Case--) {
        solve();
    }
    return 0;
}

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

using namespace std;

#define ALL(A) (A).begin(),(A).end()
#define ll long long
const int mod = 1e9+7;

int dp[100005][13];

int main(void){
	string s;
	cin >> s;
	int n = s.size();
	dp[0][0]= 1;
	int mul = 1; //桁数
	// 1?2?3 の場合は 0 -> 3 -> ?3 -> 2?3 -> ...の順に処理していく
	for(int i=n-1;i>=0;i--){
		if(s[i]=='?'){
			for(int k=0;k<13;k++){
				for(int j=0;j<10;j++){
					//jは新たに追加する数字つまりmul*jを13で割った余りを出せって感じ
					dp[n-i][(mul*j + k)%13] += dp[n-i-1][k];
					dp[n-i][(mul*j + k)%13] %= mod;
				}
			}
			mul*=10;
			mul%=13;
		}else{
			int c = (int)s[i]-'0';
			for(int k=0;k<13;k++){
				dp[n-i][(mul*c + k)%13] += dp[n-i-1][k];
				dp[n-i][(mul*c + k)%13] %=mod;
			}
			mul *=10;
			mul %=13;
		}
	}
	cout << dp[n][5]%mod << endl;
}

Measured memory_bytes: 5504
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc=new Scanner(System.in);
         int x=sc.nextInt();
         int sum=0;int count=0;
         if(x==1)
         count=1;
          for(int i=1;i<x;i++)
         { 
             if(x==2)
             {count=2;}
             
             
             
             else
            { count++;
             sum=sum+i;
              if(sum>=x)
             {break;}}
         }
         System.out.print(count);
         
    }}

Measured memory_bytes: 23124
import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())

n,q = map(int, raw_input().split())
s = raw_input()
suff = [0 for i in xrange(n+1)]
for i in xrange(n):
	suff[i+1] = suff[i]
	if i > 0 and s[i] == 'C' and s[i-1] == 'A':
		suff[i+1] += 1
for i in xrange(q):
	l,r = map(int, raw_input().split())
	print suff[r] - suff[l]

Measured memory_bytes: 38120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = pow(10,9) + 7;
vector<vector<pair<vector<char>, ll>>> memo(101);
vector<char> c{'A','C','G','T'};

bool ok(vector<char> last4){
	if(last4[1] == 'A' && last4[2] == 'G' && last4[3] == 'C'
	|| last4[1] == 'G' && last4[2] == 'A' && last4[3] == 'C'
	|| last4[1] == 'A' && last4[2] == 'C' && last4[3] == 'G'
	|| last4[0] == 'A' && last4[2] == 'G' && last4[3] == 'C'
	|| last4[0] == 'A' && last4[1] == 'G' && last4[3] == 'C'){
		return false;
	}
	return true;
}

ll dfs(int cur, vector<char> last3 , int N){
	if(cur == N){
		return 1;
	}
	for(int i(0);i<memo[cur].size();++i){
		if(equal(last3.cbegin(), last3.cend(), memo[cur][i].first.cbegin())){
			return memo[cur][i].second;
		}
	}
	ll ret = 0;
	for(int i(0);i<4;++i){
		vector<char> last4 = last3;
		last4.push_back(c[i]);
		if(ok(last4)){
			last4.erase(last4.begin());
			ret = ( ret + dfs(cur + 1, last4, N)) % MOD;
		}
	}
	memo[cur].push_back(make_pair(last3, ret));
	return ret;
}

int main()
{
	int N;
	cin >> N;
	vector<char> S{'T','T','T'};
	cout << dfs(0,S,N) << endl;
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll a,b,m,ans;
    cin>>a>>b>>m;
    vector<ll> A(a),B(b);
    rep(i,a) cin>>A[i];
    rep(i,b) cin>>B[i];
    ll minia=INF,minib=INF;
    rep(i,a) minia=min(minia,A[i]);
    rep(i,b) minib=min(minib,B[i]);
    ans=minia+minib;
    rep(i,m){
        ll x,y,c;
        cin>>x>>y>>c;
        ans = min(ans, A[x-1]+B[y-1]-c);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  map<char, int> mp;
  for(int i=0; i<s.length(); i++){
    if(mp[s[i]]){
      cout << "no" << endl;
      return 0;
    }
    mp[s[i]]++;
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
 
   
int main(){
  int n;
  cin >> n;
  VI a(n);
  rep(i,n)cin >> a.at(i);
  int ev=0;
  rep(i,n){
    if(a.at(i)%2==0)ev++;
  }
  ll ans =pow(3,n)-pow(2,ev);
  cout << ans << endl;

}

Measured memory_bytes: 3900
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  while(1) {
    int n, m;
    cin >> n >> m;
    if(n == 0) return 0;
    int tarou[n], hanako[m];
    FOR(i,0,n) cin >> tarou[i];
    FOR(j,0,m) cin >> hanako[j];
    int sum_tarou = 0, sum_hanako = 0;
    FOR(i,0,n) sum_tarou += tarou[i];
    FOR(i,0,m) sum_hanako += hanako[i];
    int ansa = 1e9, ansb = 1e9, sum_ans = 2e9;
    FOR(i,0,n) {
      FOR(j,0,m) {
        if(sum_tarou - tarou[i] + hanako[j] == sum_hanako - hanako[j] + tarou[i]) {
          if(sum_ans > tarou[i] + hanako[j]) {
            ansa = tarou[i];
            ansb = hanako[j];
            sum_ans = ansa + ansb;
          }
        }
      }
    }
    if(sum_ans == 2e9) {
      cout << -1 << endl;
    } else {
      cout << ansa << " " << ansb << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n;
    cin >> n;
    set<int> s,h,c,d;
    rep(i,n){
        char k;
        int cnt;
        cin >> k >> cnt;
        if(k == 'S') s.insert(cnt);
        if(k == 'H') h.insert(cnt);
        if(k == 'C') c.insert(cnt);
        if(k == 'D') d.insert(cnt);
    }
    for(int i = 1; i <= 13; i++){
        if(!s.count(i)) cout << 'S' sp i << endl;
    }
    for(int i = 1; i <= 13; i++){
        if(!h.count(i)) cout << 'H' sp i << endl;
    }
    for(int i = 1; i <= 13; i++){
        if(!c.count(i)) cout << 'C' sp i << endl;
    }
    for(int i = 1; i <= 13; i++){
        if(!d.count(i)) cout << 'D' sp i << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

_h = []
#t - 0.006*x

for i in range(n):
    _h.append(abs(t - 0.006*h[i] - a))

print(_h.index(min(_h)) + 1)

Measured memory_bytes: 3060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	cout << max(0LL, N - 2 * M) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>

using namespace std;


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

	int n;
	cin >> n;

	int px = 0, py = 0, pt = 0;

	bool possible = true;

	for (int i = 0; i < n; i++) {
		int nt, nx, ny;
		cin >> nt >> nx >> ny;

		int t = nt - pt;
		int x = nx - px;
		int y = ny - py;

		int dist = abs(x) + abs(y);

		if (dist <= t && dist % 2 == t % 2) {
		} else {
			possible = false;
			break;
		}

		pt = nt; px = nx; py = ny;
	}

	if (possible) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

bool m[101];

int main() {
  REP(i, 1, 10) REP(j, 1, 10) {
    m[i * j] |= 1;
  }
  int N; cin >> N;
  cout << (m[N] ? "Yes" : "No") << "\n";
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];

  REP(i, h) REP(j, w) {
    if(s[i][j] == '.') continue;
    bool flag = false;
    REP(k, 4) {
      int x = j + dx[k], y = i+dy[k];
      if(IN(0LL, w, x) && IN(0LL, h, y)) {
        if(s[y][x] == '#') {
          flag = true;
        }
      }
    }
    if(!flag) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

int main() {
  string str;
  getline(cin,str);
  int N=str.size();
  for(int i;i<N;i++){
      char c=str.at(i);
      if (('a'<=c) && (c<='z')){
          c=c-('a'-'A');
      }
      else if ('A'<=c && c<='Z'){
          c=c+('a'-'A');
      }
      str.at(i)=c;
  }
  cout << str <<endl;
}



Measured memory_bytes: 3124
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const a = Number(input[0][0]);

  return a + a ** 2 + a ** 3;
};

console.log(main(read()));


Measured memory_bytes: 29692
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int h,c=1,x=0,v=0,i,p=0;
    cin >> h;
    if(h==1)
    {
        cout << "1" << endl;
        return 0;
    }
    while(1)
    {
        h=h/2;
        c=c*2;
        p+=c/2;
        
        if(h==1)
        {
            break;
        }
    }
    p=c+p;

    cout << p << endl;


    return 0;

}


Measured memory_bytes: 3560
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    string s;cin>>s;
    unsigned int ans=0;
    for(char x:s){if(x=='7'){cout<<"Yes"<<endl;break;}else{ans++;};}
    if(ans==s.size()){cout<<"No"<<endl;};






    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
	int i,a,b,min,sum;
	sum=0;
	scanf("%d",&min);
	for(i=0;i<3;i++){
		scanf("%d",&a);
		if(min>a){
			sum+=min;
			min=a;
		}
		else sum+=a;
	}
	scanf("%d%d",&a,&b);
	if(a<b) sum+=b;
	else sum+=a;
	printf("%d\n",sum);
	return 0;
}

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

public class Program
{
    public static void Main(string[] args)
    {
        new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
        var a = cin.ReadLine;
        var ret = 0;
        switch (a)
        {
            case "SUN":
                ret = 7;
                break;
            case "MON":
                ret = 6;
                break;
            case "TUE":
                ret = 5;
                break;
            case "WED":
                ret = 4;
                break;
            case "THU":
                ret = 3;
                break;
            case "FRI":
                ret = 2;
                break;
            case "SAT":
                ret = 1;
                break;
            default:
                break;
        }
        WriteLine(ret);
        ReadKey();
    }
}

public class ConsoleInput
{
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
        this._separator = separator;
        this._stream = stream;
        inputStream = new Queue<string>();
    }
    public string Read
    {
        get
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}


Measured memory_bytes: 11348
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner teclado = new Scanner(System.in);
		int M = teclado.nextInt();
		int P = teclado.nextInt();
		int Q = ((M * 3) + P) / 2;
		System.out.println((int) Q);
	}

}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

long long dp[100202][3];
const long long INF=1LL<<60;
int h[100202][3];
int N;



int main() {
   cin >> N ;


rep(i,N){
cin >> h[i][0] >> h[i][1] >> h[i][2];
}



for(int i=0;i<N;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
if(j==k)continue;
dp[i+1][k]=max(dp[i+1][k],dp[i][j]+h[i][k]);
}
}
}
int ans=max(dp[N][0],max(dp[N][1],dp[N][2]));

cout << ans;

return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
typedef long long LL;
LL a[100005]={0},b[100005]={0};
int main()
{
	 LL n;
	 cin>>n;
	 LL suma=0,sumb=0;
	 LL ans=0;
	 vector<LL>v,v1;
	 for(LL i=0;i<n;i++)
	 {
	 	 cin>>a[i];
	 	 suma+=a[i];
	 }
	 	 for(LL i=0;i<n;i++)
	 {
	 	 cin>>b[i];
	 	 sumb+=b[i];
	 }
	  LL nsum=0;
	 	 	 for(LL i=0;i<n;i++)
	 {
	 	 // c[i]=a[i]-b[i];
	 	  if(a[i]-b[i]>=0)
	 	   v.push_back(a[i]-b[i]);
	 	   else
	 	   {
	 	   	v1.push_back(a[i]-b[i]);
	 	   	nsum+=(a[i]-b[i]);
			}
	 	   
	 }
	 sort(v.begin(),v.end(),greater<int>());
	 ans+=v1.size();
	 if(!v1.size())
	 {
	 	 printf("0\n");
	 	 return 0;
	 }
	 for(int i=0;i<v.size();i++)
	 {
	 	 if(v[i]<abs(nsum))
	 	 {
	 	 	 nsum+=v[i];
	 	 	  v[i]=0;
	 	 	  ans++;
		  }
		  else
		   {
		   	nsum=0;
		   	v[i]+=nsum;
		   	ans++;
		   	break;
		   }
	 }
	//  sort(v.begin(),v.end(),greater<int>());
	 if(sumb>suma)
	 {
	 	 printf("-1\n");
	 	 return 0;
	 }
	 cout<<ans<<endl;
}



Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1505];
ll b[1505];
int main()
{
	int n;
	scanf("%d",&n);
	ll num1=1;
	ll num2=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		ll u=num1/a[i];
		if(num1%a[i])
		{
			u++;
		}
		ll v=num2/b[i];
		if(num2%b[i])
		{
			v++;
		}
		ll w=max(u,v);
		num1=a[i]*w;
		num2=b[i]*w;
	}
	printf("%lld\n",num1+num2);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int x = in.nextInt();
        int a = in.nextInt();
        out.println((x<a)?"0":"10");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 22740
# coding: utf-8
# Your code here!
while True:
    n=int(input())
    
    x=[]
    for i in range(n):
        s=int(input())
        x.append(s)
    
    x1=sorted(x)
    if n==0:
        break
    else:
        sum1=sum(x1)
        sum1-=x1[0]+x1[n-1]
        y=sum1//(n-2)
        
        print(y)


Measured memory_bytes: 5608