akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

/**
 * B
 */
public class Main {
    public static void main(String[] args) {
        
    Scanner sc  = new Scanner(System.in);
    
    int n = sc.nextInt();
    int min_j, count=0;
    int array[] = new int[n];

    for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
    }

    sc.close();

    for(int i=0; i<=n-1; i++) {

        min_j = i;

        for(int j=i; j<=n-1; j++) {

            if(array[j] < array[min_j]) {

                min_j = j;

            }
        }

        if(i != min_j) {

            int tmp = array[i];
            array[i] = array[min_j];
            array[min_j] = tmp;
            count++;

        }

    }

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

        System.out.print(array[i]);
        if(i != n-1) {
            System.out.print(" ");
        }
    }

        System.out.println("\n" + count);

    }
}


Measured memory_bytes: 26364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

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

  for(int i=0;i<s.size();i+=w)
    cout << s[i];

  return 0;
}

Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

K = k()

print("ACL"*K)

Measured memory_bytes: 10464
W, H, N = list(map(int, input().split()))

rect = [0, 0, W, H]

ans = -1

XY_a = []

for i in range(N):
    XY_a.append(list(map(int, input().split())))
    
for i in range(N):
    if XY_a[i][2] == 1:
        rect[0] = max(XY_a[i][0], rect[0])
    elif XY_a[i][2] == 2:
        rect[2] = min(XY_a[i][0], rect[2])
        
    elif XY_a[i][2] == 3:
        rect[1] = max(XY_a[i][1], rect[1])
    elif XY_a[i][2] == 4:
        rect[3] = min(XY_a[i][1], rect[3])
        
    if rect[0] >= rect[2] or rect[1] >= rect[3]:
        ans = 0
        break
        
if ans == 0:
    print(ans)
else :
    ans = (rect[2] - rect[0])*(rect[3] - rect[1])
    print(ans)
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct drz {
  int base;
  vector<int> d;
  int query(int v){
    int res = 0;
    for(v += base;v > 0;v /= 2) res += d[v];
    return res;
  }
  void add(int x, int y, int val){
    for(x += base, y += base;x <= y;x /= 2, y /= 2){
      if(x % 2 == 1) d[x++] += val;
      if(y % 2 == 0) d[y--] += val;
    }
  }
  drz(int size){
    for(base = 1;base <= size;base *= 2);
    d.resize(2 * base);
  }
};
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, Q;
  cin >> n >> Q;
  vector<int> c(n), res(Q), last(n + 1);
  for(int i = 0;i < n;i++) cin >> c[i];
  vector<tuple<int, int, int>> q(Q);
  for(int i = 0;i < Q;i++){
    cin >> get<1>(q[i]) >> get<0>(q[i]);
    get<2>(q[i]) = i;
  }
  sort(q.begin(), q.end());
  fill(last.begin(), last.end(), -1);
  drz d(n + 7);
  int z = -1;
  for(auto [y, x, query] : q){
    x--;
    y--;
    while(z < y){
      z++;
      d.add(last[c[z]] + 1, z, 1);
      last[c[z]] = z;
    }
    res[query] = d.query(x);
  }
  for(int i : res) cout << i << '\n';
}


Measured memory_bytes: 19524
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int lli;
typedef pair<int,int> pii;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

lli min(const lli a,const lli b){
	return (a<b?a:b);
}

bool CompareY(const pii &a,const pii &b){
	return a.second<b.second;
}

lli SearchClosestPair(const vector<pii>::iterator &a,int size){
	if(size<=1) return INF;
	int m=size/2;
	lli x=a[m].first;
	lli d=min(SearchClosestPair(a,m),SearchClosestPair(a+m,size-m));
	inplace_merge(a,a+m,a+size,CompareY);
	vector<pii> b;
	for(int i=0; i<size; ++i){
		if(fabs(a[i].first-x)>=d) continue;
		for(int j=0; j<b.size(); ++j){
			lli dx=a[i].first-b[b.size()-j-1].first;
			lli dy=a[i].second-b[b.size()-j-1].second;
			if(dy>=d) break;
			d=min(d,dx*dx+dy*dy);
		}
		b.push_back(a[i]);
	}
	return d;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	vector<pii> points(N);
	REP(i,0,N) cin >> points[i].first >> points[i].second;
	sort(points.begin(),points.end());
	cout << SearchClosestPair(points.begin(),N) << endl;
	return 0;
}

Measured memory_bytes: 10712
k = int(input(''))
ab = input('')
a = int(ab.split(' ')[0])
b = int(ab.split(' ')[1])

ret=0
for i in range(a,b+1):
    if i % k == 0:
        ret=1

if ret==0:
    print('NG')
else:
    print('OK')


Measured memory_bytes: 9120
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll H, W, K;
    cin>>H>>W>>K;
    vector<string> gs(H); cin>>gs;

    ll ans = 0;
    rep(i, 1<<H) {
        rep(j, 1<<W) {
            vvl cs(H, vl(W));
            rep(h, H) rep(w, W) if (gs[h][w] == '#') cs[h][w] = 1;
            rep(h, H) {
                if (i>>h&1) {
                    rep(w, W) cs[h][w] = 0;
                }
            }
            rep(w, W) {
                if (j>>w&1) {
                    rep(h, H) cs[h][w] = 0;
                }
            }
            ll cnt = 0;
            rep(h, H) rep(w, W) cnt += cs[h][w];
            if (cnt == K) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	if(n % 2){
		for(auto i = 0; i < m; ++ i){
			cout << i + 1 << " " << 2 * m - i << "\n";
		}	
	}
	else{
		for(auto i = 0; m && i < n / 4; ++ i, -- m){
			cout << i + 1 << " " << n / 4 * 2 - i << "\n";
		}
		for(auto i = 0; m && i < (n - 2) / 4; ++ i, -- m){
			cout << i + 1 + n / 4 * 2 << " " << n - 1 - i << "\n";
		}
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')

def main():
	N = inputInt()
	X = inputList()

	ans = inf
	for i in range(1,101):
		total = 0
		for j,val in enumerate(X):
			tmp = (val-i)**2
			total += tmp
		#print(total)
		if ans > total:
			ans = total

	print(ans)


if __name__ == "__main__":
	main()


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

int main()
{
	int n;
	cin >> n;
	vector<int> p(n),a(20000),b(20000),ab(20000);
	for(int i = 0;i<20000;i++)
	{
		a[i] = 30000*i+1;
		ab[i] = 600000000;
		b[i] = ab[i] - a[i];
	}
	for(int i =0;i<n;i++)cin >> p[i];
	for(int i = 0;i<n;i++)
	{
		a[p[i]-1]+=i;
	}
	for(int i =0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
	for(int i =0;i<n;i++)cout<<b[i]<<' ';cout<<endl;

}


Measured memory_bytes: 3900
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto S = sread();
    auto T = sread();
    auto s = (cast(char[])(cast(ubyte[]) S.dup).sort().array).text;
    auto t = (cast(char[])(cast(ubyte[]) T.dup).sort!"b<a"().array).text;
    dprint(s,t);
    writeln(s < t ? "Yes" : "No");
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    vll a(3);
    rep(i,3)cin >> a[i];
    ll ev = 0,od = 0,ans = 0;
    rep(i,3){
        if(a[i]%2==0)ev++;
        else od++;
    }

    if(ev == 2){
        rep(i,3)if(a[i]%2==0)a[i]++;
        ans++;
    }
    else if(od == 2){
        rep(i,3)if(a[i]%2==1)a[i]++;
        ans++;
    }

    sort(all(a));
    //rep(i,3)cout << a[i] << " ";
    //cout << endl;

    ans += (2*a[2]-a[0]-a[1])/2; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
B=list(map(int,input().split()))
ans = 0
time = 0
prev = 0
for B_ch in B:
    if time == 0:
        ans += B_ch
    else:
        if B_ch >= prev:
            ans += prev
        else:
            ans += B_ch
    
    prev = B_ch
    time += 1
ans += prev
print(ans)

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

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int &i : h)
        cin >> i;
    vector<int> dp(n, 1e9+9);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= k + i; ++j) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

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

int main(){
    string S; cin>>S;
    if(S[0]=='R'){
        if(S[1]=='R'){
            if (S[2]=='R'){
                cout<<3<<endl;
            }else{
                cout<<2<<endl;
            }
        }else{
            cout<<1<<endl;
        }
    }else{
        if(S[1]=='R'){
            if(S[2]=='R'){
                cout<<2<<endl;
            }else{
                cout<<1<<endl;
            }
        }else{
            if(S[2]=='R'){
                cout<<1<<endl;
            }else{
                cout<<0<<endl;
            }
        }
    }
}

Measured memory_bytes: 3596
N = int(input())
sticks = list(map(int, input().split()))
stocks = set([])
doubles = []
for s in sticks:
    if s not in stocks:
        stocks.add(s)
    else :
        doubles.append(s)
        stocks.remove(s)
if len(doubles) < 2:
    print("0")
else:
    l = max(doubles)
    doubles.remove(max(doubles))
    m = max(doubles)
    print(l*m)

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
int MOD = 998244353;
const int e5 = (int) 1e5 + 5;
const int maxn = (int) 1e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL mod = MOD)
{
    if(n < 0) a = fp(a, mod - 2, mod), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % mod) if(n & 1) res = res * a % mod; return res;
}

struct Mint
{
    LL x;
    Mint() {x = 0;}
    Mint(int _x): x(_x) {}
    Mint(LL _x): x(_x) {}
    Mint operator - () const{
        return Mint(MOD - x);
    }
    Mint operator + (const Mint &rhs) const{
        LL res = x + rhs.x; if(res >= MOD) res -= MOD; return Mint(res);
    }
    Mint operator - (const Mint &rhs) const{
        LL res = x - rhs.x; if(res < 0) res += MOD; return Mint(res);
    }
    Mint operator * (const Mint &rhs) const{
        return Mint(x * rhs.x % MOD);
    }
    Mint operator / (const Mint &rhs) const{
        return Mint(x * fp(rhs.x, -1) % MOD);
    }
    Mint& operator += (const Mint &rhs) {
        x += rhs.x; if(x >= MOD) x -= MOD; return *this;
    }
    Mint& operator *= (const Mint &rhs) {
        x = (x * rhs.x) % MOD; return *this;
    }
    bool operator == (const Mint &rhs) const{
        return x == rhs.x;
    }
    bool operator != (const Mint &rhs) const{
        return x != rhs.x;
    }
    friend ostream& operator << (ostream &out, const Mint &rhs){
        return out << rhs.x;
    }
    friend istream& operator >> (istream &in, Mint &rhs){
        return in >> rhs.x;
    }
};

void work()
{
    LL x; read(x);
    LL sum = (x + 1) * x / 2;

    LL t = x / 3;
    sum -= 3 * (t + 1) * t / 2;

    t = x / 5;
    sum -= 5 * (t + 1) * t / 2;

    t = x / 15;
    sum += 15 * (t + 1) * t / 2;

    cout <<sum <<endl;
}

int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 3600
from sys import stdin
readline = stdin.readline

r0, r1 = map(int, readline().split())
a0, a1 = 1, 0
b0, b1 = 0, 1
while 0 < r1:
    q1 = r0 // r1
    a0, a1 = a1, a0 - q1 * a1
    b0, b1 = b1, b0 - q1 * b1    
    r0, r1 = r1, r0 % r1

print(a0, b0)

Measured memory_bytes: 6728
import sys

ans = 0


def dfs(rest: int, s: str) -> None:
    global ans
    if rest == 0:
        if int(s) > n:
            print(ans)
            sys.exit()
        elif '3' in s and '5' in s and '7' in s:
            ans += 1
    else:
        for c in "357":
            dfs(rest - 1, s + c)


def main() -> None:
    global n
    n = int(input())
    for i in range(1, sys.maxsize):
        dfs(i, "")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int R,C;
int arr[15][10005];
void overrow(int n)
{
	int i;
	for(i=0;i<C;i++)
		arr[n][i]=(arr[n][i]+1)%2;
}

int count(int n)
{
	int i,num=0;
	for(i=0;i<R;i++)
		if(arr[i][n]==0)
			num++;
	return num;
}
int main()
{
	while(scanf("%d%d",&R,&C),R||C)
	{
		char cm;
		int i,j,num;
		getchar();
		for(i=0;i<R;i++)
		{
			num=0;
			while((cm=getchar())!='\n')
			{
				if(cm!=' ')
					arr[i][num++]=cm-'0';
			}
		}
		int per=1<<R,m,mnum;
		long long max=0;
		for(i=0;i<per;i++)
		{
			num=0;
			for(j=0;j<R;j++)
			{
				if(i&(1<<j))
					overrow(j);
			}
			for(j=0;j<C;j++)
			{
				mnum=count(j);
				if(mnum>R/2)
					num+=mnum;
				else
					num+=R-mnum;
			}
			max=num>max?num:max;
			for(j=0;j<R;j++)
			{
				if(i&(1<<j))
					overrow(j);
			}
		}
		printf("%lld\n",max);
		memset(arr,0,sizeof(arr));
	}
	return 0;
}


Measured memory_bytes: 2288
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl

int distA(char c) {
  if(c == 'a') return 0;
  return 'z' - c + 1;
}

signed main() {
  ios::sync_with_stdio(false);
  string S;
  int K;
  cin >> S >> K;
  int k = K;
  REP(i, S.size()) {
    int d = distA(S[i]);
    if(d <= k) {
      k -= d;
      S[i] = 'a';
    }
  }
  k %= 26;
  S[S.size() - 1] += k;
  cout << S << endl;
}


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

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

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int n,a,b;
  cin>>n>>a>>b;
  if(n==1)
    cout<<"Hello World\n";
  else
    cout<<a+b<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <list>
#include <cstring>

int main(void) {
  int K;

  std::string str;

  std::string s_;
  std::cin >> s_;
  const char* s = s_.c_str();

  std::cin >> str;
  K = std::stoi(str);

  size_t lsize = 0;
  size_t len = s_.length();

  typedef struct s_set {
    int pos;
    int len;

    s_set(int i, int j) : pos(i), len(j) {
    }
  } set;

  std::list<std::string> wlist;
  //std::list<set> wlist;

  wlist.push_back(s_.substr(0, 1));
  //wlist.push_back(set(0, 1));
  for (int a = 'a'; a <= 'z' && lsize < K; ++a) {        /* a to z   */
    for (int b = 'a'; b <= 'z' && lsize < K; ++b) {      /* a to z   */
      for (int i = 0; i < len; ++i) {                    /* 0 to len */
        if (s[i] == a && (i+1 >= len || s[i+1] == b)) {
          for (int j = 1; j <= len - i && j <= 5; ++j) {           /* length 1 to len - i */
            for (auto itr = wlist.begin(); itr != wlist.end(); ++itr) {
              int cmp = s_.compare(i, j, *itr);
              //int cmp = s_.compare(i, j, s_, itr->pos, itr->len);
              if (cmp == 0) {
                break;
              }
              if (cmp < 0) {
                wlist.insert(itr, s_.substr(i, j));
                //wlist.insert(itr, set(i, j));
                lsize++;
                break;
              }
              if (cmp > 0 && itr->c_str() == wlist.rbegin()->c_str()) {
              //if (cmp > 0 && (itr->pos == wlist.rbegin()->pos && itr->len == wlist.rbegin()->len)) {
                wlist.push_back(s_.substr(i, j));
                //wlist.push_back(set(i, j));
                lsize++;
                break;
              }
            }
          }
        }
      }
    }
  }

  size_t idx = 0;
  for (auto &str : wlist) {
    idx++;
    if (idx == K) {
      std::cout << str << std::endl;
      //std::cout << str.pos << "," << str.len << std::endl;
      //std::cout << s_.substr(str.pos, str.len) << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	m := make(map[int]int)
	m[a]++
	m[b]++
	m[c]++
	if m[5] == 2 && m[7] == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#define MAX 100000

int A[MAX];

int Partition(int A[] ,int p,int r){

  int x,tmp,i,j;

  x = A[r];
  i = p-1;

  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp; 
    }
  }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;

    return i+1;
}

int main(){

  int n,x,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&A[i]);

  x = Partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i!=0) printf(" ");
    if(i==x) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
 
  printf("\n");

  return 0;
}

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

int main() {
	int N;
	int cnt;
	int flag;
	cin >> N;
	vector<int> vec(N);

	for(int i=0;i<N;i++) {
		cin >> vec.at(i);
	}
	
	cnt=0;
	while(true) {
		flag  = 0;
		for(int i=0;i<N;i++){
			if(vec.at(i)%2==0 && vec.at(i)!=0){
				vec.at(i) /= 2;
				flag++;
			}
		}
		
		if(flag == N) {
			cnt++;
		} else {
			break;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES";
	else cout << "NO";	
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
			String[] ary = br.readLine().split(" ");
	        int x = Integer.parseInt(ary[0]);
	        int y = Integer.parseInt(ary[1]);
			if(x==0&&y==0) break;
	        if(x>y){
	        	sb.append(y+" "+x+"\n");
	        }else{
	        	sb.append(x+" "+y+"\n");
	        }
		}
		System.out.print(sb);
	}
}

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

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

int main()
{	
	const int nextx[2][6] = {{ 0,  1, -1,  1,  0,  1,},  {-1,  0, -1,  1, -1,  0}};
	const int nexty[2][6] = {{-1, -1,  0,  0,  1,  1,}, {-1, -1,  0,  0,  1,  1}};
	
	bool exist[104][104] = {false}, visit[104][104] = {false};
	int w, h, ans = 0;
	
	scanf("%d%d", &w, &h);
	
	for(int y = 0; y < h; ++y) {
		for(int x = 0; x < w; ++x) {
			int t;
			scanf("%d", &t);
			if(t == 1)
				exist[x + 2][y + 2] = true;
		}
	}
	
	queue<pair<int, int> > q;
	
	q.push(make_pair(0, 0));
	
	while(!q.empty()) {
		
		//取り出し
		int cx = q.front().first, cy = q.front().second;
		q.pop();
		
		if(visit[cx][cy])
			continue;
		visit[cx][cy] = true;
		
		//調査
		for(int i = 0; i < 6; ++i) {
			
			int nx = nextx[cy & 1][i] + cx, ny = nexty[cy & 1][i] + cy;
			
			if(!IN(nx, ny, w + 4, h + 4))
				continue;
			
			if(exist[nx][ny])
				++ans;
			else if(!visit[nx][ny])
				q.push(make_pair(nx, ny));
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1084
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

signed main() {
    int n, m;
    cin >> n >> m;
    if(n == 1 && m == 1){
        cout << 1 << endl;
    }else if(n == 1 || m == 1){
        cout << n * m - 2 << endl;
    }else{
        cout << max(0LL, (long long)(n-2)*(m-2)) << endl;
    }
}

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

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

    for(int A=1; A<4000; A++){
        if(pow(A, 5) == X){
            cout << A << " " << 0 << endl;
            return 0;
        }

        else if(pow(A, 5) > X){//Aの5乗がXを超えるときBは正である
            for(int B=1; B<=4000; B++){
                if(pow(A, 5) - pow(B, 5) == X){
                    cout << A << " " << B <<endl;
                    return 0;
                }
            }
        }

        else{
            for(int B=-1; B>=-5000; B--){
                if(pow(A, 5) - pow(B, 5) == X){
                    cout << A << " " << B << endl;
                    return 0;
                }
            }
        }
    }

} 

Measured memory_bytes: 4224
l = [0]*31
pos = goal = 0
def solve(sum,cur):
    global pos, goal
    if sum == goal:
        print " ".join(map(str,l[:pos]))
        return
    for i in range(cur,0,-1):
        if sum + i <= goal:
            l[pos] = i
            pos += 1
            solve(sum+i,i)
            pos -= 1
while True:
    goal = int(raw_input())
    if goal == 0: break
    solve(0,goal)

Measured memory_bytes: 6320
#include <algorithm>
#include <cstdio>
typedef long long LL;
inline LL f(int x) {
  return x == 1 ? 1 : x - 2;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  printf("%lld\n", f(n) * f(m));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------"<<endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=100009;
ll  sum[mx];
ll  bigmod(ll  a,ll  b, ll  m)
{
    ll  ans=1;
    a%=m;
    while(b)
    {
        if(b&1) ans=(ans*a)%m;
        b>>=1; ; a=(a*a)%m;
    }
    return ans;
}
int  main()
{
    ll  n,k;
    cin>>n>>k;
    for(ll  i=1;i<=k;i++)
    {
        sum[i]=bigmod(k/i,n,mod);
    }
    for(ll  i=k;i>=1;i--)
    {
        for(int j=i*2;j<=k;j+=i)
        {
            sum[i]-=sum[j];
            sum[i]=(sum[i]+mod)%mod;
        }
    }
    ll  ans=0;
    for(ll  i=1;i<=k;i++)
    {
        ans+=(sum[i]*i)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 4308
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

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

vector<ll> t(200010);

void init(void) {
    t[0] = 1;
    for (int i=1;i<200010;i++) {
        t[i] = t[i-1] * 2LL % MOD;
    }
}

int main(void) {
    init();
    int N;
    cin >> N;
    vector<ll> A(200010), B(200010);
    for (int i=0;i<N;i++) cin >> A[i] >> B[i];

    ll z = 0;
    map<pair<ll,ll>,pair<ll,ll>> M;
    for (int i=0;i<N;i++) {
        if (A[i] == 0 && B[i] == 0) z++;
        else if (A[i]==0) M[make_pair(0,1)].first++;
        else if (B[i]==0) M[make_pair(0,1)].second++;
        else {
            ll G = gcd(abs(A[i]),abs(B[i]));
            if (A[i]/abs(A[i])*(B[i]/abs(B[i]))>0) M[make_pair(abs(A[i])/G,abs(B[i])/G)].first++;
            else M[make_pair(abs(B[i])/G,abs(A[i])/G)].second++;
        }
    }
    ll res = 1;
    for (auto itr: M) {
        res = res * (t[itr.second.first] + t[itr.second.second] - 1) % MOD;
    }
    cout << (res+z-1+MOD)%MOD << endl;

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

void Main(){
	ll n, m;
	cin >> n >> m;
	vector<pair<ll,ll>> d(n);
	rep(i,n) cin >> d[i].fi >> d[i].se;

	stable_sort(all(d));

	ll num = 0;	// すでに何個買ったか
	ll ans = 0;
	rep(i,n){
		ll temp = min(d[i].se, m - num);
		ans += d[i].fi * temp;
		num += temp;
		if(num == m) break;
	}

	cout << ans << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  string S;
  int Q;
  cin >> S >> Q;
  int reverseCount = 0;
  string front = "";
  string back = "";
  rep(_, Q)
  {
    int T;
    cin >> T;

    if (T == 1)
    {
      // reverse S
      reverseCount++;
    }
    else
    {
      int F;
      cin >> F;
      char c;
      cin >> c;
      if (F == 1)
      {
        // prepend c
        if (reverseCount & 1)
          back += c;
        else
          front += c;
      }
      else
      {
        // append c
        if (reverseCount & 1)
          front += c;
        else
          back += c;
      }
    }
  }
  reverse(front.begin(), front.end());
  S.append(back);
  S.insert(0, front);
  if (reverseCount & 1)
    reverse(S.begin(), S.end());

  cout << S << endl;
  return 0;
}

Measured memory_bytes: 1348
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	string s;
	int n;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] + n > 90) { s[i] = s[i] + n - 26; }
		else { s[i] += n; }
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define INF 100000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;


int main() {
    
    int d, t, s;
    
    cin >> d >> t >> s;

    if((d*1.0/s)<=t){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n;cin>>n;
    cout<<0<<endl;
    string s;cin>>s;
    if(s=="Vacant"){
        return 0;
    }
    cout<<n/2<<endl;
    string t;cin>>t;
    if(t=="Vacant"){
        return 0;
    }
    ll l,r;
    if(n/2%2){
    if(s==t){
        l=0,r=n/2;
    }else{
        l=n/2;
        r=n-1;
        cout<<n-1<<endl;
        cin>>s;
        if(s=="Vacant"){
            return 0;
        }
        swap(s,t);
    }
    }else{
        if(s!=t){
        l=0,r=n/2;
    }else{
        l=n/2;
        r=n-1;
        cout<<n-1<<endl;
        cin>>s;
        if(s=="Vacant"){
            return 0;
        }
        swap(s,t);
    }
    }
    while(1){
        ll mid=(r+l)/2;
        cout<<mid<<endl;
        string d;
        cin>>d;
        if(d=="Vacant"){
            return 0;
        }
        if((mid-l)%2){
            if(d==s){
                r=mid;
                t=d;
            }else{
                l=mid;
                s=d;
            }
        }else{
            if(d==s){
                l=mid;
                s=d;
            }else{
                r=mid;
                t=d;
            }
        }
    }
}

Measured memory_bytes: 3832
import collections

n = int(input())
a_lst = [int(elem) for elem in input().split()]

c = collections.Counter(a_lst)
cnt = 0

for k in c.keys():
  if c[k] > k:
    cnt += c[k] - k
  elif c[k] < k:
    cnt += c[k]
print(cnt)

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define INF 1e9+1
#define MOD 1e9+7
#define INF64 1e18+1

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  int N,M,L,A,B;
  int K[MAX_N];
  int ans;
  vector<char> C;
  bool bool_ans;

  cin >> A;
  cin >> B;
  if (A == B) {
    N = 0;
    put(N);
  } else {
    if ((A-B)%2 == 0) {
      N = (A+B) /2;
      put(N);
    } else {
      put("IMPOSSIBLE");
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 2e9+7;
const ll  longinf = 1LL<<62;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

ll dp[52][52];

ll comb(int n,int k){
  if(n<k)return 0;
  if(dp[n][k]!=0)return dp[n][k];
  if(k==0)return dp[n][k]=1;
  if(n==k)return dp[n][k]=1;
  return dp[n][k]=comb(n-1,k-1)+comb(n-1,k);
  }

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  ll v[n+1];
  rep(i,n)cin>>v[i];
  v[n]=longinf;
  rep(i,n+1)rep(j,n+1)dp[i][j]=0;
  
  sort(v,v+n);
  ll res=v[n-a];
  int left=lower_bound(v,v+n+1,res)-v;
  int right=upper_bound(v,v+n+1,res)-v;
  int m=right-left,k=right-n+a;
  if(right==n){
    ll ans=0;
    REP(i,a,b+1)ans+=comb(m,i);
    cout<<res<<endl;
    cout<<ans<<endl;
    }
  else{
    ll sum=0;
    reverse(v,v+n);
    rep(i,a)sum+=v[i];
    cout<<setprecision(8)<<1.0*sum/a<<endl;
    cout<<comb(m,k)<<endl;
    }
  return 0;    
  }


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

int main()
{
    ll tst;
//
//    cin >> tst;
//
//    while(tst--)
//    {
//
//    }

ll a,b,i,j,k,l,m,n,p,q,KK,ans=0;
//ll a,b,i,j,k,l,m,n;

cin >> n ;

ll ar[n+10];

for(i=0;i<n;i++)
{
    cin >> ar[i];

}
m = (n+1)/2;

sort(ar,ar+n);
reverse(ar,ar+n);

ll tm[m+10];

for(i=0;i<m;i++)tm[i]  = ar[i],ans+=ar[i];

if(n==1)
{
    cout << 0 << endl;
}
else if(n==2)
{
    sort(ar,ar+n);

    cout << ar[1] << endl;
}
else if(n==3)
{
sort(ar,ar+n);
cout << ar[2] + ar[1]<< endl;
}
else{

if(n%2)
{
    for(i=1;i<m-1;i++)ans+=ar[i];
}
else
{
    for(i=1;i<m-1;i++)ans+=ar[i];
    ans += ar[m-1];
}



cout << ans << endl;
}


//cout << m << endl;
}


Measured memory_bytes: 5968
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        List<List<Integer>> bulbs = new ArrayList<>();
        for (int i = 0; i < M; ++i) bulbs.add(new ArrayList<>());
        for (int i = 0; i < M; ++i) {
            int k = sc.nextInt();
            for (int j = 0; j < k; ++j) {
                bulbs.get(i).add(sc.nextInt()-1);
            }
        }
        List<Integer> p = new ArrayList<>();
        for (int i = 0; i < M; ++i) p.add(sc.nextInt());

        int res = 0;
        for (int bit = 0; bit < (1<<N); ++bit) {
            boolean flag = true;
            for (int i = 0; i < M; ++i) {
                int cnt = 0;
                for (int j = 0; j < bulbs.get(i).size(); ++j) {
                    int s = bulbs.get(i).get(j);
                    if ((bit & (1<<s)) != 0) ++cnt;
                }
                if (cnt % 2 != p.get(i)) flag = false;
            }
            if (flag) ++res;
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
string s;
bool cmp(string c)
{
    string p;
    p=c;
    reverse(c.begin(),c.end());
    if(p==c) return true;
    else return false;
}
int main()
{
    cin>>s;
    int l=s.length();
    string cnt1=s.substr(0,(l-1)/2);
    string cnt2=s.substr((l+3)/2-1,l);
    //cout<<cnt1<<" "<<cnt2<<endl;
    if(cmp(s)&&cmp(cnt1)&&cmp(cnt2)) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 2020;
const int X = 2019;
const int N = 2e5 + 4;
int dp[2][T];
int rest[N];

int main() {
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    rest[0] = 1;
    for(int i = 1; i < s.size(); i++) rest[i] = (rest[i-1]*10)%X;
    reverse(s.begin(),s.end());
    int at = 1;
    int ans = 0;

    for(int i = 0; i < s.size(); i++) {
        memset(dp[at], 0, sizeof dp[at]);
        int ok = ((s[i]-'0')*rest[i])%X;
        dp[at][ok]++;
        if(!ok) ans++;
        for(int j = T-1; j >= 0; j--) {
            if(!dp[!at][j]) continue;
            int x = (j+ok) % X;
            dp[at][x] += dp[!at][j];
            if(!x) ans += dp[!at][j];
        }
        at = !at;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4408
def solve(s):
    mm = 1e9
    for i in range(26):
        char = chr(ord('a') + i)
        ss = s
        c = 0
        while len(set(ss)) > 1:
            sss = ''
            for j in range(len(ss) - 1):
                if ss[j] == char or ss[j + 1] == char:
                    sss += char
                else:
                    sss += ss[j]
            ss = sss
            c += 1
        mm = min(mm, c)
    return mm


def main():
    s = input().strip()
    result = solve(s)
    print(result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n = int(input())
xls = list(map(int, input().split()))
mx = max(xls)
res = 0
for i in range(1, mx + 1):
    s = sum((x - i) ** 2 for x in xls)
    if res == 0:
        res = s
    if s < res:
        res = s
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
int main(){int n,d,x,r,a[d],i=0;std::cin>>n>>d>>x;for(;i<n;i++)std::cin>>a[i];for(i=0;i<n;i++){int t=0,l=1;while(t<=d){t=a[i]*(l)+1;l++;r++;}}std::cout<<r+x<<std::endl;}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int A[310][310];
queue<int> Q[310];
set<int> S;

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; ++i) {
    for (auto j = 0; j < M; ++j) {
      cin >> A[i][j];
      A[i][j]--;
      Q[i].push(A[i][j]);
    }
  }
  int ans = N;
  while (true) {
    bool cont = true;
    for (auto i = 0; i < N; ++i) {
      if (Q[i].empty()) {
        cont = false;
        break;
      }
    }
    if (!cont) break;
    int cnt[310];
    fill(cnt, cnt+M, 0);
    for (auto i = 0; i < N; ++i) {
      cnt[Q[i].front()]++;
    }
    /*
    for (auto i = 0; i < M; ++i) {
      cerr << cnt[i] << " ";
    }
    cerr << endl;
    */
    int t = 0;
    int max_ind = 100000;
    for (auto i = 0; i < M; ++i) {
      if (t < cnt[i]) {
        t = cnt[i];
        max_ind = i;
      }
    }
    assert(max_ind < 100000);
    ans = min(ans, t);
    S.insert(max_ind);
    for (auto i = 0; i < N; ++i) {
      while (!Q[i].empty() && S.find(Q[i].front()) != S.end()) {
        Q[i].pop();
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152