akhauriyash/Code-Regression huggingface dataset:
package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    hs := make([][]int, n)
    for i := 0; i < n; i++ {
        var a, b, c int
        fmt.Scan(&a, &b, &c)
        hs[i] = []int{a, b, c}
    }

    dp := make([][]int, n+1)
    for i := 0; i <= n; i++ {
        dp[i] = make([]int, 3)
    }
    for i := 1; i <= n; i++ {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + hs[i-1][0]
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + hs[i-1][1]
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + hs[i-1][2]
    }
    var m int
    for i := 0; i < 3; i++ {
        if dp[n][i] > m {
            m = dp[n][i]
        }
    }

    fmt.Println(m)
}

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

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

func abs(n int) int {
    if n < 0 {
        return -n
    }
    return n
}


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

int main () {
    int N = 0;
    int tmp = 0;
    cin >> N;

    set<int> s;
    for (int i = 0; i < N; ++i) {
        cin >> tmp;
        s.insert(tmp);
    }

    cout << s.size() << endl;
}


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

using namespace std;

int deg[1234567];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    --v;
    --u;
    deg[v]++;
    deg[u]++;
  }
  for (int i = 0; i < n; i++) {
    if (deg[i] & 1) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using namespace std;

int main(){
    int64_t N,X,M;

    cin >> N >> X >> M;

    int64_t sum =X;
    int64_t An = X;

    vector <int> Anarray;
    Anarray.push_back(X);
    int64_t firstlindex =0;
    int64_t lastlindex =0;

    int finflag=0;

    for(int64_t i=1;i<N;i++){

        int temp =  (An *An ) % M;
        if(temp == 0){
            break;
        }
        for(int64_t j =0; j<i;++j){
            if(temp == Anarray[j]){
                firstlindex = j;
                lastlindex = i;
                int loopAnnum = i - j;
                // 繰り返部分
                int64_t loopsum = 0;
                for (int64_t k = j;k<i;k++){
                    loopsum += Anarray[k];
                }

                int64_t tnum = N -i ;//

                int64_t temp1 = tnum/loopAnnum;
                int64_t temp2 = tnum%loopAnnum;

                sum += loopsum*temp1;

                for (int64_t k = 0;k<temp2;k++){
                    sum += Anarray[j+k];
                }
                finflag=1;
                break;

            }
        }
        if(finflag){
            break;
        }


        An = temp;
        Anarray.push_back(An);
        sum += temp;
    }

    cout<< sum <<endl;
}



Measured memory_bytes: 3716
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    string res = "ABD";
    if(n < 1000){
        res = "ABC";
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	while(1){
		int a, b;
		string S;
		cin >> a >> S >> b;
		if(S == "?")break;
		if(S == "+"){
			cout << a+b << endl;
			continue;
		}else if(S == "-"){
			cout << a-b << endl;
			continue;
		}else if(S == "*"){
			cout << a*b << endl;
			continue;
		}else{
			cout << a / b << endl;
			continue;
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1212
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    VI t, c;
    int x = 1;
    REP(i,n){
        if (i == n - 1 || s[i] != s[i + 1]){
            t.push_back(!(s[i] - '0'));
            c.push_back(x);
            x = 0;
        }
        x++;
    }
    int ans = 0;
    int m = t.size(), sum = 0, j = 0;
    REP(i,m){
        sum += c[i];
        k -= t[i];
        while (k < 0){
            sum -= c[j];
            k += t[j];
            j++;
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1404
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    s = input()
    k = intin()

    for i, c in enumerate(s):
        if i + 1 >= k:
            print(c)
            return
        if c != '1':
            print(c)
            return

    print(s[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3540
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

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

    vector<int> ans(N + 1);

    for (int x = 1; x * x < N; x++) {
        for (int y = 1; y * y < N; y++) {
            for (int z = 1; z * z < N; z++) {
                ll v = x * x + y * y + z * z + x * y + y * z + z * x;
                if (v > N) {
                    continue;
                }
                ans[v]++;
            }
        }
    }

    for (int i = 1; i <= N; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;
}


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

int main(){
    ll s;
    cin>>s;
    set<ll> list;
    list.insert(s);
    ll size=list.size();
    rep(i,1000000){
        if(s%2==0)s=s/2;
        else s=3*s+1;

        list.insert(s);
        if(size==list.size()){
            cout<<i+2<<endl;
            return 0;
        }else{
            size=list.size();
        }
    }
}



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

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

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b ;
  cin >> a >> b ;
  
  if(a*b%2==0){
    cout <<"Even"<<endl ;
  }
  else{
    cout <<"Odd"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>

using namespace std;

int main(void) {
    int N, M, L;
    int i, j, k;
    
    cin >> N >> M >> L;
    
    long long a[N][M], b[M][L], c[N][L];
    
    //input a
    for(i=0; i<N; i++) {
        for(j=0; j<M; j++) {
            cin >> a[i][j];
        }
    }
    
    //input b
    for(i=0; i<M; i++) {
        for(j=0; j<L; j++) {
            cin >> b[i][j];
        }
    }

    
    //calc. c
    for(i=0; i<N; i++) {
        for(j=0; j<L; j++) {
            long long sum = 0;
            for(k=0; k<M; k++) {
                sum += a[i][k]*b[k][j];
            }
            c[i][j] = sum;
        }
    }
    
    //display c
    for(i=0; i<N; i++) {
        for(j=0; j<L; j++) {
            if(j==0) cout << c[i][j];
            else cout << " " << c[i][j];
        }
        cout << endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 3336
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j,k,sum;long long a,b,c,ans;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a%2==0 || b%2==0 || c%2==0)
		printf("0\n");
	else
	{
		ans=a*b;
		if(ans>a*c)
			ans=a*c;
		if(ans>b*c)
			ans=b*c;
		printf("%lld\n",ans);
		return 0;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 k, x;
    cin >> k >> x;
    if (500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline

S = list(input().rstrip('\n'))
# print(S[2:-1])
if S[0] == 'A' and S[2:-1].count('C') == 1:
    S.remove('A')
    S.remove('C')
    S = ''.join(S)
    # print(S)
    if S.islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;         
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, a[N], x;

int main() {
	megaRandom();
	scanf("%d %d", &n, &x);
	for(int i = 1; i <= n; i ++)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);

	int res = 0;
	bool have = 0;
	for(int i = 1; i <= n; i ++) {
		if(x >= a[i]) {
			res ++;
			x -= a[i];
		} else {
			have = 1;
		}
	}
	if(x > 0 && !have)
		res --;
	res = max(res, 0);
	printf("%d\n", res);
	return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  while(cin>>n){
    map<string,long long> vis;
    string s;
    for(int i=0;i<n;i++){
      cin>>s;
      sort(s.begin(), s.end());
      vis[s]++;
    }
    long long ans = 0;
    for(auto it:vis)
      ans+=(it.second-1)*it.second/2;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,cnt = 0;
  cin >> A >> B;
  for(A; A <= B; A++){
    int r,a,b;
    a = A % 10;  //Aの下一桁
    b = A/10%10; //Aの十の位
    r = A/1000;
    if(r == 10*a + b)
      cnt++;
  }
  cout << cnt <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
///1<<3シフト演算子 とは　0001の1を三つずらして1000にする, これは8を表しておりつまりbitは0から7まで
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using ld = long double;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換


int main(){
    
    vector<ll> sum(100000,0);
    int n;
    ll k;
    cin >> n >> k;
    rep(i,n){
        int num;
        int kosuu;
        cin >> num >> kosuu;
        num--;
        sum.at(num) += kosuu;
    }
    int point = 0;
    while(k > 0){
        k -= sum.at(point);
        point++;
    }
    cout << point << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,B,C,D;
int main(){
    cin>>A>>B>>C>>D;
    pr(max(A*B,C*D));
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ary[] = new int[n];
        for(int i=0;i<ary.length;i++)ary[sc.nextInt()-1] = i;
        for(int i=0;i<ary.length;i++)System.out.print(ary[i]+1+" ");
    }
    
}


Measured memory_bytes: 63968
class Array
  def abs; map{|k| k.abs } end
end

n = gets.to_s.to_i
a = gets.to_s.split.map{|t|t.to_i}

n_nega = 1
ans_sum = 0
abs_min = 1_000_000_000

a.each do |t|
  
  ab = t.abs
  
  ans_sum += ab
  
  abs_min = ab if abs_min > ab
  
  n_nega *= -1 if t < 0
  
end

puts n_nega == 1 ? ans_sum : ans_sum - abs_min * 2 

Measured memory_bytes: 8708
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

void cout_vec(vector<long long> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

void cout_mat(vector<vector<long long>> &mat){
    for(int i=0; i<mat.size(); i++){
        vector<long long> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int main(){
    string S;
    cin >> S;

    int N=S.size();
    vector<vector<long long> > dp(N+1, vector<long long>(13,0));
    dp[0][0]=1;

    for(int i=0; i<N; i++){
        for(int j=0; j<13; j++){
            if(S[i]=='?'){
                for(int k=0; k<10; k++){
                    int r = (10*j+k) % 13;
                    dp[i+1][r]+=dp[i][j];
                    dp[i+1][r]%=MOD;
                }
            }else{
                int ints=S[i]-'0';
                int r = (10*j+ints)%13;
                dp[i+1][r]+=dp[i][j];
                dp[i+1][r]%=MOD;
            }
        }
    }

    //cout_mat(dp);

    cout << dp[N][5] << endl;

}

Measured memory_bytes: 13696
# coding: utf-8
#便利そうなので置いとく
import fractions 
import functools 
#再帰関数を使うときは、再帰上限を上げておこうね！
import sys
sys.setrecursionlimit(200000000)
# my functions here!
def pin(type=int):
    return map(type,input().split())
"""
------------------------------------------------------------------
|OBJECTIVE:                                                      |
|Educatinal DP contest("https://atcoder.jp/contests/dp")を解こう!|
------------------------------------------------------------------
"""
#solution:
INF = float("inf")
def Flog_1(N,H):
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    #遷移式を考える h1=0
    dp[0]=0
    dp[1]=abs(H[1]-H[0])#ほら、"2段前"がないから…
    for i in range(2,N):
        hop1=dp[i-1]+abs(H[i-1]-H[i]) 
        hop2=dp[i-2]+abs(H[i-2]-H[i]) 
        #print(hop1,hop2)
        dp[i]=hop1 if hop1<hop2 else hop2
    return dp
#input
N,=pin()
H =list(pin())

#output
print(Flog_1(N,H)[-1])

Measured memory_bytes: 16312
n,k,q=list(map(int,input().split()))
a=[0 for _ in range(n)]
for i in range(q):
  x=int(input())
  a[x-1] += 1
w=q-k+1
for i in range(n):
  if a[i] >= w:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 73248
#include <iostream>
using namespace std;
int main (void) {
    int x, y;
    int group[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

    cin >> x >> y;

    x = group[x];
    y = group[y];

    if (x == y) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	int cor = 0;
	int sum = 0;
	for(int i=0;i<n;i++){
		int t;
		if(cor<=x)sum++;
		cin>>t;
		cor += t;
	}
	if(cor<=x)sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, A, B;
    cin >> N;
    if(N==1) cout << "Hello World" << endl;
    else {
        cin >> A >> B;
        cout << A+B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]

def kadomatsu(i, a, b, c):
  if i == N:
    if min(a, b, c) > 0:
      return abs(a - A) + abs(b - B) + abs(c - C) - 30
    else:
      return float("inf")
  ret0 = kadomatsu(i + 1, a, b, c)
  ret1 = kadomatsu(i + 1, a + l[i], b, c) + 10
  ret2 = kadomatsu(i + 1, a, b + l[i], c) + 10
  ret3 = kadomatsu(i + 1, a, b, c + l[i]) + 10
  return min(ret0, ret1, ret2, ret3)

print(kadomatsu(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d[100000];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>d[i];
	sort(d,d+n);
	cout<<d[n/2]-d[n/2-1]<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int a1,a2,a3,a4,a5,a6,a7;
    scanf("%d%d%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5,&a6,&a7);
    int t=min(a4,a5);
    long long ans=a2;
    ans+=max(2ll*(a1/2+a4/2+a5/2),(a1&&a4&&a5?(2ll*((a1-1)/2+(a4-1)/2+(a5-1)/2)+3):0ll));
    cout<<ans<<endl;
}

Measured memory_bytes: 3768
#include<iostream>

using namespace std;

int r[200000];
int X, K, Q, T, A, s, l;

int main()
{
  int k = 0, t = 0, x = 0, sign = -1;

  cin >> X >> K;
  for(int i = 0; i < K; i++) {
    cin >> r[i];
  }

  l = X;
  
  for(cin >> Q; Q; Q--) {
    cin >> T >> A;
    for(; k<K&T>=r[k]; ) {
      int diff = sign * (r[k] - t);
      x += diff;
      s = min(X, max(0, s + diff));
      l = min(X, max(0, l + diff));
      t = r[k];
      k++;
      sign *= -1;
    }
    T -= t;
    A = min(l, max(s, A + x));
    A = min(X, max(0, A + sign * T));
    cout << A << endl;
  }

  return 0;
}

Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static class Pair implements Comparable<Pair>{
		public int first=0,second=0;

		@Override
		public int compareTo(Pair other) {
			return other.second-this.second;
		}
		
	}
	
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n, m;
		while (true) {
			n = scanner.nextInt();
			m = scanner.nextInt();
			if (n == 0 && m == 0) {
				break;
			}
			Pair[] a = new Pair[m];
			for (int i = 0; i < m; i++) {
				a[i]=new Pair();
				a[i].first=i+1;
			}
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					a[j].second += scanner.nextInt();
				}
			}
			Arrays.sort(a);
			for (int i = 0; i < m; i++)
				System.out.print(a[i].first + (i == m - 1 ? "" : " "));
			System.out.println();
		}
	}
}

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

using namespace std;
typedef long long ll;
int main()
{
    map<string , int>mp;
    int n;
    cin >> n ;
    string s;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> s;
        mp[s]++;
    }
    vector<string>v={"AC" , "WA" , "TLE" , "RE" };
    for(int i = 0 ; i < 4 ;i++)
    {
        cout << v[i] << " x " << mp[v[i]]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int k;
    cin >> k;

    int n = s.size();

    vector<string> t;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i + j > n) continue;
            t.push_back(s.substr(i, j));
        }
    }

    sort(t.begin(), t.end());
    unique(t.begin(), t.end());

    cout << t[k - 1] << endl;

    return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

bool is_match(string &s, string &t, int i) {
    for (int j = 0; j < t.size(); j++) {
        if (s[i + j] == '?') continue;
        if (s[i + j] == t[j]) continue;
        return false;
    }
    return true;
}

string replace(string &s, string &t, int i) {
    string u;
    for (int j = 0; j < i; j++) {
        if (s[j] == '?') u.push_back('a');
        else u.push_back(s[j]);
    }
    for (int j = 0; j < t.size(); j++) {
        u.push_back(t[j]);
    }
    for (int j = i + t.size(); j < s.size(); j++) {
        if (s[j] == '?') u.push_back('a');
        else u.push_back(s[j]);
    }
    return u;
}

int main() {
    string _s, t;
    cin >> _s >> t;

    vector<string> candidate;

    for (int i = 0; i + t.size() <= _s.size(); i++) {
        bool b = is_match(_s, t, i);
        if (!b) continue;
        string s = replace(_s, t, i);
        candidate.push_back(s);
    }
    if (candidate.empty()) {
        cout << "UNRESTORABLE" << endl;
        ret();
    }
    sort(candidate.begin(), candidate.end());
    cout << candidate.front() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e3+10;
const int N = 1e6+10;
const int E = 1e6+10;  
ll n,m,k;
ll a,b;
string s; 

int main(){
	cin>>n;
	ll ans = 0;
	ans += (n/500)*1000;
	n%=500;
	ans+=(n/5)*5;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

std::vector<std::string> gen(int n) {
    if (n == 3) {
        return {
            "a..",
            "a..",
            ".bb"};
    } else if (n == 4) {
        return {
            "abcc",
            "abdd",
            "ccab",
            "ddab"};
    } else if (n == 5) {
        return {
            "aadde",
            "bbg.e",
            "ccgff",
            "..abc",
            "..abc"};
    } else if (n == 6) {
        return {
            "a..ccd",
            "a..f.d",
            ".bbfee",
            "ccda..",
            "f.da..",
            "fee.bb",
        };
    } else if (n == 7) {
        return {
            "a...dde",
            "a...g.e",
            "b...gff",
            "bdde...",
            "cg.e...",
            "cgff...",
            ".aabbcc",
        };
    } else {
        std::terminate();
    }
}

int main() {
    int n;
    std::cin >> n;
    if (n == 2) {
        std::cout << -1 << std::endl;
        return 0;
    }

    std::vector<std::string> ans(n, std::string(n, '.'));
    if (n == 3) {
        ans = gen(3);
    } else {
        int r = n % 4 + 4;
        auto head = gen(r);

        for (int x = 0; x < r; ++x) {
            for (int y = 0; y < r; ++y) {
                ans[x][y] = head[x][y];
            }
        }

        auto back = gen(4);
        int s = r;
        while (s < n) {
            for (int x = 0; x < 4; ++x) {
                for (int y = 0; y < 4; ++y) {
                    ans[s + x][s + y] = back[x][y];
                }
            }
            s += 4;
        }
    }

    for (auto& s : ans) {
        std::cout << s << std::endl;
    }
    return 0;
}


Measured memory_bytes: 2304
// ------------------------------------
// Date:2018/ 2/22
// Problem:ABC 042 IrohaAndHaiku a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int main()
{
  int fCnt,sCnt,n;
  fCnt = sCnt = 0;
  REP(i,3) {
    cin >> n;
    if (n == 5) ++fCnt;
    if (n == 7) ++sCnt;
  }
  if (fCnt == 2 && sCnt == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

def bfs(H,W,S):
	V = [[False for i in range(W)] for j in range(H)]
	qu = deque([(0,0,1)])
	V[0][0] = True
	while(qu):
		p,q,r = qu.popleft()
		S[p][q] = '#'
		for d in [(-1,0), (0,-1), (1,0), (0,1)]:
			s = p+d[0]
			t = q+d[1]
			if s < 0 or t < 0 or s >= H or t >= W:
				continue
			if s == (H-1) and t == (W-1) and S[s][t] == '.':
				return r+1
			if S[s][t] == '.' and V[s][t] == False:
				V[s][t] = True
				qu.append((s,t,r+1))
	return -1

H, W = list(map(int, input().split()))
S = []
cnt = 0
for i in range(H):
	a = str(input())
	tmp = []
	for i in a:
		if (i == '.'):
			cnt += 1
		tmp.append(i)
	S.append(tmp)

step = bfs(H, W, S)

if (step != -1):
	print(cnt - step)
else:
	print(step)


Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main() {
	char b;
	cin >> b;

	if (b == 'A') {
		cout << 'T' << endl;
	}
	else if (b == 'T') {
		cout << 'A' << endl;
	}
	else if (b == 'G') {
		cout << 'C' << endl;
	}
	else if (b == 'C') {
		cout << 'G' << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int t = 0;
		
		if(a > b){
		t = a;
		a = b;
		b = t;
		}
		if(b > c){
		t = b;
		b = c;
		c = t;
		}
		if(a > b){
		t = a;
		a = b;
		b = t;
		}
		
		System.out.println(a+" "+b+" "+c);
	}
}

Measured memory_bytes: 26172
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    int N; cin >> N;
    vector<int> a(N),b(N),c(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++) cin >> b[i];
    for(int i = 0; i < N; i++) cin >> c[i];
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());

    /* 
    for(int i = 0; i < N; i++) cout << a[i] << " ";
    cout << endl;
    for(int i = 0; i < N; i++) cout << b[i] << " ";
    cout << endl;
    for(int i = 0; i < N; i++) cout << c[i] << " ";
    cout << endl;
    */
    ll am,cm;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        am = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
        cm = upper_bound(c.begin(),c.end(),b[i]) - c.begin();
        ans += am*(N - cm);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll n,m;
ll a[100000],b[100000];
vector<ll> st_cnt[100000];
ll end_cnt[100000];

int main() {
    std::cin >> n>>m;
    Fill(st_cnt,0);
    Fill(end_cnt,0);
    for (int i = 0; i < m; i++) {
        std::cin >> a[i]>>b[i];
        a[i]--;
        b[i]--;
        st_cnt[a[i]].push_back(b[i]);
        end_cnt[b[i]]++;
    }
    
    vector<ll> now;
    ll result = 0;
    for (int i = 0; i < n; i++) {
        if(end_cnt[i]>0){
            result++;
            for(auto&e : now){
                end_cnt[e]--;
            }
            now = {};
        }
        for(auto&e : st_cnt[i]){
            now.push_back(e);
        }
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 8700
#include<iostream>
#include<cstring>
using namespace std;
string a,b="CF";
int al,bl;
int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){
            bl++;
            if(bl==2)
                break;
        }
    if(bl==2) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 768
package main

import "fmt"

func pow(a, n int) (b int) {
	b = 1
	for n > 0 {
		b *= a
		n--
	}
	return
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if b < 100 {
		fmt.Println(b * pow(100, a))
	} else {
		fmt.Println((b + 1) * pow(100, a))
	}
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
 
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APassword solver = new APassword();
        solver.solve(1, in, out);
        out.close();
    }
 
    static class APassword {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
          	int k = sc.nextInt();
          	long num=1;
          	for (int i = 0 ; i < n-1 ;i++){
              num*=(k-1);
            }
          	out.println(num*k);
        }
    }
 
    static class inputClass {
        BufferedReader br;
        StringTokenizer st;
 
        public inputClass(InputStream in) {
 
            br = new BufferedReader(new InputStreamReader(in));
        }
 
        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
    }
}
 


Measured memory_bytes: 22996
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')

n,m = inpl()
a = ""
b = ""
for i in range(m):
    a += str(n)

for j in range(n):
    b += str(m)

if (a>b):
    print(b)
else:
    print(a)

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll n,k;
ll ans;
//string s;
signed main(){
	acc_io;
	ans=0;
	cin>>n>>k;
	int a[200010];
	rep(i,1,n+1) cin>>a[i];
	ll sta=0;
	ll cyc=1;
	int next=1;
	int pass[200010]={0};
	pass[1]=1;
	while(1){
		if(pass[a[next]]){
			sta=pass[a[next]]-1;
			cyc=cyc-pass[a[next]]+1;
			break;
		}
		else{
			cyc++;
			pass[a[next]]=cyc;
			next=a[next];
		}
	}
//	cout<<sta<<" "<<cyc<<" "<<endl;
	if(k>(sta+cyc)){
		k=(k-sta)%cyc;
		k+=sta;
		k+=cyc;
	}
//	cout<<k<<endl;
	next=1;
	rep(i,0,k){
		next=a[next];
//		cout<<next<<endl;
	}
	cout<<next<<endl;
	return 0;
}


Measured memory_bytes: 5180
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
main()
{
    int n;
    while( cin >> n, n )
    {
        vector< int > b(n);
        for( int i = 0; i < n; i++ )cin >> b[i];
        for( int cnt = 0;; cnt++ )
        {
            if( cnt > 10000 ) {puts("-1");break;}
            bool ok = 1;
            for( int i = 0; i < b.size(); i++ )
            {
                if( b[i] != i + 1 ) ok = 0;
            }
            if( ok ){cout << cnt << endl;break;}
            for( int i = 0; i < b.size(); i++ )b[i]--;
            b.push_back( b.size() );
            b.erase( remove( begin(b), end(b), 0 ), end(b) );
        }
    }    
}


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

using namespace std;

int n;
char str[110];
int maxi[30];

int main() {
    int i, p, j;

    scanf("%s",str);
    n = strlen(str);
    for (j=0;j<26;j++) {
        p = -1;
        for (i=0;i<n;i++) {
            if (str[i] == 'a'+j) {
                if (maxi[j]<i-p) {
                    maxi[j]=i-p;
                }
                p=i;
            }
        }
        if (maxi[j]<n-p) maxi[j]=n-p;
    }
    int mini = 987654321;
    for (i=0;i<26;i++) {
        if (mini>maxi[i]) mini = maxi[i];
    }
    printf("%d\n",mini-1);

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n,m;
  while(cin>>n>>m,n+m) {
    vector<int> v;
    REP(i,n)
      v.push_back(i+1);
    int pos = -1;
    int size = n;
    while(v.size()>1) {
      pos = (pos+m)%v.size();
      v.erase(v.begin()+pos);
      pos--;
    }
    cout << v[0] << endl; 
  }
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N, A, B;
vector<ll> v;

void init()
{
	cin >> N >> A >> B;
	CINV(v, N);
	sort(all(v), greater<ll>());
}

ll memo[100][100];

ll ncr(int n, int r)
{
	if (n < r || r < 0) return 0;
	if (n-r < r) return ncr(n, n-r);
	if (memo[n][r]) return memo[n][r];
	if (r == 0) return memo[n][r] = 1;
	return memo[n][r] = ncr(n-1, r-1) + ncr(n-1, r);
}


void solve()
{
	if (v[0] != v[A-1]) {
		int x = 0, y = 0;
		rep(i, N) x += v[A-1] == v[i];
		rep(i, A) y += v[A-1] == v[i];
		double d = 0;
		rep(i, A) d += v[i];
		cout << fixed << setprecision(12) << d / A << endl;
		cout << ncr(x, y) << endl;
		return;
	}
	int x = 0;
	rep(i, N) x += v[0] == v[i];
	ll res = 0;
	reps(i, A, B+1) res += ncr(x, i);
	cout << v[0] << endl;
	cout << res << endl;
}

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

int A[505];

long long func(int g, int N)
{
    vector<int> X;
    long long ans = 0;

    for(int i=1; i<=N; i++)
        X.push_back(A[i] % g);
    
    sort(X.begin(), X.end());
    int i = 0, j = X.size() - 1;

    while(i < j)
    {
        int x = X[i], y = g - X[j];
        int z = min(x, y);

        X[i] -= z, X[j] = (X[j] + z) % g;
        ans += z;

        if(X[i] == 0)
            i++;
        if(X[j] == 0)
            j--;
    }

    return ans;
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

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

    int sum = 0;

    for(int i=1; i<=N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }

    for(int i=sum; i>=1; i--)
    {
        if(sum % i)
            continue;
        
        if(func(i, N) <= K)
        {
            cout << i << "\n";
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
bool b[8];
int main() {
	int n;
	cin >> n;
	long long m = 0, a = 0, r = 0, c = 0, h = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M')m++;
		if (s[0] == 'A')a++;
		if (s[0] == 'R')r++;
		if (s[0] == 'C')c++;
		if (s[0] == 'H')h++;
	}
	cout << m * a*r + m * a*c + m * a*h + m * r*c + m * r*h + m * c*h + a * r*c + a * r*h + a * c*h + r * c*h;
	return 0;
}

Measured memory_bytes: 256
s = input()

ans = 1000
for cur in set(s):
    count = 0
    t_count = 0
    for i in s:
        if i == cur:
            count = max(count, t_count)
            t_count = 0
        else:
            t_count += 1

    count = max(count, t_count)
    ans = min(ans, count)

print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;ans%=mod;}b/=2;a*=a;a%=mod;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INF=0x3f3f3f3f;
#define Pa pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main()
{
    int n,a;
    si(n);si(a);
    n%=500;
    
    if(n<=a) cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
n = input()
k = int(input())

if len(n) <= k:
    cnt = 0
    for i in range(1,int(n)+1):
        if len(str(i)) - str(i).count('0') == k:
            cnt += 1
    print(cnt)
    exit()

cnt = 0
l = len(n)
def combi(n,k):
    ans = 1
    if k == 0:
        return ans
    for i in range(k):
        ans = ans * (n-i) // (i+1)
    return ans
flag = 0
for i in range(l):
    if flag > k:
        break
    if n[i] == '0':
        if i == l-1 and k == flag:
            cnt += 1
        continue
    flag += 1
    cnt += int(((int(n[i])-1)*9**(k-flag))*combi(l-i-1,k-flag) + 9**(k-flag+1)*combi(l-i-1,k-flag+1))

print(cnt)

Measured memory_bytes: 3064
n = STDIN.gets.to_i

n1 = STDIN.gets.to_i
n2 = STDIN.gets.to_i

max = n1
min = n1

if n1 > n2 then
  min = n2
  diff = n2 - n1
  max = n2
else
  max = n2
  diff = n2 - n1
end


(3..n).each { |i|
  x = STDIN.gets.to_i

  if x > max then
    diff = x - min if x - min > diff
    max = x
  elsif x <= min then
    diff = x - max if x - max > diff
    min = x
    max = x
  end
}
puts diff

Measured memory_bytes: 8772
package main
import(
  "fmt"
)
func main(){
  var s, ans string
  var n int
  fmt.Scan(&n, &s)
  if len(s)<=n{
    fmt.Println(s)
  }else{
    ans=s[:n]+"..."
    /*for i=0;i>n;i++{
      ans+="..."
    }*/
    fmt.Println(ans)
    /*for i=0;i<n;i++{
      if i<n{
        fmt.Print(s[i])
      }else{
        fmt.Print(".")
      }
    }*/
  }
}


Measured memory_bytes: 1760
N = int(input())
min = N//1.08
min_a = N%1.08
if min_a != 0:
  min = min +1
max = (N + 1)//1.08
max_a = (N + 1)%1.08
if min > max:
  print(':(')
else:
  print(int(min))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	string s; cin >> s;
	cout << (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ? "Bad\n" : "Good\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n,k;
    cin >> n >> k;
    vi p(n);
    rep(i,n) cin >> p.at(i);
    sort(p.begin(), p.end());
    ll res = 0;
    rep(i,k){
        res += p.at(i);
    }
    cout << res << endl;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> candy(n);
    for (int i = 0; i < n; i++){
        cin >> candy.at(i);
    }
    sort(candy.begin(), candy.end());
    int count = 0;
    for (int i = 0; i < n; i++){
        if ((x >= candy.at(i) && i < (n - 1)) || 
            (x == candy.at(i) && i == (n - 1))){
            count++;
            x -= candy.at(i);
        }
        else{
            break;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256