akhauriyash/Code-Regression huggingface dataset:
//   //  /////       ///      
//  //   //  //     // //     
// //    //   //   //   //    
////     //   //  //     //   
// //    //   //  /////////    
//  //   //  //   //     //    
//   //  /////    //     //    

#include <bits/stdc++.h>
using namespace std;
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define iter(it,a,b) for(a::iterator it=b.begin(); it!=b.end();++it)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (binary me 1 kitne hai) (if longlong popcount ll)
#define ln "\n"
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(n) n.begin() , n.end() 
#define tfi first.first
#define tse first.second
#define tth second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef pair< pair<int,int> , int> tri;
typedef vector<bool> vbool;
typedef priority_queue<p32> pq32;
typedef priority_queue<p32, vector<p32>, greater<p32> > pq32l;

#pragma GCC optimize ("-O2")
const ll LIM = 2e5+5;
const ll MOD = 1e9+7;
const ll inf = 1e10;



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

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

	ll a[n];
	forn(i,n) cin >> a[i];

	ll dp[n+1][k+1];

	forn(i,k+1) dp[0][i] = 0;
	forn(i,n+1) dp[i][0] = 1;

	forn(i,n){
		forn(j,k){
			if(j >= a[i]) dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j-a[i]] + MOD)%MOD;
			else dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%MOD;
		}
	}

	cout << setprecision(20) << dp[n][k];


}


Measured memory_bytes: 79104
n, m = map(int, input().split())
k = []
for _ in range(m):
    k.append(list(map(int, input().split()))[1:])
*p, = map(int, input().split())

table = []
for i in range(n):
    row = []
    for j in range(2 ** i):
        row += [1] * (2 ** (n-i) // 2) + [0] * (2 ** (n-i) // 2)
    table.append(row)

count = 0
for j in range(len(table[0])):
    res = 0
    for i, item in enumerate(k):
        if sum([table[n-1][j] for n in item]) % 2 == p[i]:
            res += 1
    if res == len(p):
        count += 1

print(count)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();

		int max = 0;
		for (int i = 1; i < n; i++) {
			int tmp = 0;
			for (char c = 'a'; c <= 'z'; c++) {
				boolean flag = false;
				for (int j = 0; j < i; j++) {
					if (s[j] == c) {
						flag = true;
					}
				}

				if (!flag) {
					continue;
				}
				flag = false;
				for (int j = i; j < n; j++) {
					if (s[j] == c) {
						flag = true;
					}
				}
				if (flag) {
					tmp++;
				}
			}

			max = Math.max(max, tmp);
		}

		pr.println(max);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto A=vecin(N);
	
	int r = N-1;
	int x = A.back();
	int index = -1;
	for(int i=0;i<r;i++){
		if(A[i]<=x){
			index++;
			swap(A[i],A[index]);
		}
	}
	swap(A[index+1],A[N-1]);

	REP(i,N-1){
		if(i==index+1) cout << '[' << A[i] << "] ";
		else cout << A[i] << ' ';
	}
	if(N-1==index+1) cout << '[' << A[N-1] << "]" << endl;
	else out(A[N-1]);

	return 0;
}



Measured memory_bytes: 3320
import sys
p = [[int(t) for t in r.split(' ')] for r in sys.stdin.read().split('\n') if r != '']
N, D = p[0]
count = 0
for i in range(1, N):
    for j in range(i + 1, N + 1):
        s = sum(map(lambda t: (t[0]-t[1])**2, [i for i in zip(p[i], p[j])]))
        if int(s**0.5)**2 == s:
            count += 1
print(count)

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

int main() {
    string S;

    int A = 0;//3と4文字目
    int B = 0;//5と6文字目

    cin >> S;

    if (S.at(2) == S.at(3)){
        A = 1;
    }
    else {
        A = 0;
    }
    if (S.at(4) == S.at(5)) {
        B = 1;
    }
    else {
        B = 0;
    }

    if (A * B == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
module UIntegerSort
  implicit none
 
  private
 
  public QuickSortInteger
 
contains
    
  !!
  ! ピボット値の取得
  !
  subroutine GetPivotIntegerValue(array, n, a, b, pivot_value)
    integer, intent(inout) :: array(:), pivot_value
    integer, intent(in) :: n, a, b
 
    pivot_value = array((a + b) / 2)
  end subroutine
 
  !!
  ! ピボット値に従って値を分離
  !
  subroutine GetPartitionInteger(array, n, a, b, pivot)
    integer, intent(inout) :: array(:)
    integer, intent(in)  :: n, a, b
    integer, intent(out) :: pivot
 
    integer :: buffer, pivot_value
    integer :: l, r
 
    if (a == b) then
      pivot = 0
      return
    end if
 
    call GetPivotIntegerValue(array, n, a, b, pivot_value)
 
    l = a
    r = b
 
    do while(.true.)
      do while(array(l) < pivot_value)
        if (l >= b) exit
        l = l + 1
      end do
 
      do while(pivot_value < array(r))
        if (r <= a) exit
        r = r - 1
      end do
 
      if(r <= l) exit
 
      buffer   = array(l)
      array(l) = array(r)
      array(r) = buffer
 
      l = l + 1
      r = r - 1
    end do
 
    pivot = r
  end subroutine
 
  !!
  ! 配列の一部分をソートする。
  !
  recursive subroutine QuickSortIntegerSubarray(array, n, a, b)
    integer, intent(inout) :: array(:)
    integer, intent(in)    :: n, a, b
 
    integer :: pivot
 
    call GetPartitionInteger(array, n, a, b, pivot)
    if (pivot /= 0) then
      call QuickSortIntegerSubarray(array, n, a, pivot)
      call QuickSortIntegerSubarray(array, n, pivot + 1, b)
    end if
  end subroutine
 
  !!
  ! 配列全体をソートする
  !
  subroutine QuickSortInteger(array, n)
    integer :: array(:)
    integer :: n
 
    call QuickSortIntegerSubarray(array, n, 1, n)
  end subroutine
 
end module
 
program TestIntegerSort
  use UIntegerSort
 
  implicit none
  integer,allocatable::a(:),b(:)
  integer :: N,i,k
  read*,N
  allocate(a(N))
  allocate(b(N))
  read(*,*)(a(i),i=1,N)
  b=a
  call QuickSortInteger(a, N)
  do i=1,N
  if(b(i)==a(N))then
    print*,a(N-1)
  else
  	print*,a(N)
  end if
  end do
end program

Measured memory_bytes: 4864
fn main() {
    let b = read::<String>();
    match b.as_str() {
        "A" => println!("T"),
        "T" => println!("A"),
        "C" => println!("G"),
        _ => println!("C"),
    }
}

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


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

int main()
{
    int n;
    cin >> n;
    double a[3100];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    double dp[3100][3100];
    dp[0][0] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            if (j > 0)
                dp[i][j] += dp[i - 1][j - 1] * a[i - 1];

            dp[i][j] += dp[i - 1][j] * (1 - a[i - 1]);
        }
    }

    double result = 0;
    for (int i = 1; i <= n; i++)
    {
        if (n - i <  i)
            result += dp[n][i];
    }
     cout << fixed << setprecision(11) << result << endl;
    return 0;
}

Measured memory_bytes: 50260
#include<stdio.h>

int main(void){
   int N;
   int result,result2=0;
   scanf("%d",&N);

   if(N%2==1){
      result=N/2;
      printf("%d\n",result+1);
   }else if(N%2==0){
      result2=N/2;
      printf("%d\n",result2);
   }
   return 0;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int t_att = c / b ;
    if(c % b != 0)t_att++;
    int a_att = a / d ;
    if(a % d != 0)a_att++;

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

}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){
  int A, B; cin >> A >> B;
  cout << 2 * B - A << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


def main():
    high, width = map(int, input().split())
    sum_s = high * width
    ans = sum_s
    for i in range(1, high):
        a = i * width
        b1 = (high - i) * (width // 2)
        b2 = ((high - i) // 2) * width
        c1 = sum_s - (a + b1)
        c2 = sum_s - (a + b2)

        ans = min(max(a, b1, c1) - min(a, b1, c1), max(a, b2, c2) - min(a, b2, c2), ans)

    for i in range(1, width):
        a = i * high
        b1 = (width - i) * (high // 2)
        b2 = ((width - i) // 2) * high
        c1 = sum_s - (a + b1)
        c2 = sum_s - (a + b2)

        ans = min(max(a, b1, c1) - min(a, b1, c1), max(a, b2, c2) - min(a, b2, c2), ans)

    print(ans)




if __name__ == '__main__':
    main()



Measured memory_bytes: 41200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
template<typename T>
T gcd(T a, T b)
{
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a,T b)
{
    return  a / gcd(a,b) * b;
}
vector<long long> dev;
vector<int> id;

void prime_factor(long long N){
    for(int i=2;(long long)i*i<=N;i++){
        int cnt = 0;
        while(N%i == 0){
            cnt++;
            N /= i;
        }
        if(cnt){
            dev.push_back(i);
            id.push_back(cnt);
        }
    }
    if(N != 1){
        dev.push_back(N);
        id.push_back(1);
    }
    return;
}
int main(){
    ll a,b;
    cin >> a >> b;
    ll c = gcd(a,b);
    prime_factor(c);
    cout << id.size()+1 << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(int i=s;i<=n;i++)
#define ford(j,s,n) for(int i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,n;
    cin>>n>>a>>b;
    if((a/n)==(b/n)&&(a%n!=0))
    	cout<<"NG";
    else cout<<"OK";
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int M = 0;
		var list = new List<int[]>();
			for(var i=1;i<=N;i++){
				for(var j=i+1;j<=N;j++){
					if(i+j!=N+(N+1)%2){
						list.Add(new int[2]{i,j});
					}
				}
			}
		Console.WriteLine(list.Count);
		for(var i=0;i<list.Count;i++){
			Console.WriteLine(list[i][0]+" "+list[i][1]);
		}
	}
}

Measured memory_bytes: 13268
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys


def get_an(s,t):
  # sをtの倍数になるよう切り上げる
  return s//t

## input
N,K = map(int, input().split())
An = list(map(int, sys.stdin.readline().rstrip().split()))
An = sorted(An)
Fn = list(map(int, sys.stdin.readline().rstrip().split()))
Fn = sorted(Fn,reverse=True)
MX = An[0]*Fn[0]
for i in range(N):
  MX = max(MX,An[i]*Fn[i])

def check(ret):
  k = K
  for i in range(N):
    if An[i]*Fn[i] <= ret:
      continue
    else:
     k -= An[i]-get_an(ret,Fn[i])
  if k < 0:
    return False
  else:
    return True

l,r = 0,MX
while r-l > 1:
  c = (l+r)//2
  if check(c):
    r = c
  else:
    l = c
if check(l):
  print(l)
else:
  print(r)

Measured memory_bytes: 114816
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, M = inm()


def solve():
    pos = {0}
    count = [1] * N
    for i in range(M):
        x, y = inm()
        x -= 1
        y -= 1
        if x in pos:
            if count[x] == 1:
                pos.remove(x)
            pos.add(y)
        count[x] -= 1
        count[y] += 1
    return len(pos)


print(solve())


Measured memory_bytes: 18080
import sys
n=int(input())
data=[0]*(n+1)
for i in range(2,n+1):
    for j in range(2,int(i**(1/2))+1):
        if i%j==0:
            break
    else:
        count=0
        for j in range(i,n+1):
            k=j
            while k%i==0:
                k//=i
                data[i]+=1
if n==1:
    print(0)
    sys.exit()
if data[2]>=74:
    ans=1
else:
    ans=0
count3=0
count5=0
count15=0
count25=0
for i in range(n+1):
    if data[i]>=2:
        count3+=1
for i in range(n+1):
    if data[i]>=4:
        count5+=1
for i in range(n+1):
    if data[i]>=14:
        count15+=1
for i in range(n+1):
    if data[i]>=24:
        count25+=1
ans+=count25*(count3-1)
ans+=count15*(count5-1)
ans+=(count3-2)*count5*(count5-1)//2
print(ans)

Measured memory_bytes: 3064
n,l = map(int,input().split())
azi = 0
eat = -1

for i in range(n):
	ringo = l+i
	if (i == 0 and ringo >= 0):
		eat = ringo
	if (ringo == 0):
		eat = 0
	azi += ringo


if (eat < 0):
	eat = ringo

print(azi-eat)

Measured memory_bytes: 3060
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll MOD = 1000000007;

ll N, A[101010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; ++i) { cin >> A[i]; }

    ll ans = 1;
    ll hats[3] = {0, 0, 0};
    for (int i = 0; i < N; ++i) {
        int count = 0;
        for (int j = 0; j < 3; ++j) count += (hats[j] == A[i] ? 1 : 0);
        ans = ans * count % MOD;
        for (int j = 0; j < 3; ++j) {
            if (hats[j] == A[i]) {
                ++hats[j];
                break;
            }
        }
        sort(hats, hats+3);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> H;
  for(int i=0;i<N;i++){
    int k;
    cin >> k;
    H.push_back(k);
  }
  if(N <= K) {cout << 0 << endl;}
  else{
    sort(H.begin(),H.end());
    long long int answer=0;
    for(int i=K;i>=1;i--){
      H.pop_back();
    }
    for(int i=0;i<H.size();i++){
      answer += H[i];
    }
    cout << answer << endl;
  }
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	char c; cin >> c;
	cout << (char)(c + 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

ll fact[1000001];

int main(){
    ll n, k; cin >> n >> k;
    ll ans = 0;
    vector<ll> arr(n+1);
    rep(i, n+1) arr[i] = i;
    ll min = 0, max = 0;
    rep(i, k){
        min += arr[i];
        max += arr[n-i];
    }
    while(k <= n+1){
        ans += max - min + 1;
        min += arr[k];
        max += arr[n-k];
        k++;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4776
#include <stdio.h>

int main(){
  int i, j, sum, n, count = 0;

  scanf("%d", &sum);

  for(i=0; i<sum; i++){
    scanf("%d", &n);
    if(n==2){
      count++;
      continue;
    }
    if(n%2==0) continue;
    for(j=3; j<=n/j; j+=2)
      if(n%j == 0) break;
    if(!(j<=n/j)) count++;
  }

  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		if((s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2)) || (s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3))){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
				
	}
}


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

int main() {
    bool f = true;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] != t[i]) f = false;
    }
    if(f) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    return 0;
}


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

int main() {
    int X, A;
    cin >> X >> A;
    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    int N, K, lenMax;
    int l[50] = {};

    cin >> N >> K;
    for(int i = 0; i < N; i++)
        cin >> l[i];
    
    sort(l, l + N, greater<int>());

    lenMax = 0;
    for(int i = 0; i < K; i++)
        lenMax += l[i];

    cout << lenMax;

    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;

int main(){
	cin >> s;
	int ans1 = 0;
	REP(i, (int)s.size()){
		if(i % 2 == 0 && s[i] == '1')ans1++;
		if(i % 2 == 1 && s[i] == '0')ans1++;
	}
	int ans2 = 0;
	REP(i, (int)s.size()){
		if(i % 2 == 0 && s[i] == '0')ans2++;
		if(i % 2 == 1 && s[i] == '1')ans2++;
	}
	cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	if(a>0)puts("Positive");
	else if(b>=0)puts("Zero");
	  else if((a&1)^(b&1))puts("Positive");
	    else puts("Negative");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
    ll n,k,s;
    cin >> n >> k >> s;
    ll kai = n;
    int minn = 1;
    ll che = 1000000000;
    
    for(int i=0;i<k;i++){
        if(kai==1){
            cout<<s<<endl;
            return 0;
        }
        cout << s<<" ";
        kai--;
    }
    ll d  = s+1;
    if(s==che){
        d=1;
    }
    for(int i=k;i<n;i++){
        if(kai==1){
            cout<<d<<endl;
        }
        else {
            cout<<d<<" ";
            kai--;
        }
    }
}



Measured memory_bytes: 1280
#include <iostream> 
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <math.h>       /* pow */

using namespace std;


void solve(int n){
    //double ans = 0; 
    int ans = n+ pow(n,2) + pow(n,3) ;
    cout << ans << endl;
}



int main(void){

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

}

Measured memory_bytes: 4096
#include <iostream>

int main() {
  int h, w;
  while (std::cin >> h >> w) {
    if (h == 0 && w == 0) {
      return 0;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        std::cout << '#';
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const ll longinf=1LL<<60;

struct LazySegmentTree{
private:
   int n;
   vector<ll> node,lazy;
public:
   LazySegmentTree(int sz,ll init=0){
      n=1;
      while(n<sz)n*=2;
      node.resize(2*n-1,init);
      lazy.resize(2*n-1,0);
   }
 
   void eval(int k,int l,int r){
      if(lazy[k]!=0)node[k]+=lazy[k];
      if(r-l>1){
          lazy[2*k+1]+=lazy[k];
          lazy[2*k+2]+=lazy[k];
      }
      lazy[k]=0;
   }
      //[a,b)にxを加算
   void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
       if(r<0)r=n;
       eval(k,l,r);
       if(r<=a||b<=l)return;
       if(a<=l&&r<=b){
          lazy[k]+=x;
          eval(k,l,r);
       }
       else {
          add(a,b,x,2*k+1,l,(l+r)/2);
          add(a,b,x,2*k+2,(l+r)/2,r);
          node[k]=max(node[2*k+1],node[2*k+2]);
        }
   }
   //[a,b)でのmaxを返す
   ll get(int a,int b,int k=0,int l=0,int r=-1){
      if(r<0)r=n;
      eval(k,l,r);
      if(r<=a||b<=l)return 0;
      if(a<=l&&r<=b)return node[k];
      ll xl=get(a,b,2*k+1,l,(l+r)/2);
      ll xr=get(a,b,2*k+2,(l+r)/2,r);
      return max(xl,xr);
   }
};

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

   vector<ll> w(N), s(N), v(N);
   REP(i, N) cin >> w[i] >> s[i] >> v[i];

   vector<int> ord(N);
   iota(all(ord), 0);
   sort(all(ord),[&](int x,int y){
      return min(s[x], s[y] - w[x]) > min(s[y], s[x] - w[y]);
   });

   // dp[i] := 上から順に重量iまで積んだ時の最大価値
   vector<ll> dp((int)2e4 + 5, -1);
   dp[0] = 0;

   for(int i : ord){
      for(int j = (int)1e4; j >= 0; j--){
         if(dp[j] == -1) continue;
         // 上にjの重量を載せるには、丈夫さがそれ以上になる必要がある
         if(j <= s[i]) chmax(dp[j + w[i]], dp[j] + v[i]);
      }
   }
   cout << *max_element(all(dp)) << endl;

   return 0;
}

Measured memory_bytes: 384
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const L1 = arg[0].split("");
    const L2 = arg[1].split("");
    const L3 = arg[2].split("");
    
    console.log(L1[0] + L2[1] + L3[2]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21192
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.to();
    let v: Vec<(i32, i32, i32)> = (0..n).map(|_| (iter.to(), iter.to(), iter.to())).collect();
    if n == 1 {
        println!("{} {} {}", v[0].0, v[0].1, v[0].2);
        return;
    }
    let mut heights = vec![vec![0; 101]; 101];
    for i in 0..101 {
        for j in 0..101 {
            let height = v.iter()
                .filter(|&p| p.2 != 0)
                .map(|p| p.2 + (p.0 - i).abs() + (p.1 - j).abs())
                .take(1)
                .next()
                .unwrap();
            heights[i as usize][j as usize] = height;
        }
    }

    for i in 0..101 {
        for j in 0..101 {
            let height = heights[i][j];
            let cx = i as i32;
            let cy = j as i32;
            let all = v.iter().all(|p| {
                std::cmp::max(height - (p.0 - cx).abs() - (p.1 - cy).abs(), 0) == p.2
            });
            if all {
                println!("{} {} {}", i, j, height);
                return;
            }
        }
    }

    assert!(false);
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N;
int W[100];
int main(void){
    cin >> N;
    int total = 0;
    REP(i,N){
        cin >> W[i];
        total += W[i];
    }
    int res = INF;
    int left = 0;
    REP(i,N){
        left += W[i];
        int right = total - left;
        res = min(res, abs(right-left));
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8

class Proc:
    def __init__(self):
        self.x = int(input().rstrip())

    def get_ans(self):
        if self.x <= 0:
            return 0
        if self.x <= 6:
            return 1
        if self.x <= 11:
            return 2
        ans = int(self.x / 11) * 2
        self.x = self.x % 11
        ans += self.get_ans()
        return ans


print(Proc().get_ans())


Measured memory_bytes: 2940
x,y = map(int,raw_input().split())
if x==y:
    print x
else:
    if y>x:
        tmp = x
        x = y
        y = tmp
    i=2
    ans = 1
    al = []
    while i*i<=x:
        if x % i ==0:
            if y % i==0:
                al.append(i)
                x = x/i
                y = y/i
                continue
        i+=1
    if len(al)==0:
        pass
    else:
        for j in al:
            ans *= j
    print ans

Measured memory_bytes: 6376
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;
int n;
int a[100001];
int main(){
  cin>>n;
  long ans = 0;
  memset(a,0,sizeof(a));
  for(int i = 0;i<n;i++){
    //  int a;
    cin>>a[i];

  }
  long tmp = 0;
  for(int i = 0;i<=n;i++){
    if(a[i] != 0)
      tmp += a[i];
    else{
      ans += tmp/2;
      tmp = 0;
    }
  }
          
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int a,b; cin >> a >> b;
    
    if((a <= 8) && (b <= 8)) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
unittest
{
	assert( [ "3 3", "1 3 4", "1 3 6" ].parse.expand.solve == 60 );
	assert( [ "6 5", "-790013317 -192321079 95834122 418379342 586260100 802780784", "-253230108 193944314 363756450 712662868 735867677" ].parse.expand.solve == 835067060 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto xs = input.front.split.to!( long[] );
	input.popFront;
	auto ys = input.front.split.to!( long[] );
	return tuple( xs, ys );
}

auto solve( long[] xs, long[] ys )
{
	// すべての長方形の横辺の長さの合計を計算
	auto xt = 0L;
	for( auto i = 1L; i < xs.length.signed; i++ )
	{
		xt = xt.addMod( xs[ i ].subMod( xs[ i - 1 ] ).mulMod( i ).mulMod( xs.length.signed - i ) );
	}
	
	// すべての長方形の縦辺の長さの合計を計算
	auto yt = 0L;
	for( auto i = 1L; i < ys.length.signed; i++ )
	{
		yt = yt.addMod( ys[ i ].subMod( ys[ i - 1 ] ).mulMod( i ).mulMod( ys.length.signed - i ) );
	}
	
	// 横辺 * 縦辺
	return xt.mulMod( yt );
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}

// 引き算
auto subMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + MOD - y ) % MOD;
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}


Measured memory_bytes: 11148
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int64_t n, k;
	cin >> n >> k;

	int64_t ans;
	if (n <= k) {
		ans = min(n, k - n);
	} else {
		int64_t r = n % k;
		ans = min(r, k - r);
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	int a;
	int color[9]={0,0,0,0,0,0,0,0,0};
	int c=0;
	int num=0;
	
	int i,j;
	
	cin>>N;
	for(i=0;i<N;i++){
		cin>>a;
		c=0;
		if(a<400){
			color[0]++;
			c=1;
		}
		if(a<800 && c==0){
			color[1]++;
			c=1;
		}
		if(a<1200 && c==0){
			color[2]++;
			c=1;
		}
		if(a<1600 && c==0){
			color[3]++;
			c=1;
		}
		if(a<2000 && c==0){
			color[4]++;
			c=1;
		}
		if(a<2400 && c==0){
			color[5]++;
			c=1;
		}
		if(a<2800 && c==0){
			color[6]++;
			c=1;
		}
		if(a<3200 && c==0){
			color[7]++;
			c=1;
		}
		if(c==0){
			color[8]++;
			c=1;
		}
	}
	for(i=0;i<8;i++){
		if(color[i]!=0){
			num++;
		}
	}
	if(num==0){
		cout<<1<<" "<<num+color[8];
	}else{
		cout<<num<<" "<<num+color[8];
	}
}
	
		
	
			
		
	

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=100;

char str[2*N];
int n;
vector<int> sav;

int main(){
	scanf("%s%d",str+1,&n);
	int len=strlen(str+1);
	long long ans=0;
	for(int i=1,j=1;i<=len;i++){
		if(str[i]==str[i+1])
			j++;
		else{
			sav.push_back(j);
			j=1;
		}
	}
	if(sav.size()==1){
		long long clen=1ll*len*n;
		printf("%lld\n",clen/2);
		return 0;
	}
	if(sav.size()==2){
		for(int i=0;i<2;i++)
			ans+=sav[i]/2;
		ans*=n;
		printf("%lld\n",ans);
		return 0;
	}
	for(int i=1;i<(int)sav.size()-1;i++)
		ans+=1ll*n*(sav[i]/2);
	if(str[1]==str[len]){
		ans+=sav[0]/2;
		ans+=sav[sav.size()-1]/2;
		ans+=(n-1ll)*((sav[0]+sav[sav.size()-1])/2ll);
		printf("%lld\n",ans);
	}
	else{
		ans+=1ll*n*(sav[0]/2+sav[sav.size()-1]/2);
		printf("%lld\n",ans);
	}
	return 0;
}
//cooooooooonteeeeeeeeeest

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
#define mod2 20071027
#define mod 1000074259
#define base 139
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define tc(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=500010;
ll n,mx;
vector<ll>adj[N];
map<pair<ll,ll>, ll>col;
vector<pair<ll,ll>>edg;
void dfs(ll s, ll pre)
{
    ll cnt=1;
    for(auto u:adj[s])
    {
        if(u!=pre)
        {
            if(cnt==col[{pre,s}])
                cnt++;
            col[{s,u}]=cnt;
            col[{u,s}]=cnt;
            mx=max(mx, cnt);
            cnt++;
        }
    }
    for(auto u:adj[s])
        if(u!=pre)
        dfs(u,s);
}
int main()
{
    in1(n);
    for(int i=0;i<n-1;i++)
    {
        ll u,v;
        in2(u,v);
        edg.pb({u,v});
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1, 1);
    printf("%lld\n",mx);
    for(auto p:edg)
    {
        printf("%lld\n",col[p]);
    }
    return 0;
}
/*

*/


Measured memory_bytes: 31220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	int N = s.size();
	rep(i,N-1) if(s.substr(i,2)=="AC"){
		puts("Yes");
		return 0;
	}
	puts("No");
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "answer: " ; cout << (x) << endl
#define dputans(x) std::cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define substr(s,i,l) string((s), (i), (l))
#define tos(x) (to_string((x)))
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //いい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e9)
#pragma endregion


int main() {
	int n; put n;
	int count = 0;
	vi a;
	vector<bool> used;
	rep(i, n) {
		int ai; put ai;
		a.push_back(ai-1);
		used.push_back(false);
	}

	rep(i, n) {
		if (!used[i]) {
			used[i] = true;
			if (a[a[i]] == i && !used[a[i]]) {
				dbg2(a[i], a[a[i]]);
				used[a[i]] = true;
				count++;
			}
		}
		dbg(i);

	}
END:
	putans(count);
	return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 310
#define MAXM 44100
#define LOGMAXN 20
#define INF 1000000007
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL


int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m;
	while(cin >> n >> m)
	{
		priority_queue<int> pq;
		int x;
		FOR(i, 0, n)
		{
			cin >> x;
			pq.push(x);
		}
		while(m > 0)
		{
			x = pq.top();
			pq.pop();
			pq.push(x/2);
			m--;
		}
		ll ans = 0LL;
		while(pq.size())
		{
			ans += (ll) pq.top();
			pq.pop();
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 892
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    const long Mod = (long)(1e9 + 7);
    
    public static void Main()
    {
        var nm = Console.ReadLine().Split()
            .Select(x => long.Parse(x))
            .OrderBy(x => x)
            .ToArray();

        var d = nm[1] - nm[0];
        if (d > 1)
        {
            Console.WriteLine(0);
            return;
        }

        var t = Frac(1, nm[0]);
        t *= t * Frac(nm[0] + 1, d) % Mod;
        t %= Mod;
        t *= 2 - d;
        t %= Mod;
        Console.WriteLine(t);
    }

    static long Frac(long x, long k)
        => k == 0
            ? 1
            : x * Frac(x + 1, k - 1) % Mod;
}


Measured memory_bytes: 16084
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(N):
    tmp = 0
    for j in range(M):
        tmp += A[i][j]*B[j]
    if tmp + C > 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector< vector<int> > a(n, vector<int>(2));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[j][i];
		}
	}
	for (int i = 1; i < n; i++) {
		a[i][0] += a[i - 1][0];
	}
	for (int i = n - 2; i >= 0; i--) {
		a[i][1] += a[i + 1][1];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, a[i][0] + a[i][1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main
import (
    "fmt"
    "math"
    )
func main(){
    var n, m int
    fmt.Scan(&n, &m)
    min, max := 1.0, float64(n)
    for i,l,r:=0,0.0,0.0;i<m;i++{
        fmt.Scan(&l, &r)
        max = math.Min(max, r)
        min = math.Max(min, l)
    }
    if max - min + 1 < 0{
        fmt.Println(0)
    }else{
        fmt.Println(max - min +1)
    }
    
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pairSS
int main(){
  int 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;

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}

ll ncm(ll n, ll m, ll mod){
  ll ans = 1;
  rep(i, m){
    ans *= (n-i);
    ans %= mod;
    ans *= pow(i+1, mod - 2, mod);
    ans %= mod;
  }
  return ans;
}

void solve(){
  ll N, K;
  cin >> N >> K;

  REP(i, 1, K+1){
    ll a, b;
    a = ncm(K - 1, i - 1, mod);
    b = ncm(N - K + 1, i, mod);

    cout << a * b % mod << endl;
  }
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n m ->
    let a, b = min n m, max n m in
    let z = 1000000007 in
    let ( *@) a b = (a * b) mod z in
    let fact k =
        let rec loop i acc =
            if i = 0 then acc else loop (i - 1) (acc *@ i)
        in
        loop k 1
    in
    let c = fact a in
    Printf.printf "%d\n" @@
        if a = b then 2 *@ c *@ c else
        if a + 1 = b then c *@ c *@ b else 0
)

Measured memory_bytes: 3768
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
ans = [0]*n
for i in range(1,n+1):
    ind = i - 1
    while True:
        r = i % 2
        if r == 0:
            ans[ind] += 1
            i = i // 2
        else:
            break

print(ans.index(max(ans)) + 1)


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

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

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

  int n, l;
  cin >> n >> l;

  vector<int> original_tastes(n);
  rep(i, n) {
    int taste = l + (i + 1) - 1;
    original_tastes.at(i) = taste;
  }
  auto abs_min =
      *min_element(original_tastes.begin(), original_tastes.end(),
                   [](const int& s1, int& s2) { return abs(s1) < abs(s2); });
  int ans = 0;
  rep(i, n) {
    if (original_tastes.at(i) == abs_min) {
      continue;
    }
    ans += original_tastes.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  REP(i,n) cin >> l[i];

  sort(RALL(l));
  int ml = l[0];
  int sum = 0;
  for(int i = 1; i < n; ++i){
    sum += l[i];
  }

  if(ml < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

char a[20];
int main()
{
	int i;
//	freopen ("input.txt", "r", stdin);
	cin >> a;
	for (i = 0; i < 4; i++) {
		printf("%c", a[i]);
	}
	cout << " ";
	for (i = 4; i < 12; i++) {
		printf("%c", a[i]);
	}
	cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    if(a>b)
        swap(a,b);
    //cout<<b<<" "<<a<<endl;
    long long x=b-a;
    //cout<<x<<endl;
    //cout<<a+x<<" "<<b-x<<endl;
    if((a+x/2)==(b-x/2))
        cout<<a+x/2<<endl;
    else
        cout<< "IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 256
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 ans =0;
		for (int i =A; i<=B; i++) {
			int first = i/10000%10;
			int second = i/1000%10;
			int forth =i/10%10;
			int fifth = i%10;
			if (first==fifth&&second==forth) {
				ans++;
			}
		}
		System.out.println(ans);
//------------------------------------------------------------
	}
}

Measured memory_bytes: 23124
#include<stdio.h>

int main(void)
{
	int i,a,b,c,d,e,f;
	char op;
	
	for(i=1; ;i++)
	{scanf("%d %c %d",&a,&op,&b);
	if(op=='?')break;
	c=a+b;
	d=a-b;
	e=a*b;
	f=a/b;
		if(op=='+'){printf("%d\n",c);}
			else{if(op=='-'){printf("%d\n",d);}
						else{if(op=='*'){printf("%d\n",e);}
										else{printf("%d\n",f);}
						}
			}
	}
return 0;
}


Measured memory_bytes: 2100