akhauriyash/Code-Regression huggingface dataset:
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((s (map '(simple-array uint4 (*)) #'digit-char-p (read-line)))
         (n (length s))
         (res 0))
    (declare ((integer 1 10) n)
             (uint62 res))
    (dotimes (l n)
      (loop for r from l to n
            for num of-type uint62 = 0 then (+ (* 10 num) (aref s (- r 1)))
            do (incf res
                     (* num
                        (expt 2 (max 0 (- l 1)))
                        (expt 2 (max 0 (- n r 1)))))))
    (println res)))

#-swank(main)


Measured memory_bytes: 8680
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

  // 群数列: グループg内でk番目
  lint g;
  lint k = N-1;
  for(g=1; g<20; g++) {
    if(k < pow(26, g)) break;
    k -= pow(26, g);
  }

  // 答えはg桁
  string ans;
  while(g--) {
    ans += 'a' + (k%26);
    k /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 4016
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, H, Hb, cnt = 0, ans = 0;
    cin >> N >> Hb;
    REP(i, N - 1) {
        cin >> H;
        if (H <= Hb) {
            cnt++;
        }
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
        Hb = H;
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))

count = 0
if N<=2:
    print(0)
    exit()

for i in range(N-2):
    L1 =L[i]
    for s in range(i+1,N-1):
        L2 = L[s]
        if L1 == L2:
            continue
        for n in range(s+1,N):
            L3=L[n]
           
            if L1==L3 or L2 == L3:
                continue

            if L1+L2<=L3 or L1+L3<=L2 or L2+L3<=L1:
                continue
            else:
                count+=1
print(count)
            


Measured memory_bytes: 9200
import qualified Data.Vector.Unboxed as VU
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.List


-- 1 <= damageOther < damageTarget <= 10^9
isPossibleWith :: VU.Vector Int -> Int -> Int -> Int -> Bool
isPossibleWith hps damageTarget damageOther numMagics
  = (<= numMagics) $ VU.sum
    $ VU.map (\hp -> max 0 $ (hp - damageMin + damageDiff - 1) `div` damageDiff)
    $ hps
  where
    damageMin = damageOther * numMagics
    damageDiff = damageTarget - damageOther

query :: VU.Vector Int -> Int -> Int -> Int
query hps damageTarget damageOther = binSearch 0 (10 ^ 9)
  where
    binSearch ng ok
      | ok - ng <= 1 = ok
      | isPossibleWith hps damageTarget damageOther mid = binSearch ng mid
      | otherwise = binSearch mid ok
      where
        mid = (ng + ok) `shiftR` 1

main :: IO ()
main = do
  [n, damageTarget, damageOther]
    <- unfoldr (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  hps <- VU.unfoldrN n (BSL.readInt . BSL.dropWhile (< '-'))
         <$> BSL.getContents
  print $ query hps damageTarget damageOther

Measured memory_bytes: 2684
// inputに入力データ全体が入る
function Main(input) {
inp = input.split('\n')
n = inp[0]
nums = inp[1].split(' ')
min = 1000000001
max = 0
for(i=0;i<n;i++){
	a = ~~nums[i]
	if(a < min){
		min = a
	}
	if(a > max){
		max = a
	}

}
console.log('%d',max - min);
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <cstdio>
using namespace std;
int a[100005];
int main(void)
{
	int n,i,h;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=1,h=a[0];i<n;i++){
		if(h-a[i]>=2){
			printf("No");
			return 0;
		}
		if(a[i]>h) h=a[i];
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
//g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG b.cpp
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define scint(x) scanf("%d", &x)
#define scll(x) scanf("%lld", &x)

typedef long long ll;

int main(){
    int x, y;
    scint(x);
    scint(y);

    printf("%d\n", x + y/2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    while (n--) {
	string snake;
	cin >> snake;
 
	string s = snake.substr(0, 2);
 
	if (s != ">^" && s != ">\'") {
	    puts("NA");
	    continue;
	}
 
	if (s == ">\'") {
	    int a = 0;
	    int p = 2;
	    bool flg = true;
	    int len = (int)snake.size();
	    for (int i = 2; i < len; i++, p++) {
		if (snake[i] == '#') break;
		else if (snake[i] == '=') a++;
		else {
		    flg = false;
		    break;
		}
	    }
 
	    if (!flg) {
		puts("NA");
		continue;
	    }      
 
	    int b = 0, q = p + 1;
	    for (int i = q; i < len; i++, p++) {
		if (snake[i] == '~') break;
		else if (snake[i] == '=') b++;
		else {
		    flg = false;
		    break;
		}
	    }
 
	    if (!flg || a == 0 || b == 0 || a != b) {
		puts("NA");
		continue;
	    }  
 
	    if (a == b && snake[len-1] == '~') {
		puts("A");
	    } else {
		puts("NA");
	    }
	} else {
	    bool ok = true;
	    int p = 0;
	    string ss = "";
	    int len = (int)snake.size();
 
	    if (len < 6 || len % 2) {
		puts("NA");
		continue;
	    } 
 
	    for (int i = 2; i < len-2; i++, p++) {
		ss += snake[i];
		if (p == 1) {
		    p = -1;
		    if (ss != "Q=") {
			ok = false;
			break;
		    }
		    ss = "";
		}
	    }
 
	    if (snake[len-2] == '~' && snake[len-1] == '~' && ok) {
		puts("B");
	    } else {
		puts("NA");
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
map<int ,int > m ;
int n ;
int main(){
    scanf("%d",&n) ;
    for (int i=0;i<n;i++){
        int d ;
        scanf("%d",&d) ;
        m[d]++ ;
    }
    int co = 0 ;
    unsigned long long  area = 1;
    map<int,int> ::reverse_iterator itr ;
    for (itr=m.rbegin();itr!=m.rend() && co!=4;itr++)
    {
        if(itr->second <2)
            continue ;
        else if(itr->second >=2 ){
            if(itr->second >=4 && co ==0 ){
                co = 4;
                area =  itr->first*1ll*itr->first ;
            }
            else{
                area *= itr->first ;
                co +=2 ;
            }
        }
    }
    if(co!=4)
        printf("0");
    else
        printf("%llu",area ) ;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  ll ans = 0;
  vector<bool> lose(n, false);
  for (int i = 0; i < n; ++i) {
    if (i - k >= 0 && t[i] == t[i - k] && !lose[i - k]) {
      lose[i] = true;
      continue;
    }
    if (t[i] == 'r') {
      ans += p;
    } else if (t[i] == 's') {
      ans += r;
    } else if (t[i] == 'p') {
      ans += s;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
//#define int long long int
#define endl "\n"
using namespace std;
long long int countt =0;
long long int calc(long long int c)
{
	if(c==1)
		return 1;
	else
	{
		return 1+2*calc(ceil(c/2));
	}
	//return countt;
}
void solve()
{
	//Enter your code here Tanmay:)
	long long int n;
	cin>>n;
	cout<<calc(n);
	//cout<<count;

}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
/*
int eulortotent(int n)
     {
    //Enter your code here Tanmay:)
    int total=n;
        for(int p=2;p*p<=n;p++)
        {
            if (n%p==0)
        {
            total /= p;
            total *= (p-1);
            while ( n % p == 0 ) 
                n /= p;
        }
    }

    if(n>1)
    {
        total/=n;
        total*=(n-1);
    }

  return total;
}
*/

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	long long int a,b;
	long long int data;
	long long int max,min,high,low;	//max=Ååöñ,min=Å¬ö{
	
	while(scanf("%lld %lld",&a,&b)==2){
		if(a<b){
			data=a;
			a=b;
			b=data;
		}
		if(b==0) max=a;
		else{
			data=a%b;
			low=b;
			while(data!=0){
				high=low;
				low=data;
				data=high%low;
			}
			max=low;
		}
		min=a*b/max;
		
		printf("%lld %lld\n",max,min);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 2147483647

int main() {
	ios_base::sync_with_stdio(false);
  
	int n; cin >> n;
	vector<int> a(n); 
	vector<int> b(n+1);
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i]; 
	}
	b[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	c[0] = 0;
	for (int i = 1; i <= n-1; i++) {
		cin >> c[i];
	}

	int s = 0; // satisfaction 
	for (int i = 0; i < n; i++) {
		if (i == 0 || a[i] - a[i-1] != 1) {
			s += b[a[i]]; // s += 4
		}
		else if(a[i] - a[i-1] == 1){ // 1 -> 2
			s += (b[a[i]] + c[a[i]-1]);
		}
	}
	cout << s << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

 
int main(){
	ll n; IN(n);
	ll mx = 1;
	for(ll i=1; i*i<=n; i++){
		ll t = n/i;
		if(t*i == n) chmax(mx,i);
	}
	cout << (mx + (n/mx) -2) << el;
	return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
signed main(){
  int a;
  cin>>a;
  vector<int> dp(a,100000000000);
  int c[a];
  fo(i,a)
    cin>>c[i];
  dp[0]=0;
  for(int i=0;i<a;i++){
      int t=dp[i];
      dp[i+1]=min(dp[i+1],t+abs(c[i]-c[i+1]));
      dp[i+2]=min(dp[i+2],t+abs(c[i]-c[i+2]));
                       }
  cout<<dp[a-1]<<endl;
                       }


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

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

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

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

    for (int i = G.size() -1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;

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

    shellSort(A, n);

    cout << G.size() << endl;

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

    return 0;
}



Measured memory_bytes: 7132
#include<bits/stdc++.h>
#define ll long long
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
#define mod 1000000007
#define inf (1ll<<60)
using namespace std;

int main()
{
    iof;
    ll n,k; cin>>n>>k;
    ll arr[n];
   // cin>>arr[0];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
        //arr[i]-=arr[0];
        //k-=arr[0];
    ll dp[k+1];
    for(ll i=0;i<=k;i++)
        dp[i]=1;
    for(ll i=1;i<=k;i++)
    {
        for(ll j=0;j<n;j++)
        {
            if(arr[j]>i)
                break;
            else
                dp[i]=min(dp[i],1-dp[i-arr[j]]);
        }
    }
    /*for(ll i=1;i<=k;i++)
        cout<<dp[i]<<" ";*/
    if(dp[k])
     cout<<"Second"<<endl;
     else
     cout<<"First"<<endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	int c = stoi(a + b);
	int x = sqrt(c);
	if (c == x * x) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static int N;
  public static int A;
  public static int B;
  public static int C;
  public static int[] l;
  public static int mp;

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    N = sc.nextInt();
    A = sc.nextInt();
    B = sc.nextInt();
    C = sc.nextInt();

    l = new int[N];

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

    sc.close();

    mp = 99999999;

    dfs(0, 0, 0, 0, 0, 0, 0);

    System.out.println(mp);

  }

  public static void dfs (int i, int a, int b, int c, int acount, int bcount, int ccount) {

    if (i == N) {

      int mp_ = 0;

      if (a != 0 && b != 0 && c != 0) {

        if (acount != 0){
          mp_ += (acount - 1) * 10;
        }

        if (bcount != 0){
          mp_ += (bcount - 1) * 10;
        }

        if (ccount != 0){
          mp_ += (ccount - 1) * 10;
        }

        mp_ += Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C);

        mp = Math.min(mp, mp_);

      }

      return;
    }

    dfs(i+1, a, b, c, acount, bcount, ccount);

    dfs(i+1, a + l[i], b, c, acount+1, bcount, ccount);

    dfs(i+1, a, b + l[i], c, acount, bcount+1, ccount);

    dfs(i+1, a, b, c + l[i], acount, bcount, ccount+1);
    
    return;
    
  }

}

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

#define EPS 1e-9

typedef complex<double> P;
typedef const P &rP;
typedef pair<P,P> seg;

const double pi = acos(-1.0);

double dot(rP a, rP b){
	return real(a) * real(b) + imag(a) * imag(b);
}

double cross(rP a, rP b){
	return real(a) * imag(b) - imag(a) * real(b);
}

void intrcc(rP p1, double r1, rP p2, double r2, vector<P> &ret){
	double d = abs(p2 - p1);
	double phi = arg(p2 - p1);
	
	double ct = (d * d + r1 * r1 - r2 * r2) / (2.0 * d * r1);
	if(abs(d) < EPS || abs(ct) > 1.0 + EPS){ return; }
	if(ct > 1.0){ ct = 1.0; }
	else if(ct < -1.0){ ct = -1.0; }
	
	double theta = acos(ct);

	ret.push_back(p1 + polar(r1, phi + theta));
	ret.push_back(p1 + polar(r1, phi - theta));
}

void intrlc(const seg &s, rP pc, double r, vector<P> &ret){
	rP p1 = s.first, p2 = s.second;
	P v12 = p2 - p1;
	P v1c = pc - p1;

	double a = norm(v12);
	double b = -dot(v12, v1c);
	double c = norm(v1c) - r * r;

	double D = b * b - a * c;
	if(D < -EPS || abs(a) < EPS){ return; }
	D = max(D, 0.0);

	double t1 = (-b + sqrt(D)) / a;
	double t2 = (-b - sqrt(D)) / a;

	ret.push_back(p1 + v12 * t1);
	ret.push_back(p1 + v12 * t2);
}

void intrll(const seg &s, const seg &t, vector<P> &ret){
	rP pa1 = s.first, pa2 = s.second, pb1 = t.first, pb2 = t.second;
	P da12 = pa2 - pa1;
	P db21 = pb1 - pb2;
	P dab1 = pb1 - pa1;
	double D = cross(da12, db21);
	if(abs(D) > EPS){
		double t = cross(dab1, db21) / D;
		ret.push_back(pa1 + t * da12);
	}
}

bool check(rP z, rP p, double r, double s, double t){
	double d = abs(z - p);
	if(d < EPS){ return true; }
	if(abs(z - p) > r + EPS){ return false; }
	double a = arg(z - p) - 6.0 * pi;
	while(a < s - EPS){
		a += 2.0 * pi;
	}
	return a < t + EPS;
}

vector<P> ps;
vector<double> rs, ss, ts;

int counton(rP z){
	int ret = 0;
	for(int i = 0; i < ps.size(); ++i){
		if(check(z, ps[i], rs[i], ss[i], ts[i])){
			++ret;
		}
	}
	return ret;
}

int main(){
	vector<P> chk;
	vector<seg> segs;
	chk.reserve(150000);
	segs.reserve(300);

	int T;
	scanf("%d", &T);
	while(T--){
		chk.clear();
		segs.clear();

		int m;
		scanf("%d", &m);
		ps.resize(m);
		rs.resize(m);
		ss.resize(m);
		ts.resize(m);
		vector<P> lss(m), lts(m);
		double x, y;
		for(int i = 0; i < m; ++i){
			scanf("%lf%lf%lf%lf%lf", &x, &y, &rs[i], &ss[i], &ts[i]);
			ps[i] = P(x, y);
			ss[i] *= pi / 180.0;
			ts[i] *= pi / 180.0;
			if(ts[i] < ss[i]){ ts[i] += 2.0 * pi; }
			
			segs.push_back(seg(ps[i], ps[i] + polar(rs[i], ss[i])));
			segs.push_back(seg(ps[i], ps[i] + polar(rs[i], ts[i])));
		}

		for(int i = 1; i < ps.size(); ++i)
		for(int j = 0; j < i; ++j){
			intrcc(ps[i], rs[i], ps[j], rs[j], chk);
		}
		for(int i = 0; i < ps.size(); ++i)
		for(int j = 0; j < segs.size(); ++j){
			intrlc(segs[j], ps[i], rs[i], chk);
		}
		for(int i = 1; i < segs.size(); ++i)
		for(int j = 0; j < i; ++j){
			intrll(segs[i], segs[j], chk);
		}

		int ans = 1;
		for(int i = 0; i < chk.size(); ++i){
			ans = max(ans, counton(chk[i]));
		}

		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
string s;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in k;
  cin>>s>>k;
  in n=sz(s);
  const in ms=26;
  in c;
  forn(i,n){
    c=s[i]-'a';
    if(i==n-1){
      c+=k;
      c%=ms;
      s[i]='a'+c;
    }
    else{
      if(c!=0 && ms-c<=k){
	s[i]='a';
	k-=ms-c;
      }
    }
  }
  cout<<s<<endl;
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int mod=1e9+7;
const int N=21;

int cache[(1<<N)+5];
int n;
int a[22][22];

int dp(int mask)
{
     if(mask==0)
          return 1;
     int &ans=cache[mask];     
     if(ans!=-1)
          return ans;
     ans=0;
  	 int pos=n-(__builtin_popcount(mask))+1;
     for(int i=0;i<n;i++)
     {
          if(mask&(1<<i) && a[pos][i+1])
               ans=(ans+dp(mask&(~(1<<i))))%mod;
     }
     return ans;
}

int32_t main()
{
     memset(cache,-1,sizeof cache);
     cin>>n;
     for(int i=1;i<=n;i++)
     {
          for(int j=1;j<=n;j++)
               cin>>a[i][j];
     }
     cout<<dp((1<<n)-1);
}


Measured memory_bytes: 16640
'use strict'

function Main(input) {
    const n = input;
    const result = isHarshadNumber(n) ? 'Yes' : 'No';
    console.log(result);
}

function isHarshadNumber(n) {
    let total = n.split("\n")[0].split('').reduce((a, b) => parseInt(a) + parseInt(b));
    const is_harshad_number = (n % total) === 0;
    if (is_harshad_number) return true;
    return false;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
user_input, acceptable_height = input().split(" ")
user_input = int(user_input)
acceptable_height = int(acceptable_height)
friend_height = input().split(" ")
for index, value in enumerate(friend_height):
    friend_height[index] = int(value)

for i in friend_height:
    if i < acceptable_height:
        user_input -= 1
print(user_input)


Measured memory_bytes: 9992
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << newl;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li r, g, b, n;
    cin >> r >> g >> b >> n;

    li res = 0;
    rep(ir, 3010) {
        rep(ig, 3010) {
            li rest = n - ir * r - ig * g;
            if (rest >= 0 && rest % b == 0) {
                res++;
            }
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  vector<int> v[n];
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  bitset<200000> s,t;
  s.set(0);
  t.set(n-1);
  rep(i,v[0].size()) s.set(v[0][i]);
  rep(i,v[n-1].size()) t.set(v[n-1][i]);
  if((s&t).count()) pr("POSSIBLE");
  else pr("IMPOSSIBLE");
}

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


Measured memory_bytes: 12016
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int>> adj[MAX]; // 重み付き有向グラフの隣接リスト表現

void dijkstra()
{
  priority_queue<pair<int, int>> PQ;
  int color[MAX];
  int d[MAX];
  for (int i = 0; i < n; i++)
  {
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while (!PQ.empty())
  {
    pair<int, int> f = PQ.top();
    PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    // 最小値を取り出し、それが最短でなければ無視
    if (d[u] < f.first * (-1))
      continue;

    for (int j = 0; j < adj[u].size(); j++)
    {
      int v = adj[u][j].first;
      if (color[v] == BLACK)
        continue;
      if (d[v] > d[u] + adj[u][j].second)
      {
        d[v] = d[u] + adj[u][j].second;
        // priority_queueはデフォルトで大きい値を優先するため-1をかける
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }
  for (int i = 0; i < n; i++)
  {
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main()
{
  int k, u, v, c;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> u >> k;
    for (int j = 0; j < k; j++)
    {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }
  dijkstra();
  return 0;
}


Measured memory_bytes: 8028
#include <stdio.h>
long long t[2], a[2], b[2];
long long w, x, y, z, e, f;
long long ans;
int main() {
	scanf("%lld%lld", t, t + 1);
	scanf("%lld%lld", a, a + 1);
	scanf("%lld%lld", b, b + 1);
	if (a[0] == b[0])printf("wa\n");
	if (a[1] == b[1])printf("wa\n");
	x = t[0]; y = t[1];
	w = b[0] - a[0];
	z = b[1] - a[1];
	e = w * x + z * y;
	if (e == 0) {
		printf("infinity\n");
		return 0;
	}
	if (e > 0) {
		w = -w;
		z = -z;
		e = -e;
	}
	if (w < 0) {
		printf("0\n");
		return 0;
	}
	f = w * x;
	e = -e;
	ans = f / e * 2;
	if (f % e)ans++;
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

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



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

	cin >> N;
	vector<long long int>num(N * 2 + 1);
	vector<long long int>sum(N * 2 + 1);
	for (int i = 0; i < N; i++) {
		cin >> num[i];
		M += num[i];
		num[i + N] = num[i];
	}
	sum[0] = num[0];
	for (int i = 0; i < N * 2; i++) {
		sum[i] = sum[i - 1] + num[i];
	}
	sum[N * 2] = sum[N * 2 - 1] + num[0];
	for (int i = 1; i <= N; i++) {
		L = i;
		R = i + N - 2;
		long long int mid;
		while (R - L > 1) {
			mid = (R + L + 1) / 2;
			if (sum[mid] - sum[i - 1] <= M / 3) {
				L = mid;
			}
			else {
				R = mid;
			}
		}
		mid = L;
		L = mid + 1;
		R = i + N - 1;
		long long int med;
		while (R - L > 1) {
			med = (R + L + 1) / 2;
			if (sum[med] - sum[mid] <= (M - (sum[mid] - sum[i - 1])) / 2) {
				L = med;
			}
			else {
				R = med;
			}
		}
		//cout << sum[mid] - sum[i - 1] << " " << sum[L] - sum[mid] << " " << sum[i + N - 1] - sum[L + 1] << endl;
		K = max({ K,min({sum[mid] - sum[i - 1],sum[L] - sum[mid],sum[i + N - 1] - sum[L]}),min({sum[i + N - 1] - sum[L + 1],sum[mid] - sum[i - 1],sum[L + 1] - sum[mid]}) });
		//cout << K << " " << mid << " " << L << endl;
	}
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 5996
import queue
def main():
    h, w = map(int, input().split())
    s = [list(input().rstrip()) for _ in range(h)]
    q = queue.Queue()
    t = [[10**9]*w for _ in range(h)]
    f = [[True]*w for _ in range(h)]
    if s[h-1][w-1] == "#":
        t[h-1][w-1] = 1
    else:
        t[h-1][w-1] = 0
    q.put([h-1, w-1])
    while not q.empty():
        y, x = q.get()
        if y < h-1 and x < w-1:
            py = t[y+1][x]
            if s[y][x] == "#" and s[y+1][x] == ".":
                py += 1
            px = t[y][x+1]
            if s[y][x] == "#" and s[y][x+1] == ".":
                px += 1
            t[y][x] = min(py, px)
        elif y < h-1 and x == w-1:
            py = t[y+1][x]
            if s[y][x] == "#" and s[y+1][x] == ".":
                py += 1
            t[y][x] = py
        elif y == h-1 and x < w-1:
            px = t[y][x+1]
            if s[y][x] == "#" and s[y][x+1] == ".":
                px += 1
            t[y][x] = px
        if 0 < y:
            if f[y-1][x]:
                f[y-1][x] = False
                q.put([y-1, x])
        if 0 < x:
            if f[y][x-1]:
                f[y][x-1] = False
                q.put([y, x-1])
    print(t[0][0])

if __name__ == "__main__":
    main()


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    map <ll, ll> as;
    REP(i, n){
        ll a; cin >> a;
        as[a]++;
        if (as[a] > 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64 (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS)

using namespace std;
using llong = long long;

string s;
string ans;

int main() {
    cin >> s;

    for (auto ch:s) {
        if (ch == 'B' && !ans.empty()) ans.pop_back();
        else if (ch != 'B') ans.push_back(ch);
    }

    cout << ans << endl;

    return 0;
};


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

int main() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<char> t(q),d(q);
    for(int i = 0; i < q; i++)
    {
        cin >> t.at(i) >> d.at(i);
    }
    
    int left = -1;
    int right = s.size();
    int golem_index;
    bool flag = false;
    while (right - left > 1) {
        flag = false;
        int mid = left + (right - left) / 2;
        golem_index = mid;
        for (int i = 0; i < q; i++) {
            if (golem_index == (int)s.size()) break;
            if (s.at(golem_index) == t.at(i)) {
                if (d.at(i) == 'L') golem_index--;
                else golem_index++;
            }
            if (golem_index == -1) {
                flag = true;
                break;
            }
        }
        if (flag) left = mid;
        else right = mid;
    }
    int left_golem = right;
    
    left = -1;
    right = (int)s.size();
    while (right - left > 1) {
        flag = false;
        int mid = left + (right - left) / 2;
        golem_index = mid;
        for (int i = 0; i < q; i++) {
            if (golem_index == -1) break;
            if (s.at(golem_index) == t.at(i)) {
                if (d.at(i) == 'L') golem_index--;
                else golem_index++;
            }
            if (golem_index == (int)s.size()) {
                flag = true;
                break;
            }
        }
        if (flag) right = mid;
        else left = mid;
    }
    int right_golem = left;
    
    int ans = right_golem - left_golem + 1;
    cout << ans << endl;
}

Measured memory_bytes: 900
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    A=[list(map(int,input().split())) for _ in range(N)]
    B=[]
    C=[]
    for x in A:
        B.append(x[0]+x[1])
        C.append(x[0]-x[1])
    b=max(B)-min(B)
    c=max(C)-min(C)
    d=[b,c]
    print(max(d))
    
   


if __name__ == '__main__':
    main()


Measured memory_bytes: 61396
#include <iostream>

int main(void)
{
	int a, b, c;
	std::cin >> a >> b >> c;

	if (a == b){
		std::cout << c << std::endl;
	}
	else if (b == c){
		std::cout << a << std::endl;
	}
	else if (a == c){
		std::cout << b << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

int n,c[200010],sz[200010],cnt[200010],ans[200010];
vector<int> v[200010];

inline void dfs1(int x,int pr)
{
	sz[x]=1;
	for(int i=0;i<v[x].size();i++) if(v[x][i]!=pr)
	{
		int u=v[x][i];
		dfs1(u,x);
		sz[x]+=sz[u];
	}
}

inline void dfs2(int x,int pr)
{
	int pre=cnt[c[x]];
	for(int i=0;i<v[x].size();i++) if(v[x][i]!=pr){
		int u=v[x][i];
		cnt[c[x]]=0;
		dfs2(u,x);
		ans[c[x]]+=(sz[u]-cnt[c[x]])*(sz[u]-cnt[c[x]]+1)/2;
	}
	cnt[c[x]]=pre+sz[x];
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>c[i];
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs1(1,-1);
	dfs2(1,-1);
	for(int i=1;i<=n;i++){
		ans[i]+=(n-cnt[i])*(n-cnt[i]+1)/2;
		cout<<n*(n+1)/2-ans[i]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 36408
import numpy as np
H,W,*L = map(int, open(0).read().split())
A = L[:H*W]
B = L[H*W:]
C = [abs(b-a) for a,b in zip(A,B)]
U = max(C)*(H+W)
N = 2*U+1
INF = 10**10
dp = np.zeros((H,W,N),dtype=bool)
dp[0,0,C[0]+U] = True
for i in range(1,W):
  c = C[i]
  dp[0,i,c:] |= dp[0,i-1,:N-c]
  dp[0,i,:N-c] |= dp[0,i-1,c:]
for i in range(1,H):
  c = C[i*W]
  dp[i,0,c:] |= dp[i-1,0,:N-c]
  dp[i,0,:N-c] |= dp[i-1,0,c:]
for i in range(1,H):
  for j in range(1,W):
    c = C[i*W+j]
    dp[i,j,c:] |= dp[i,j-1,:N-c]
    dp[i,j,:N-c] |= dp[i,j-1,c:]
    dp[i,j,c:] |= dp[i-1,j,:N-c]
    dp[i,j,:N-c] |= dp[i-1,j,c:]
ans = np.min(np.abs(np.where(dp[H-1][W-1])[0]-U))
print(ans)

Measured memory_bytes: 175044
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int l=scan.nextInt();
            int r=scan.nextInt();
            int d=scan.nextInt();
            int ans=0;
            for(int i=l;i<=r;i++){
                if(i%d==0){
                    ans++;
                }
            }
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 32376
N = int(input())
Ln = list(map(int,input().split()))
Ln.sort()
n = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if Ln[i]+Ln[j]>Ln[k] and Ln[i]!=Ln[j] and Ln[j]!=Ln[k]:
                n += 1
            
print(n)
                


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    ll cnt=0;
    rep(i,n-1){
        if(p[i]>p[i+1]){
            ll dif=p[i]-p[i+1];
            p[i+1]+=dif;
            cnt+=dif;
        }
    }
    cout<<cnt<<endl; 
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long n; cin >> n;
    long long a[n];
    long long sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    long long left = 0, right = sum, bestleft = 0, bestright = sum;
    for(int i = 0; i < n; i++){
        if(abs(right - left) < abs(bestright - bestleft)){
            bestleft = left;
            bestright = right;
        }
        left += a[i];
        right -= a[i];
    }
    if(abs(right - left) < abs(bestright - bestleft)){
        bestleft = left;
        bestright = right;
    }
    cout << abs(bestright - bestleft) << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;

public class Main {
    static Map<Integer, int[]> map = new HashMap<Integer, int[]>();
    static Map<Integer, Boolean> visited = new HashMap<Integer, Boolean>();
    static List<Integer> que = new ArrayList<Integer>();
    static List<Integer> tmpQue = new ArrayList<Integer>();
	static int[] d; // 

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
		
		//set map
        for (int i = 0; i < n; i++){
            String[] s = br.readLine().split(" ");
            int u = Integer.parseInt(s[0]);
            int k = Integer.parseInt(s[1]);
            int[] a = new int[k];
            for (int j = 0; j < k; j++){
                a[j] = Integer.parseInt(s[j+2]);
            }
            map.put(u, a);
            visited.put(u, false);
        }

        d = new int[n + 1];
        for (int i = 0; i < n + 1; i++){
            d[i] = -1;
        }
        int v = 1;
        que.add(v);
        visited.put(1, true);
        int step = 0;
        d[v] = step;
        step++;
        
        while (que.size() > 0){
            v = que.remove(0);
			
            //add the next Vertices to the que
            try{
				if (map.get(v) == null){
					;
                }else{
                    int[] nextArr = map.get(v);
                    for (int j = 0; j < nextArr.length; j++){
                        if (visited.get(nextArr[j])){
                            ;
                        }else{
                            tmpQue.add(nextArr[j]);
                            visited.put(nextArr[j], true);
                            d[nextArr[j]] = step;
                        }
                    }
                }
				// 
				if (que.size() == 0){
					step++;
					for (int i = 0; i < tmpQue.size(); i++){
						que.add(tmpQue.get(i));
					}
					tmpQue.clear();
				}
            }catch (NullPointerException e){
                e.printStackTrace();
            }
        }
        //show the result
        for (int i = 1; i < n + 1; i++){
            System.out.println(i + " " + d[i]);
        }
    }    
}

Measured memory_bytes: 18964
#include<iostream>
#include<vector>
#define lli long long int
#define N 4
#define pb push_back
#define p 1000000007
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b+c)>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}


Measured memory_bytes: 3552
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	as := make([]int, 3)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d %d", &as[0], &as[1], &as[2])

	fmt.Println(max(as...) - min(as...))
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <string_view>
#include <vector>

#include <cmath>
#include <cctype>

int main() {
  int a;
  std::cin >> a;

  std::cout << (a + a * a + a * a * a) << '\n';
}


Measured memory_bytes: 3632
import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	count+=math.floor(XW[i][0]/L)
"""
if XW[0][1]==1:
	for i in range(1,N):
		if XW[i][0]<XW[0][0]:
			count+=int((XW[0][0]-XW[i][0])/L)+1
else:
	for i in range(1,N):
		if XW[i][0]>XW[0][0]:
			count+=int((XW[i][0]-XW[0][0])/L)+1
"""
#print(count)
#print(len())
newX=[]
for i in range(N):
	newX.append(XW[i][0]%L)
newX.sort()
#print(newX)
for i in range(N):
	print(newX[(i+count)%N]%L)

Measured memory_bytes: 23156
uses crt, math;
var
        i,n,k,tmp,tmp2:longint;
        kq:real;
begin
        clrscr;
        readln(n, k);
        kq:=0;
        for i:=1 to n do begin
                tmp:=i;
                tmp2:=0;
                while tmp<k do begin
                        tmp:=tmp*2;
                        inc(tmp2);
                end;
                kq:=kq+(1/n)*power(0.5, tmp2);
        end;
        writeln(kq:0:20);
        readln;
end.


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

int N;
int a[100];

int main() {
    cin >> N;
    rep(i, N) cin >> a[i];

    map<string, int> mp;
    int free = 0;

    rep(i, N) {
        if (a[i] <= 399) {
            mp["gray"]++;
        } else if (a[i] <= 799) {
            mp["brown"]++;
        } else if (a[i] <= 1199) {
            mp["green"]++;
        } else if (a[i] <= 1599) {
            mp["lightblue"]++;
        } else if (a[i] <= 1999) {
            mp["blue"]++;
        } else if (a[i] <= 2399) {
            mp["yellow"]++;
        } else if (a[i] <= 2799) {
            mp["orange"]++;
        } else if (a[i] <= 3199) {
            mp["red"]++;
        } else {
            free++;
        }
    }

    string t[] = {"gray", "brown", "green", "lightblue", "blue", "yellow", "orange", "red"};

    int base = 0;
    int new_color = 0;

    for (int i = 0; i < 8; i++) {
        if (mp.count(t[i])) {
            base++;
        } 
        // else if (free > 0) {
        //     free--;
        //     new_color++;
        // }
    }

    // printf("%d %d\n", max(base, 1), min(base + new_color, 8));
    // printf("%d %d\n", max(base, 1), min(base + free, 8));
    printf("%d %d\n", max(base, 1), base + free);
}

Measured memory_bytes: 256