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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string inputbuf1 = Console.ReadLine();
            //string inputbuf2 = Console.ReadLine();
            //string inputbuf1 = "2510";
            //string inputbuf2 = "ABCAB";
            
            int N1 = Convert.ToInt32(inputbuf1.Substring(0,2));
            int N2 = Convert.ToInt32(inputbuf1.Substring(2, 2));
            bool N1_y = false;
            bool N1_m = false;
            bool N2_y = false;
            bool N2_m = false;
            if ((N1 > 0) && (N1 < 13))
            {
                N1_m = true;
                N1_y = true;
            }
            else if(N1 < 99)
            {
                N1_m = false;
                N1_y = true;
            }
            if ((N2 > 0) && (N2 < 13))
            {
                N2_m = true;
                N2_y = true;
            }
            else if (N2 < 99)
            {
                N2_m = false;
                N2_y = true;
            }

            if (N1_m &N2_m)
                Console.WriteLine("AMBIGUOUS");
            else if ((!N1_m) &N2_m)
                Console.WriteLine("YYMM");
            else if ((N1_m) &(!N2_m))
                Console.WriteLine("MMYY");
            else
                Console.WriteLine("NA");


            
            //Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11220
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9+8
#define OO 1e18
#define EPS 1e-6
#define Endl '\n'
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=200005;

int main()
{
    int n,m,c;
    scanf("%d%d%d",&n,&m,&c);
    vector<int> b(m);
    for(int i=0;i<m;++i)cin >> b[i];
    int ans=0;
    while(n--){
        int tmp=c;
        for(int i=0;i<m;++i){
            int x;
            scanf("%d",&x);
            tmp+=(x*b[i]);
        }
        ans+=(tmp>0);
    }
    printf("%d\n",ans);
    re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int X, Y, A, B, C;
PQ<PII> pq;
PQ<int, greater> pq2;


signed main(){
    cin >> X >> Y >> A >> B >> C;
    rep(i, 0, A){ int p; cin >> p; pq.emplace(p, 0); }
    rep(i, 0, B){ int p; cin >> p; pq.emplace(p, 1); }
    rep(i, 0, C){ int p; cin >> p; pq.emplace(p, 2); }

    int c = 0;
    while(X+Y){
        int v, i;
        tie(v, i) = pq.top(); pq.pop();
        if(X > 0 and i == 0) pq2.push(v), X--;
        else if(Y > 0 and i == 1) pq2.push(v), Y--;
        else if(i == 2) pq2.push(v), c++;
    }

    while(c) pq2.pop(), c--;

    int ans = 0;
    while(!pq2.empty()) ans += pq2.top(), pq2.pop();

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14312
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B
"""
n,m,c = LI()
b = LI()
a = LIR(n)
ans = 0
for i in range(n):
    d = c
    for k in range(m):
        d += b[k]*a[i][k]
    if d > 0:
        ans += 1
print(ans)
"""


#C
n,m = LI()
v = LIR(n)
v.sort(key = lambda x:x[0])
ans = 0
k = 0
for a,b in v:
    if k+b >= m:
        ans += (m-k)*a
        print(ans)
        quit()
    ans += b*a
    k += b
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 56368
#include<stdio.h>
int main(void){

int n, i, k, p;

scanf("%d", &n);

p=n/100;

for(i=1; i<10; i++){
if(p==i&&n<=i+i*10+i*100){
 k=i+i*10+i*100;
 printf("%d\n", k);
 break;
}
else if(p==i){
 k=(i+1)+(i+1)*10+(i+1)*100;
 printf("%d\n", k);
 break;
}

}
return 0;
}


Measured memory_bytes: 128
// RAKSHIT KADAM

 #include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
//int power(int x, unsigned int y, unsigned int m)
//{
//    if (y == 0)
//        return 1;
//    int p = power(x, y/2, m) % m;
//    p = (p * p) % m;
//
//    return (y%2 == 0)? p : (x * p) % m;
//}
//ll modInverse(int a, int m)
//{
//    int g = gcd(a, m);
//
//    {
//        // If a and m are relatively prime, then modulo inverse
//        // is a^(m-2) mode m
//
//             return power(a, m-2, m);
//    }
//}
//int gcd(int a, int b)
//{
//    if (b == 0)
//        return a;
//    return gcd(b, a % b);
//
//}
//vector<ll>v[200080];
//ll vis[200080];
//
//void dfs(ll root)
//{
//    vis[root]=1;
//    for(auto it:v[root])
//    {
//        if(vis[it]==0)
//        {
//            dfs(it);
//        }
//    }
//}
void solve()
{
    
}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {
//        solve();
//    }
    string a;ll ans=0;
    cin>>a;
    for(ll i=0;i<=(a.length()-1)/2;i++)
    {
        if(a[i]!=a[a.length()-1-i])ans++;
    }
    cout<<ans<<endl;
    return 0;
    }




Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    int n;
    cin >> n;
    int numOdd;
    int numEv;
    for (int i = 1; i <= n; i++)
    {
        if(i % 2 == 0)
            numEv++;
        else
            numOdd++;
    }
    double result = (double)numOdd/(double)n;
    cout << result;
    
    
    return 0;
}


/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/
/*
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;


int main()
{
    return 0;

}
*/

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

int abc102_a(int n) {
	if (n % 2 == 0) {
		return n;
	}
	return n * 2;
}

void abc_102_a_test() {
	assert(abc102_a(3) == 6);
	assert(abc102_a(10) == 10);
	assert(abc102_a(999999999) == 1999999998);
}


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

	cout << abc102_a(n) << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int m;
    cin >> m;
    long long int result = 0,kuriagari=0, tmpa, tmpb;
    REP(i,m){
        scanf("%lld %lld", &tmpa, &tmpb);
        kuriagari += tmpa*tmpb;
        result += tmpb;
    }
    long long int tmp=10;
    while(tmp<=kuriagari){
        result += kuriagari / tmp;
        kuriagari = kuriagari / 10 + kuriagari % 10;
        //cout << result << endl;
       // cout << kuriagari << endl;
    }
    cout << result-1<< endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int s=sc.nextInt();
		long mod=998244353;
		long[] dp=new long[s+1];
		dp[0]=1;
		long ans=0;
		for(int i=0; i<n; i++){
			int a=sc.nextInt();
			for(int j=s; j>=a; j--){
				dp[j]+=dp[j-a];
				dp[j]%=mod;
			}
			dp[0]++;
			ans+=dp[s];
			ans%=mod;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 29608
n, k = list(map(int,input().split()))
l = list(map(int,input().split()))
dp = [10**9]*n
dp[0] = 0
dp[1] = abs(l[0] - l[1])
for i in range(2,n):
    for j in range(i-1,max(0,i-k)-1,-1):
        tem = dp[j] + abs(l[i] - l[j])
        if tem<dp[i]:
            dp[i] = tem
    
print(dp[n-1])


Measured memory_bytes: 52448
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
arr = Array.new(10**6+1,true)
ans = 0

for i in 1..(10**6 / a[0])
  arr[i*a[0]] = false
end
if n > 1
  ans += 1 if a[0] != a[1]
else
  ans +=1
end

for i in 1..n-1
  if a[i] != a[i-1] && arr[a[i]]
    for j in 1..(10**6 / a[i])
      arr[j*a[i]] = false
    end
    if n > i+1
      ans += 1 if a[i] != a[i+1]
    else
      ans += 1
    end
  end
end
puts ans

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

int main() {
  int n;
  cin >> n;
  set<int> diameter;
  int temp;
  for(int i = 0; i < n; ++i) {
    cin >> temp;
    diameter.insert(temp);
  }
  
  cout << diameter.size() << endl;
}


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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int X = max(A, B);
  X = max(C, X);
  int Y = X;
  for(int i = 0; i < K; i++){
    Y = Y * 2;
  }
  int ans = Y + A + B + C - X;
  cout << ans << endl;
}

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

int main(){
  // 入力
  long int K, N;
  cin >> K >> N;

  vector<long int> A(N);
  for (long int i=0; i<N; i++) {
    cin >> A[i]; 
  }
  
  vector<long int> kyori(N);
  long int kyori_max = 0;
  long int kyori_sum = 0;
  for (long int i=0; i<N-1; i++) {
    kyori[i] = A[i+1] - A[i];
    kyori_sum += kyori[i];
    if (kyori[i]> kyori_max){
      kyori_max = kyori[i];
    }
  }
  // A[N-1]~A[0]間距離
  kyori[N-1] = K - A[N-1] + A[0];
  kyori_sum += kyori[N-1];
  if (kyori[N-1]> kyori_max){
    kyori_max = kyori[N-1];
  }
  long int saitan_kyori = kyori_sum - kyori_max;

  cout << saitan_kyori << endl;
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

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

  if (K == 0){
    cout << N * N << endl;
    return 0;
  }

  ll ans = 0;
  for (ll B = K + 1; B <= N; B++){
    ans += (N/B) * (B-K);
    ans += max((N%B)-(K-1), 0ll);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := ri(), ri()
	for i := 0; i < n; i++ {
		_ = ri()
	}

	cost := 0
	cost += (n - 1) / (k - 1)
	if (n-1)%(k-1) != 0 {
		cost++
	}
	fmt.Println(cost)
}


Measured memory_bytes: 640
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

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

const int mod = 1000000007;
int md(int x,int mdo=mod){
	while(x<0)
		x+=mdo;
	return x%mdo;
}
int ge(int a, int b, int *x, int *y){
	if (a == 0){
		*x = 0, *y = 1;
		return b;
	}
	int x1, y1;
	int gcd = ge(b%a, a, &x1, &y1);
	*x = y1 - (b/a) * x1;
	*y = x1;
	return gcd;
}
int  modinv(int a, int m=mod){
	int x, y;
	int g = ge(a, m, &x, &y);
	int p = (x%m + m) % m;
	return p;
}

vector<int> fct(MAX),ifct(MAX);

void pre(){
	fct[0]=1;
	for(int i=1;i<MAX;i++){
		fct[i]=md(fct[i-1]*i);
	}
	ifct[MAX-1]=modinv(fct[MAX-1]);
	for(int i=MAX-2;i>=0;i--){
		ifct[i]=md(ifct[i+1]*(i+1));		
	}
}

int ncr(int n, int r){
	if(n<r || n<0 ||r<0)
		return 0;
	return md(ifct[r]*md(fct[n]*ifct[n-r]));
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	pre();
	int n,k,i;
	cin>>n>>k;
	vector<int> a(n);
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=0;
	sort(a.begin(), a.end());
	for(i=0;i<n;i++){
		ans=md(ans+md(md(a[i])*ncr(i,k-1)));
	}
	for(i=0;i<n;i++){
		ans=md(ans-md(md(a[i])*ncr(n-i-1,k-1)));
	}
	cout<<ans;
	return 0;
}


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

int N, Q;
ll tr[301010];
vector<int> g[301010];

void solve(int v, int p, ll sum) {
    for (int u : g[v]) {
        if (u == p) continue;
        solve(u, v, sum + tr[v]);
    }
    tr[v] += sum;
}

int main() {
    cin >> N >> Q;
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i, Q) {
        ll p, x;
        cin >> p >> x;
        p--;
        tr[p] += x;
    }

    solve(0, -1, 0);
    rep(i, N) {
        if (i) cout << " ";
        cout << tr[i];
    }
    cout << endl;

}


Measured memory_bytes: 29824
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll sum = 0;
    vector<P> v(N);
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    sort(all(v));
    rep(i, N) {
        sum += v[i].second;
        if (K <= sum) {
            print(v[i].first);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,ans,a,b,c;
string s;
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		for(int j=0;j+1<s.size();j++){
			if(s[j]=='A'&&s[j+1]=='B')ans++;
		}
		if(s[0]=='B')b++;
		if(s[s.size()-1]=='A')a++;
		if(s[0]=='B'&&s[s.size()-1]=='A')c++;
	}
	if(a==c&&b>0)b--;
	cout<<ans+min(a,b)<<endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns      #-} --引数に!

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as BS
import Debug.Trace

cnt :: [Char] -> Int
cnt [] = 0
cnt (a:s) = if a == 'o' then 1 + (cnt s) else cnt s

main :: IO ()
main = do
  n <- readLn
  print $ 180*(n-2)


Measured memory_bytes: 508
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;



void insertionSort(int A[], int n, int g){
    for (int i = g; i <n ; i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[], int n){
    for (int h =1;;){
        if (h > n) break;
        G.push_back(h);
        h =3*h + 1;
    }
    for (int i = G.size()-1 ; i >= 0; i--){
        insertionSort(A, n, G[i]);
    }
}


int main(){
    cin >> n;
    for(int i=0; i < n; i++) cin >> A[i];
    cnt =0;
    
    shellSort(A,n);

    cout << G.size() << endl;
    for ( int i = G.size() - 1 ; i >= 0; i-- ){
        printf("%d", G[i]);
        if ( i )printf(" ");
    }
    printf("\n");
    printf("%lld\n", cnt);
    for ( int i = 0; i < n; i++) printf("%d\n", A[i]);

    return 0;
}


Measured memory_bytes: 7184
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (0 ++^ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv
let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv
let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let between n x m = n <= x && x < m


(* ===== MAIN ===== *)

let n = scan "%d" id

let () =
  match n mod 10 with
  | 2 | 4 | 5 | 7 | 9 -> Printf.printf "hon\n"
  | 0 | 1 | 6 | 8 -> Printf.printf "pon\n"
  | 3 -> Printf.printf "bon\n"
  | _ -> failwith "main.ml"


Measured memory_bytes: 5296
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int[] a=new int[n];
		int[] b=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
			b[i]=a[i];
		}
		Arrays.sort(a);
		for(int i=0; i<n; i++){
			if(a[n-1]==b[i]){
				System.out.println(a[n-2]);
			}else{
				System.out.println(a[n-1]);
			}
		}
	}
}




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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S, T;

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

  std::cin >> S >> T;

  for(int i=0;i<S.size();++i){
      if(S[i] != T[i]){
          std::cout << "No" << std::endl;
          return 0;
      }
  }

  std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 3628
def sieve(n):
  ass = []
  is_prime = [True]*(n+1)
  is_prime[0] = False
  is_prime[1] = False
  
  for i in range(2, int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2, n+1, i):
      is_prime[j] = False
  for i in range(n+1):
    if is_prime[i]:
      ass.append(i)
  return(ass)

x = int(input())
l = sieve(10**5+4)
l_ = set(l)

import bisect
if x in l_:
  print(x)
else:
  print(l[bisect.bisect_right(l,x)])


Measured memory_bytes: 39920
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int S = sc.nextInt();
		int h = S/3600;
		S -= h*3600;
		int m  = S/60;
		S -= m*60;
		int s = S;
		System.out.println(h+":"+m+":"+s);
	}
}



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

int main() {
	int W,H,x,y,r;
	
	cin >> W >> H >> x >> y >> r;
	if (H< y + r|| W < x + r) {
		cout << "No" << endl;
	}
	else if (0>x-r||0>y-r) {
		cout << "No" << endl;
	}
	
	else {
		cout << "Yes" << endl;
	}


	//system("pause");
		return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 
 
 
    
     int solve()
     {  
 
        int a,b;cin>>a>>b;
        if(a==b) cout<<"Yes";else cout<<"No";
        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int	count(char s[200001], int len)
{
  	int	i;
  	int	cnt;
  
  	cnt = 0;
  	for (i=0; i<len; i++)
    {
      	if (s[i] == 'D')
        {
          	cnt++;
        }
    }
  	for (i=0; i<len - 1; i++)
    {
      	if (s[i] == 'P')
        {
          	if (s[i+1] == 'D')
            {
              	cnt++;
            }
        }          
    }
    return cnt;
}

int	main(void)
{
  	char	s[200001];
  	int		i;
  	int		len;
 
  	scanf("%s", s);
  
  	len = strlen(s);
  	for (i=0; i<len; i++)
    {
      	if (s[i] == '?')
        {
          	s[i] = 'D';
        }
    }
  
	printf("%s", s);
  	return (0);
}
  

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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int main() {
    deque<int> dq;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        if (i % 2 == 0)
            dq.push_back(x);
        else
            dq.push_front(x);
    }
    vector<int> vv;
    for (int i: dq)
        vv.push_back(i);
    if (n % 2 == 1)
        reverse(vv.begin(), vv.end());
    for (int i = 0; i < vv.size(); ++i)
        printf("%d ", vv[i]);
    printf("\n");
    return 0;
}




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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  r *= 100;
  g *= 10;
  int sum = r + g + b;
  
  if (!(sum % 4)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

typedef long long ll;
typedef pair<int,int> P;

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N; cin >> N;
    ll l[N];
    for(int i=0;i<N;i++){
        cin >> l[i];
    }
    sort(l,l+N);
    //map<tuple<ll,ll,ll>,int> ma;
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                if((l[i]==l[j])||(l[j]==l[k])||(l[i]==l[k])) continue;
                if((l[i]+l[j])>l[k]){
                    //if(ma[{l[i],l[j],l[k]}]++) continue;
                    //cout << i << " " << j << " " << k << endl;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
}

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

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

  int ans = 1;
  for (int i=2; i<=x; i++) {
    for (int j=2; pow(i,j)<=x; j++) {
      ans = max(ans, (int)pow(i,j));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
H = int(input())

cnt = 1
ans = 1

if H == 1:
    ans = 1
else:
    while True:
        if H // 2 > 1:
            H //= 2
            ans += 2 ** cnt
            cnt += 1
        else:
            ans += 2 ** cnt
            break

print(ans)


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

static const long long INFTY = (1LL << 32);

void WarshallFloyd(long long weight[][100], int verNum) {

	//k????¢??????????????????????????????°????¢??????????????????????????±???????
	//???????????????????¨???????
	for (int k = 0; k < verNum; k++)
		for (int i = 0; i < verNum; i++) {
			//?????????????????£?????????????????§??´??°???????????????????????????
			if (weight[i][k] == INFTY) continue;
			for (int j = 0; j < verNum; j++) {
				if (weight[k][j] == INFTY) continue;
				weight[i][j] = min(weight[i][j], weight[i][k] + weight[k][j]);
			}
		}
}

int main() {

	long long weight[100][100];
	int verNum;
	int edgeNum;
	cin >> verNum >> edgeNum;

	//Initialize
	for (int i = 0; i < verNum; i++)
		for (int j = 0; j < verNum; j++)
			weight[i][j] = (i == j) ? 0 : INFTY;

	for (int i = 0; i < edgeNum; i++) {
		int first_ver, second_ver, wei;
		cin >> first_ver >> second_ver >> wei;
		weight[first_ver][second_ver] = wei;
	}

	WarshallFloyd(weight, verNum);

	//?????¨???
	bool negative = false;
	for (int i = 0; i < verNum; i++)
		if (weight[i][i] < 0) negative = true;

	if (negative)
		cout << "NEGATIVE CYCLE" << endl;
	else {
		for (int i = 0; i < verNum; i++) {
			for (int j = 0; j < verNum; j++) {
				if (j) cout << " ";

				string verVal;
				if (weight[i][j] == INFTY) verVal = "INF";
				else                                  verVal = to_string(weight[i][j]);

				cout << verVal;
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3340
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

c = input()

ans = chr(ord(c) + 1)
print(ans)


Measured memory_bytes: 3064
/* AOJ 0072
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0072
 *
 */

#include <stdlib.h>
#include <stdio.h>

#define DEBUG 0

#define MAX 100
/* 市内の史跡は100 箇所以内です */


typedef struct TStreet Street;
struct TStreet{
    int fA;
    int fB;
    int fCost;
};

int parent[MAX];
int rank[MAX];

void MakeSet(int loc){
    parent[loc] = loc;
    rank[loc] = 0;
};


int find(int loc){
    int found;
    if(parent[loc]==loc){
        return loc;
    }else{
        found = find(parent[loc]);
        parent[loc] = found;
        return found;
    }
}


void merge(int x, int y){
    int xr, yr;
    xr = find(x);
    yr = find(y);
    if(rank[xr] > rank[yr]){
        parent[yr] = xr;
    }else if( rank[xr] < rank[yr]){
        parent[xr] = yr;
    }else if (xr != yr) {
        parent[yr] = xr;
        rank[xr] += 1;
    }
}


int Kruskal(int nodecount, Street* network, int path){
    int i;
    int a, b;
    int cost;
    cost = 0;
    for(i=0; i<nodecount;i++){
        MakeSet(i);
    }
    for(i=0; i < path; i++){
        if(DEBUG)
            printf("Working on %d <-> %d  (%d)\n", network[i].fA, network[i].fB, network[i].fCost);
        a = network[i].fA;
        b = network[i].fB;
        if(DEBUG){
            printf("%d in  %d\n", a, find(a));
            printf("%d in  %d\n", b, find(b));
        }
        if(find(a) != find(b)){
            merge(a, b);
            cost += network[i].fCost;
        }
    }
    return cost;
}


int comp(const void*a, const void*b){
    return ((Street*)a)->fCost - ((Street*)b)->fCost;
}


int main(){
    /* 最小全域木問題 */
    int n, path;
    int i;
    int a, b, d;
    int cost;
    Street* network;
    

    while(scanf("%d", &n)==1 && n){
        /* n <= 100 */
        scanf("%d", &path);

        /* path <= n! */
        network = (Street*)malloc(path*sizeof(Street));

        for(i=0;i<path;i++){
            scanf("%d,%d,%d", &a, &b, &d);
            network[i].fA = a;
            network[i].fB = b;
            network[i].fCost = d/100 - 1 ;
        }

        qsort(network, path, sizeof(Street), comp);
        if(DEBUG){
            for(i=0;i<path;i++){
                printf("%d <-> %d  (%d)\n", network[i].fA, network[i].fB, network[i].fCost);
            }
        }

        cost = Kruskal(n, network, path);
        printf("%d\n", cost);

        free((void*)network);
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
  int n;
  cin>>n;
  int a[n];
  int min=1000000;
  int c;
  for(int i = 0; i<n;i++) {
    cin>>a[i];
    c=0;
    while(a[i]%2==0){
      c++;
      a[i]/=2;
    }
    if(c<min) min = c;
  }
  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l, r = [0] * m, [0] * m
for i in range(m):
    li, ri = map(int, input().split())
    l[i] = li
    r[i] = ri
maxl = max(l)
minr = min(r)
if minr < maxl:
    print(0)
else:
    print(minr - maxl + 1)


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

using namespace std;

void hawawa()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << "\n";
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

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

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

int main(void)
{
    int n, m;
    
    while (1){
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0) break;
        vector <int> number;
        for (int i = 1; i <= n; i++){
            number.push_back(i);
        }
        vector <int> :: iterator it = number.begin();
        while (1 < number.size()){
            for (int i = 1; it = (it == number.end()) ? number.begin() : it, i < m; i++){
                it++;
            }
            it = number.erase(it);
        }
        printf("%d\n", number[0]);
    }
    
    return (0);
}

Measured memory_bytes: 0
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

//ll z[1000001]={0};

int main()
{
    /*
    #ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif
    */
    fio;
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
    cout<<"bust";
    else
    cout<<"win";
    cout<<endl;
}


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

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

  long long int d[N];
  for (int i = 0; i < N; i++)
  {
    cin >> d[i];
  }

  for (int i = 0; i < N; i++)
  {
    if(d[i]==0){
      cout << 0 ;
      return 0;
    }
  }
  
  long long int ans = 1;
  for (int i = 0; i < N; i++)
  {
    ans = ans * d[i];
    if(ans < 1 || ans >  1000000000000000000){
      cout << -1;
      return 0;
    }
  }

  cout << ans ;

  

  

  return 0;
}


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

int main(){
  int N, M;
  vector<long> X;
  cin >> N >> M;
  for(int i=0; i<M; i++){
    long x; cin >> x;
    X.push_back(x);
  }
  sort(X.begin(), X.end());

  vector<long> ivl;
  for(int i=0; i<M-1; i++){
    ivl.push_back(X[i+1]-X[i]);
  }
  sort(ivl.begin(), ivl.end(), greater<long>());

  if(N>=M){
    cout << "0" << endl;
    return 0;
  }

  long ans =0;
  for(int i=0; i<N-1; i++){
    ans += ivl[i];
  }
  cout << X[M-1]-X[0]-ans << endl;
  return 0;
}

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll a,b,c,s,t,x,y,z;
 ll A,B,C,S,T,X,Y,Z;

 ll count;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

signed main(){

	cin>>a>>b;

	vector<int> f(a);

	REP(i,a) cin>>f[i];

	sort(f.begin(),f.end());

	x=0;

	REP(i,b) x+=f[i];

	cout<<x;

	return 0;

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int MAXN = 2e5 + 10;
const int MAXM = 1e6 + 10;
const ll mod = 1e9 + 7;

int a[MAXN],b[MAXN];

int main()
{
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(int i=1; i<=n; i++)
        scanf("%d",&b[i]);
    int ans = 0;
    for(int k=(1<<28); k!=0; k>>=1) {
        for(int i=1; i<=n; i++) {
            a[i] &= (k * 2 - 1);
            b[i] &= (k * 2 - 1);
        }
        sort(a+1,a+1+n);
        sort(b+1,b+1+n);
        int l = 1, r = 1, mid = 1;
        int res = 0;
        for(int i=n; i>=1; i--) {
            while(l <= n && a[i] + b[l] < k) l++;
            while(mid <= n && a[i] + b[mid] < 2 * k) mid++;
            while(r <= n && a[i] + b[r] < 3 * k) r++;
            res += mid - l + n - r + 1;
            res &= 1;
        }
        if(res) ans += k;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    String s = sc.next();
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(0);
    for(int i = 1; i < n; i++) {
      if(s.charAt(i) != s.charAt(i - 1)) list.add(i);
    }
    int ans = 0;
    for(int i = 0; i < list.size(); i++) {
      int t = list.get(i);
      if(s.charAt(t) == '0') {
        if((i + (2 * k)) < list.size()) {
          int s1 = list.get(i + (2 * k));
          ans = Math.max(ans, s1 - t);
        } else {
          ans = Math.max(ans, n - t);
        }
      } else {
        if((i + (2 * k) + 1) < list.size()) {
          int s1 = list.get(i + (2 * k) + 1);
          ans = Math.max(ans, s1 - t);
        } else {
          ans = Math.max(ans, n - t);
        }        
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 27832
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,less<int> > q;
const int N=1e5+10;
const int mod=1e9+7;
int n,m,sum,t,x,a[N],num;
inline int mx(int c,int y){return c>y?c:y;}
int main()
{
	sf(n);
	rep(i,1,n){
		sf(x);
		if(i==1){
			t=x;continue;	
		}
		if(t>=x)sum++;
		else {
			num=mx(num,sum);
			sum=0;
		}
		t=x;
	}
	num=mx(num,sum);
	cout<<num<<endl;
	return 0;
}

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

using namespace std;
const int N = 500010,M = 2e4 + 10;
char s[N];
int n,q;
set<int> st[26];

int main()
{
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#endif

    cin >> n >> s >> q;
    for(int i = 0;i < n;i++)st[s[i] - 'a'].insert(i + 1);
    while(q--)
    {
        int a,b;
        cin >> a;
        if(a == 1)
        {
            char t;
            cin >> b >> t;
            st[s[b-1] - 'a'].erase(b);
            s[b-1] = t; 
            st[t - 'a'].insert(b);
        }
        else 
        {
            int l,r;
            cin >> l >> r;
            int ans = 0;
            for(int i = 0;i < 26;i++)
            {
                set<int>::iterator it;
                it = st[i].lower_bound(l);
                if(it != st[i].end() && *it <= r)ans++;
            }
            cout << ans <<"\n";
        }
    }
    return 0;
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 2019;



int main(){
    ll K; cin >> K;
    ll N = 50;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) A[i] = 49;
    ll common = K / 50;
    ll operation = K % 50;
    for(int i = 0; i < N; i++) A[i] += common;
    for(int i = 0; i < operation; i++){
        A[i] += N;
        for(int j = 0; j < N; j++){
            if(j != i) A[j]--;
        }
    }
    cout << N << endl;
    for(int i = 0; i < N; i++) cout << A[i] << " ";
    cout << endl;





}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        long n = Long.parseLong(br.readLine());
        long ans = 0;
        for(int i = 1; i <= Math.sqrt(n); i++) {
           if(n % i == 0) {
               long m = n / i - 1;
               if(i < m) ans += m;
           }
        }

        System.out.println(ans);
        
        br.close();
    }
}

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

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

const int mod = 1000000007;

using ll = long long;

vector<ll> fact(300000);

void init()
{
	fact[0] = 1;
	for (int i = 1; i < 300000; i++) {
		fact[i] = fact[i-1] * i;
		fact[i] %= mod;
	}
}

ll modpow(ll val, int p = mod - 2)
{
	if (p == 0) return 1;
	ll res = modpow(val, p / 2);
	res = res * res % mod;
	if (p % 2 == 1) return res * val % mod;
	return res;
}

ll comb(int n, int r)
{
	return (fact[n] * modpow(fact[n-r]) % mod) * modpow(fact[r]) % mod;
}

signed main()
{
	init();
	ll res = 0;
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	int h, w;
	for (h = H - A - 1, w = B; h >= 0 && w < W; h--, w++) {
		ll t = comb(h+w, h);
		ll a, b;
		a = H-h-1;
		b = W-w-1;
		res += t * comb(a+b, a) % mod;
		res %= mod;
	}
	cout << res << endl;
}


Measured memory_bytes: 2560