akhauriyash/Code-Regression huggingface dataset:
/*
 * sample.c
 *
 *  Created on: 2017/05/09
 *      Author: SS-76
 */

/*
 * ???????????´??°b, f, r, v??????????????????
 * b?£?f??????r???????????¨?±????v??????????????§??\?±?( v < 0 ???????????????
 *
 * int??????3?¬????????????¨????????±????????¨????????????
 * member[b?£?][f???][r??????] ????????\?±??????°???????????????0
 */


#include <stdio.h>

int main (void){

	/*?????¨???????????°?????£?¨?*/

	int b = 0 ;		//???????£?????????????????£????
	int f = 0 ;		//???????????????????????????
	int r = 0 ;		//????????????????????????????????????
	int v = 0 ;		//???????????\?±?????????????????????????
	int n = 0 ;		//?????????????????\?±??????±????????¶???

	int i = 0 ;		//???????????°

	/*???????????£?¨???¨?????????*/

	int member[4][3][10];

	for( b = 0 ; b < 4 ; b++ ){
		for( f = 0 ; f < 3 ; f++ ){
			for( r = 0 ; r < 10 ; r++ ){
				member[b][f][r] = 0 ;		//???????????¨????????¨?±??????°?????\?±????????????????
			}	//r???for????????????????????§
		}	//f???for????????????????????§
	}	//b???for????????????????????§

	/*??\?±??????±???????????????*/

	scanf("%d" , &n);			//?????±?????°???n??¶

	for( i = 0 ; i < n ; i++){		//n??¶????????±????????????????????????????????????
		scanf("%d" , &b);			//b-1?£?
		scanf("%d" , &f);			//f-1???
		scanf("%d" , &r);			//r-1??????
		scanf("%d" , &v);			//v???????¢????

		member[b-1][f-1][r-1] += v ;		//?????????????????±?????????
	}

	/*???????????????*/

	for( b = 0 ; b < 4 ; b++ ){
		for( f = 0 ; f < 3 ; f++ ){
			for( r = 0 ; r < 10 ; r++ ){
				printf(" %d" ,member[b][f][r]);
			}	//r???for????????????????????§

			printf("\n");			//???????????¨?????????
		}	//f???for????????????????????§

		if( b != 3){
			printf("####################\n");					//1?£??????¨???????????????????????? b == 3 ?????¨?????????????????????
		}


	}	//b???for????????????????????§



	return 0;
}

Measured memory_bytes: 612
#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;


inline li calc(li x) {
    if (x == 0)return 0;
    if (x == 1)return 1;
    return calc(x / 2) * 2 + 1;
}

int main() {
    li h;
    cin >> h;
    cout << calc(h) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;


int main() {
	int n;
	cin >> n;
	vecst A(n);
	map<string, int> m;
	for (int i = 0;i < n;i++) {
		string s;
		int a;
		cin >> s >> a;
		A[i] = s;
		m[s] = a;
	}
	string st;
	cin >> st;
	int ans = 0;
	bool b = false;
	for (int i = 0;i < n;i++) {
		if (b) ans += m[A[i]];
		if (A[i] == st) b = true;
	}
	print(ans);
}


Measured memory_bytes: 256
// Cease to struggle and you cease to live
// D.cpp
// Created by Nickwzk on 2019-02-16 20:31
#include <bits/stdc++.h>
using namespace std;

inline int read() {
	int x = 0, ch = getchar(); bool fg = 1;
	while(ch < '0' || ch > '9') { if(ch == '-') fg = 0; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return fg ? x : -x;
}
int b[] = {0,2,5,5,4,5,6,3,7,6};
int a[13];
string dp[20003];
bool cmp(string A, string B) {
	if(A.size() != B.size()) return A.size() < B.size();
	for(int i = 0; i < A.size(); i++) {
		if(A[i] != B[i]) return A[i] < B[i];
	}
	return 0;
}
int main() {
	int n = read(), m = read();
	for(int i = 1; i <= m; i++) a[i] = read();
	for(int i = 0; i <= n; i++) {
		if(dp[i].size() == 0 && i != 0) continue;
		for(int j = 1; j <= m; j++) {
			if(i + b[a[j]] <= n && cmp(dp[i + b[a[j]]], dp[i] + (char)('0' + a[j])))
				dp[i + b[a[j]]] = dp[i] + (char)('0' + a[j]);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int L= a+b;
    int R=c+d;

    if(L>R){
        cout << "Left" << endl;
    }
    else if(L==R){
        cout << "Balanced" << endl;
    }
    else{
        cout << "Right" << endl;
    }
    
}

Measured memory_bytes: 3588
h, w = map(int, input().split())
amap = [list(map(int, input().split())) for _ in range(h)]
n = 0
mv = []
for i, alist in enumerate(amap):
  for j in range(len(alist)):
    if i == len(amap) - 1 and j == len(alist) - 1:
      break
    if i % 2 == 0:
      if amap[i][j] % 2 == 1:
        amap[i][j] -= 1
        if j == len(alist) - 1:
          amap[i+1][j] += 1
          mv.append((i+1, j+1, i+2, j+1))
        else:
          amap[i][j+1] += 1
          mv.append((i+1, j+1, i+1, j+2))
        n += 1
    elif i % 2 == 1:
      if amap[i][-j-1] % 2 == 1:
        amap[i][-j-1] -= 1
        if j == len(alist) - 1:
          amap[i+1][0] += 1
          mv.append((i+1, 1, i+2, 1))
        else:
          amap[i][-j-2] += 1
          mv.append((i+1, len(alist)-j, i+1, len(alist)-j-1))
        n += 1
print(n)
for _mv in mv:
  print(*_mv)


Measured memory_bytes: 26736
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    int d, n;
    cin >> d >> n;
    
    if(n == 100){
        if(d == 0){
            cout << 101 << endl;
        }
        else if(d == 1){
            cout << 10100 << endl;
        }
        else{
            cout << 1010000 << endl;
        }
        return 0;
    }
    
    cout << pow(100, d) * n << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Char
import Data.Function
import Data.List
import Data.Maybe
import qualified Data.Map as M
import Text.Read
import Text.ParserCombinators.ReadPrec
import Text.Printf

newtype Pair a b = Pair { getPair :: (a, b) }

instance (Read a, Read b) => Read (Pair a b) where
  readPrec = Pair `dot` (,) <$> readPrec <* get <*> readPrec

instance (Show a, Show b) => Show (Pair a b) where
  show (Pair (a, b)) = show a ++ " " ++ show b

dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = ((.).(.))

data Result = AC | WA | TLE | RE deriving (Show, Read, Eq, Ord)

main :: IO ()
main = do
  n <- readLn
  rs <- replicateM n readLn :: IO [Result]
  let count = foldr (\r mp -> M.insertWith (+) r 1 mp) M.empty rs :: M.Map Result Int
  forM_ [AC, WA, TLE, RE] $ \r -> do
    printf "%s x %d\n" (show r) (fromMaybe 0 $ count M.!? r) 


Measured memory_bytes: 14040
#include <iostream>
#include <bitset>
using namespace std;
int main(void) {
  bitset<10001> bs;
  bs.reset();
  bs[0] = 1;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    bs = bs | (bs << a);
  }
  for (int i = bs.size(); i >= 0; i--) {
    if (bs[i] && i % 10 != 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] arr = new int[N];

    for (int i = 0; i < N; i++) {
      arr[i] = sc.nextInt();
    }
    System.out.println(Arrays.stream(arr).distinct().count());
  }
}

Measured memory_bytes: 28500
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H, N;
    cin >> W >> H >> N;
    int HW[H][W] = {};
    int x[N], y[N], a[N];
    rep(i, N) cin >> x[i] >> y[i] >> a[i];
    rep(i, N) {
        if(a[i] == 1) {
            rep(j, x[i]) {
                rep(k, H) {
                    HW[k][j] = 1;
                }
            }
        }
        if(a[i] == 2) {
            rep(j, W-x[i]) {
                rep(k, H) {
                    HW[k][W-j-1] = 1;
                }
            }
        }
        if(a[i] == 3) {
            rep(j, W) {
                rep(k, y[i]) {
                    HW[k][j] = 1;
                }
            }
        }
        if(a[i] == 4) {
            rep(j, W) {
                rep(k, H-y[i]) {
                    HW[H-k-1][j] = 1;
                }
            }
        }
    }
    int ans = H*W;
    rep(i, H) {
        rep(j, W) {
            ans -= HW[i][j];
            //cout << HW[i][j] << " ";
        }
        //cout << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M;
  cin >> N >> M;
  ll A;
  ll tot = 0;
  rep(i, M){
    cin >> A;
    tot += A;
  }

  if(tot <= N)
    cout << N - tot << endl;
  else
    cout << -1 << endl;
  
  return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] m=new int[N];
        int total=0;
        int count=0;
        
        for(int i=0;i<N;i++){
            m[i] =sc.nextInt();
            X-=m[i];
            count+=1;
            
        }
        
        Arrays.sort(m);
        
        while(X>=m[0]){
            X-=m[0];
            count+=1;
        }
        
        System.out.println(count);
        
        
    }
    
} 

Measured memory_bytes: 35884
import java.util.Scanner;

public class Main {
	static int[] str = new int[300];
	static int i = 0;
	static void push(int k) {
		if (i >=299){
			System.out.print("?????????????????????");
			System.exit(1);
		}else
			i++;
			str[i] = k;
		}
	static int pop() {
		if (i == 0){
			System.out.print("??¢??????????????????");
			System.exit(1);
		}else
		i--;
		return str[i+1];

	}
	static boolean isNumber(String j) {
	    try {
	        Integer.parseInt(j);
	        return true;
	        } catch (NumberFormatException e) {
	        return false;
	    }
	}

	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String[] array = in.nextLine().split(" ");
		int size = array.length;
		for (int h=0;h<size;h++){
			if (array[h].equals("+")){
				int b = pop();
				int c = pop();
				int d = c + b;
				push(d);
			}
			else if (array[h].equals("-")){
				int b = pop();
				int c = pop();
				int d = c - b;
				push(d);
			}
			else if (array[h].equals("*")){
				int b = pop();
				int c = pop();
				int d = c * b;
				push(d);
			}
			else
				if (isNumber(array[h])){
				int k = Integer.parseInt(array[h]);
				push(k);
			}
		}
		System.out.println(str[i]);
	}
}

Measured memory_bytes: 26088
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

int main(){
  ll N, M;
  cin >> N >> M;
  vll dev(0);
  for(int i = 1; i*i <= M; i++){
    if(M%i != 0) continue;
    dev.push_back(i);
    if(i*i != M) dev.push_back(M/i);
  }
  sort(ALL(dev));
  ll n = *lower_bound(ALL(dev), N);
  cout << M/n << endl;
}

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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  vector<double> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];
  sort(xs.begin(), xs.end());
  reverse(xs.begin(), xs.end());
  while (xs.size() >= 2) {
    double x1 = xs.back();
    xs.pop_back();
    double x2 = xs.back();
    xs.pop_back();
    xs.push_back((x1 + x2) / 2.0);
  }
  cout << xs[0] << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> PII;
#define MOD (1000000007ll)

int main(void){
	int n,a,b,i,t,ans=0;
	cin >> n >> a >> b;
	for(i=1; i<=n; i++){
		t = i/10000 + (i%10000)/1000 + (i%1000)/100 + (i%100)/10 + i%10;
		if(a <= t && t <= b){
			ans+=i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;
 
int main() {
  int n;
  float a,b;
  float sum=0.0;
  std::priority_queue< float, std::vector<float>, std::greater<float> > A;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    A.push(a);
  }
   while(true){
     a=A.top();
     A.pop();
     b=A.top();
     A.pop();
     sum=(a+b)/2;
     if(A.empty()) break;
     A.push(sum);
  }
  cout<<sum;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

s = [0] * m
c = [0] * m
a = [0] * n

for i in range(m):
    s[i], c[i] = map(int, input().split())

for i in range(m):
    if s[i] == 1 and c[i] == 0 and n != 1:
        print(-1)
        exit()
    for j in range(i+1, m):
        if s[i] == s[j] and c[i] != c[j]:
            print(-1)
            exit()

for i in range(m):
    a[s[i]-1] = c[i]

if a[0] == 0 and n != 1:
    a[0] = 1

ans = ''

for i in range(n):
    ans += str(a[i])

print(int(ans))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if ( T[u].p == NIL ) cout << "root, ";
    else if ( T[u].l == NIL ) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for ( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void rec(int u, int p) {
    D[u] = p;
    if ( T[u].r != NIL ) rec(T[u].r, p);
    if ( T[u].l != NIL ) rec(T[u].l, p+1);
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;

    for ( i = 0; i < n; i++ ) {
        cin >> v >> d;
        for ( j = 0; j < d; j++ ) {
            cin >> c;
            if ( j == 0 ) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for ( i = 0; i < n; i++ ) {
        if ( T[i].p == NIL ) r = i;
    }

    rec(r, 0);
    
    for ( i = 0; i < n; i++ ) print(i);

    return 0;
}


Measured memory_bytes: 7752
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0, cur = 0;
    rep(i,n){
        if(cur < h[i]) ans += h[i] - cur;
        cur = h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(string):
    n, m, *a = map(int, string.split())
    c = 2**len(bin(a[0]).split("1")[-1])
    l = reduce(lcm, (2 * m + 2 if _a % c or not _a // c % 2 else _a for _a in a))
    return str(max((m + l // 2) // l, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 17172
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, n;
  while( 1 ) {
    scanf("%lld", &n);
    if(!n) break;
    ll a[n], ans = 0, now = 0;
    for(i = 0; i < n; ++i) scanf("%lld", &a[i]), now += a[i];
    for(i = 0; i < n; ++i) if(now >= a[i] * n) ++ans;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2816
# coding: utf-8

N = int(input())
S = input().rstrip('#')

lb = 0
rw = S.count('.')
ans = lb + rw

for i in range(len(S)):
  if S[i] == '.':
    rw -= 1
  else:
    lb += 1
  ans = min(ans, rw + lb)

print(ans)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rs64() {
	int64_t n;
	scanf("%" SCNd64, &n);
	return n;
}
#define MOD 1000000007
template<int mod>
struct ModInt{
	int x;
	ModInt():x(0){}
	ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator-()const{return ModInt(-x);}
	ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
	ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
	ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
	ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
	bool operator==(const ModInt &p)const{return x==p.x;}
	bool operator!=(const ModInt &p)const{return x!=p.x;}
	explicit operator int() const { return x; }						   // added by QCFium
	ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
	ModInt inverse()const{
		int a=x,b=mod,u=1,v=0,t;
		while(b>0){
			t=a/b;
			a-=t*b;
			std::swap(a,b);
			u-=t*v;
			std::swap(u,v);
		}
		return ModInt(u);
	}
	friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
		return os<<p.x;
	}
	friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
		long long x;
		is>>x;
		a=ModInt<mod>(x);
		return (is);
	}
};
typedef ModInt<MOD> mint;

struct MComb {
	std::vector<mint> fact;
	std::vector<mint> inversed;
	MComb(int n) { // O(n+log(mod))
		fact = std::vector<mint>(n+1,1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
		inversed = std::vector<mint>(n+1);
		inversed[n] = fact[n] ^ (MOD-2);
		for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
	}
	mint ncr(int n, int r) {
		return (fact[n] * inversed[r] * inversed[n-r]);
	}
	mint npr(int n, int r) {
		return (fact[n] * inversed[n-r]);
	}
	mint nhr(int n, int r) {
		assert(n+r-1 < (int)fact.size());
		return ncr(n+r-1, r);
	}
};

mint ncr(int n, int r) {
	mint res = 1;
	for (int i = n - r + 1; i <= n; i++) res *= i;
	for (int i = 1; i <= r; i++) res /= i;
	return res;
}

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	int res = 1000000000;
	for (int i = 0; i <= 100; i++) {
		int cur = 0;
		for (int j = 0; j < n; j++) cur += std::abs(i - a[j]) * std::abs(i - a[j]);
		res = std::min(res, cur);
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ans, x, a, b, key;
	string s;

	cin >> n >> s;
	vector<vector<bool>> v(n + 2, vector<bool>(10, false));
	vector<vector<bool>> w(n + 2, vector<bool>(10, false));
	for (i = 1; i <= n; i++) {
		x = s[i - 1] - '0';
		v[i] = v[i - 1];
		v[i][x] = true;
	}
	for (i = n; i >= 1; i--) {
		x = s[i - 1] - '0';
		w[i] = w[i + 1];
		w[i][x] = true;
	}

	vector<bool> valid(1000, false);
	for (i = 1; i <= n; i++) {
		x = s[i - 1] - '0';
		for (a = 0; a < 10; a++) {
			if (v[i - 1][a]) {
				for (b = 0; b < 10; b++) {
					if (w[i + 1][b]) {
						key = a * 100 + x * 10 + b;
						valid[key] = true;
					}
				}
			}
		}
	}

	ans = 0;
	for (i = 0; i < 1000; i++) {
		if (valid[i])ans++;
	}
	cout << ans << "\n";

		
	return 0;
}


Measured memory_bytes: 3584
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Main().main();
    }

    public void main() {
        Scanner scanner = new Scanner(System.in);
        String[] nw = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nw[0]);
        int m = Integer.parseInt(nw[1]);

        char[][] a = new char[n][n];
        for (int i = 0; i < n; i++) {
            String line = scanner.nextLine();
            for (int j = 0; j < n; j++) {
                a[i][j] = line.charAt(j);
            }
        }

        char[][] b = new char[m][m];
        for (int i = 0; i < m; i++) {
            String line = scanner.nextLine();
            for (int j = 0; j < m; j++) {
                b[i][j] = line.charAt(j);
            }
        }

        boolean found = false;
        for (int startI = 0; startI <= n - m; startI++) {
            for (int startJ = 0; startJ <= n - m; startJ++) {
                if (this.matches(a, b, startI, startJ, n, m)) {
                    found = true;
                    break;
                }
            }
            if (found) {
                break;
            }
        }
        if (found) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    private boolean matches(char[][] a, char[][] b, int startI, int startJ, int n, int m) {
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                if (a[i + startI][j + startJ] != b[i][j]) {
                    return false;
                }
            }
        }
        return true;
    }
}


Measured memory_bytes: 23380
from collections import Counter
n = int(input())
s = []
s0 = list(input())
sc = Counter(s0)
for i in range(1,n):
    a = list(input())
    ac = Counter(a)
    for i,v in ac.items():
        if i not in sc:
            continue
        elif sc[i] > v:
            sc[i] = ac[i]
    for i,v in sc.items():
        if i not in ac:
            sc[i] = 0
sc2 = sorted(sc.items())
for i,v in sc2:
    for j in range(v):
        print(i,end='')
            

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

signed main()
{
    int M, N; cin>>M>>N;
    vector<int> sumW(M+1), sumT(M+1);
    for(int i=0;i<M;i++){
        int W, T; cin>>W>>T;
        sumW[i+1]=sumW[i]+W;
        sumT[i+1]=sumT[i]+T;
    }
    //for(int i=0;i<=M;i++) cout<<sumW[i]<<' '; cout<<endl;
    //for(int i=0;i<=M;i++) cout<<sumT[i]<<' '; cout<<endl;
    vector<int> c(N), b(N);
    for(int i=0;i<N;i++){
        cin>>c[i]>>b[i];
    }

    vector<int> dp(1<<N, -1);
    dp[0]=0;
    for(int S=0;S<(1<<N);S++){
        if(dp[S]==-1) continue;
        for(int i=0;i<N;i++){
            if(S>>i&1) continue;
            int j1=upper_bound(sumW.begin(), sumW.end(), sumW[dp[S]]+c[i])-sumW.begin()-1;
            int j2=upper_bound(sumT.begin(), sumT.end(), sumT[dp[S]]+b[i])-sumT.begin()-1;
            int j=min(j1, j2);
            dp[S|(1<<i)]=max(dp[S|(1<<i)], j);
        }
    }
    cout<<dp[(1<<N)-1]<<endl;
}




Measured memory_bytes: 6164
N = int(input())
A = [int(input()) for _ in range(N)]

ans = A[0] - 1

nowMin = 1
for a in A[1:]:
    if a == nowMin + 1:
        nowMin = a
    else:
        q, r = divmod(a, nowMin + 1)
        if r == 0:
            q -= 1
        ans += q

print(ans)

Measured memory_bytes: 7852
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

int ctoi(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	default: return -1;
	}
}


int main()
{
	string S;
	cin >> S;
	
//	S.erase(S.begin() + 2);
//	S[i]
//	S.length()

	bool bit = false;
	int count = 0;

//	cout << S[0] << decltype(S[0]) << endl;
//	cout << char(bit) << decltype(char(bit)) << endl;

	for (int i = 0; i < S.length(); i++) {
//		cout << bit <<  endl;
		char temp = S[i];
		if (ctoi(temp) == bit) {
			count++;
		}
		else {
		}
		bit = !bit;
	}

	int score = count;

	bit = 1;
	count = 0;
	for (int i = 0; i < S.length(); i++) {
//		cout << bit << endl;
		char temp = S[i];
		if (ctoi(temp) == bit) {
			count++;
		}
		else {
		}
		bit = !bit;
	}

	if (score <= count) {
		cout << score;
	}
	else {
		cout << count;
	}

}

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

int main(){

	int H, W;

	while(1){

		cin >> H >> W;

		if(H == 0 && W == 0) break;

		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				cout << "#";
			}

			cout << endl;
		}

		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

template<typename T>
T gcd(T a, T b) {
	if( a < b ) swap(a, b);
	
	T r;
	while( r = a % b ) {
		a = b;
		b = r;
	}
	
	return b;
}

template<typename T>
bool is_prime(T n) {
	
	for(T i = 2; i * i <= n; ++i) {
		if( n % i == 0 ) return false;
	}
	
	return true;
}

template<typename T>
map<T, int> prime_factor(T n) {
	
	map<T, int> res;
	for(T i = 2; i * i <= n; ++i) {
		while( n % i == 0 ) {
			res[i]++;
			n /= i;
		}
	}

	if( n != 1 ) res[n] = 1;
	
	return res;
}

int main(void) {
	ll a, b;
	cin >> a >> b;

	ll g = gcd(a, b);
	
	int ans = 1;
	
	if( !is_prime(g) ) {
		map<ll, int> div;
		div = prime_factor(g);
	
		for(auto& x : div) {
			//cout << x.first << " ";
			ans++;
		}
		
		cout << endl;	
	}
	
	else if( g != 1 && is_prime(g) ) ans++;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int t[];
        t = new int[N];
        for(int i=0;i<N;i++){
            t[i]=sc.nextInt();
        }
        Arrays.sort(t);
        int a = 0;
        int b = 0;
        for(int i=0;i<N;i++){
            if (i % 2 != 1) {
                a += t[i];
            } else {
                b += t[i];
            }
        }
    
        System.out.println(Math.abs(b-a));
    }
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    map<string, int> cnt;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        cnt[s]++;
    }
    
    for (string s : {"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << cnt[s] << endl;
    }
    return 0;
}

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

# -*- coding: utf-8 -*-


from sys import stdin
import itertools


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

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])

data = []
write = stdin.readline().split()
for i in range(N):
    data.append(int(write[i]))

total = sum(data)

best = 1e6
buf = 0
for i in range(N):
    buf += data[i]
    score = abs(buf - (total-buf)) 
    if score < best:
        best = score

print(best)

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

using namespace std;

int main(void) {
    int n;
    while (cin >> n, n) {
        int m, M = 0;
        for (int i = 0; i < 9; i++) {
            cin >> m;
            M += m;
        }
        cout << n - M << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int paper[10][10]={0};

int drop(int y, int x){
	if (0<=x && x<10 && 0<=y && y<10) paper[y][x]++;
	return 0;
}

int ink(int y, int x, int size){
	switch(size){
		case 3:
			drop(y-2, x); drop(y+2, x);
			drop(y, x-2); drop(y, x+2);
		case 2:
			drop(y-1, x-1); drop(y-1, x+1);
			drop(y+1, x-1); drop(y+1, x+1);
		case 1:
			drop(y, x);
			drop(y-1, x); drop(y+1, x);
			drop(y, x-1); drop(y, x+1);
	}
	return 0;
}

int main(void){
	
	while (true){
		int x,y,size;
		char c;
		cin>>x>>c>>y>>c>>size;
		if (cin.eof()) break;
		ink(y, x, size);
	}

	int n=10, c1=0, c2=0;
	for (int i=0; i<n; i++){
		for (int j=0; j<n; j++){
			int tmp = paper[j][i];
			if (tmp==0) c1++;
			if (tmp>c2) c2=tmp;
		}
	}
	cout<<c1<<endl;
	cout<<c2<<endl;
	return 0;
}

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

using namespace std;

#define INF 1e9
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define repv(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define ll long long int
#define endl "\n"

int sol(int n) {
	int ans = 0;
	for(int i = 1; i <= n; i++) 
    	ans += floor(n/i);
    return ans;
}

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

    int n;
    cin >> n;
    cout << sol(n-1);
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> cnt(9, 0);
  REP(i, n) {
    ll a;
    cin >> a;
    a /= 400;
    a = min(a, 8LL);
    cnt[a]++;
  }
  ll x = 0;
  REP(i, 8) {
    if (cnt[i]) {
      x++;
    }
  }
  ll mini = x == 0 ? 1 : x;
  cout << mini << " " << x + cnt[8] << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pii > VPI;
typedef vector<pll > VPL;
const int mod = 1000000007;

int H, W;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> H >> W;
    if(H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
    }
    cout << 1LL * H * W / 2 + (1LL * H * W) % 2 << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    
    string str;
    int q;
    cin >> str >> q;
    for(int i = 0; i < q; i++){
        string c;
        int a,b;
        cin >> c >> a >> b;
        if(c == "print"){
            for(int j = 0; j < b-a+1; j++){
                cout << str[a+j];
            }
            cout << endl;
        }
        else if(c == "reverse"){
            for(int j = 0; j < (b-a+1)/2; j++){
                char d = 0;
                d = str[a+j];
                str[a+j] = str[b-j];
                str[b-j] = d;
            }
        }else if(c == "replace"){
            string r;
            cin >> r;
            for(int j = 0; j < b-a+1; j++){
                str[a+j] = r[j];
            }
        }
    }
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
 
void solve(){
    ll n, m;
    cin>>n>>m;
    vl v[m];
    ll a[m];
    loop(i,0,m){
        ll x;
        cin>>a[i]>>x;
        loop(j,0,x){
            ll y;
            cin>>y;
            y--;
            v[i].pb(y);
        }
    }
    ll dp[1ll<<n];
    loop(i,0,1ll<<n) dp[i] = inf;
    dp[(1ll<<n)-1] = 0;
    for(ll i = (1ll<<n)-2; i >= 0; i--){
        // trace(i);
        for(ll j = 0; j<m; j++){
            ll new_mask = i;
            for(auto x: v[j]){
                new_mask = new_mask|(1ll<<x);
            }
            // trace(j, new_mask);
            dp[i] = min(dp[i], dp[new_mask] + a[j]);

        }
    }
    if(dp[0] < inf) print(dp[0]);
    else print(-1);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
       
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  string s; cin >> s;
  int mx = 0, count = 0;
  REP(i, s.length()) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      count++;
    } else {
      if (mx < count) mx = count;
      count = 0;
    }
  }
  cout << max(mx, count) << endl;
}


Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  string ans;
  while(N != 0) {
    if(N % 2 != 0) {
      ans.push_back('1');
      N--;
    }else {
      ans.push_back('0');
    }
    N /= (-2);
  }

  reverse(ans.begin(),ans.end());

  if(ans.empty()) cout << 0 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
import itertools

def duplicate(x):
    return len(x) != len(set(x))

N = int(input())
S = list(map(int, input().split()))

cnt = 0

for team in itertools.combinations(S, 3):
    #print(duplicate(team))
    if duplicate(team) == True:
        continue
    else:
        if max(team) < sum(team) - max(team):
            cnt += 1
        else:
            continue

print(cnt)


Measured memory_bytes: 9104
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	cout<<0.5*(1+(b-a))*(b-a)-b<<endl;
	return 0;
}

Measured memory_bytes: 256
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let a: usize = sc.read();
    let b: usize = sc.read();
    let x: usize = sc.read();
    println!("{}", b / x + 1 - if a == 0 { 0 } else { (a - 1) / x + 1 });
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Measured memory_bytes: 4476
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    ans = 0
    bxa = 0
    bx = 0
    xa = 0
    for s in S:
        ans += s.count("AB")
        if s.startswith("B") and s.endswith("A"):
            bxa += 1
        elif s.startswith("B"):
            bx += 1
        elif s.endswith("A"):
            xa += 1

    ans += min(bx, xa)
    if bxa >= 1:
        ans += bxa - (1 if max(bx, xa) == 0 else 0)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 45784
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        switch(S) {
            case "SUN":
            System.out.println(7);
            break;
            case "MON":
            System.out.println(6);
            break;
            case "TUE":
            System.out.println(5);
            break;
            case "WED":
            System.out.println(4);
            break;
            case "THU":
            System.out.println(3);
            break;
            case "FRI":
            System.out.println(2);
            break;
            case "SAT":
            System.out.println(1);
            break;
            default:
            break;
        }

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  std::vector<ll> a(N), b(N);
  ll count=0;
  range(i, N) std::cin >> a[i] >> b[i];
  for(int i=N-1;i>=0;i--) count+= ((a[i]+count)%b[i]==0?0:b[i] - (a[i]+count)%b[i]);
  std::cout << count << '\n';
  return 0;
}


Measured memory_bytes: 2424
#include <iostream>
#include <map>
#include <vector>

using namespace std;

vector<int> counting_sort(vector<int> *A)
{
    map<int, long> M;

    for (int a : *A)
    {
        if (M.find(a) == M.end())
        {
            M.insert(make_pair(a, 1));
        }
        else
        {
            M.at(a)++;
        }
    }

    vector<int> B;

    for (int i = 0; i <= 10000; i++)
    {
        if (M.find(i) == M.end())
        {
            continue;
        }

        for (long j = 0; j < M.at(i); j++)
        {
            B.push_back(i);
        }
    }

    return B;
}

int main()
{
    long n;
    cin >> n;
    vector<int> A(n);
    for (long i = 0; i < n; i++)
    {
        cin >> A.at(i);
    }

    vector<int> B = counting_sort(&A);
    cout << B.at(0);
    for (long i = 1; i < B.size(); i++)
    {
        cout << ' ' << B.at(i);
    }
    cout << endl;
}



Measured memory_bytes: 19708
#include<iostream>
using namespace std;
int main(){
    long long a,b,i,j,k;
    cin >> a >> b >> k;
    i=0;
    while(i<k)
    {
        if(a%2!=0)
            a--;
        a/=2;
        b+=a;
        i++;
        if(i==k)
            break;
        if(b%2!=0)
            b--;
        b/=2;
        a+=b;
        i++;
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
scount=1
flg=0
ans=1
for i in range(1,N):
    if A[i]==A[i-1]:
        scount+=1
        if i==N-1 and scount>=2 and flg==1:
            flg=2
            ans*=A[i-1]
        if i==N-1 and scount>=4 and flg==0:
            flg=2
            ans=A[i-1]**2
    else:
        if scount>=4 and flg==0:
            flg=2
            ans=A[i-1]**2
            break
        elif scount>=2:
            if flg==0:
                flg=1
                ans*=A[i-1]
            elif flg==1:
                flg=2
                ans*=A[i-1]
                break
        scount=1

print(ans if flg==2 else 0)

Measured memory_bytes: 62704
S = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
L = S.split(',')
K = int(input())
print(int(L[K-1]))

Measured memory_bytes: 2940
import heapq
n, k = map(int, input().split())
hq = []
total = 0
for i in range(n):
    a, b = map(int, input().split())
    heapq.heappush(hq, (-a, b))
    total += b

while total >= k:
    a, b = heapq.heappop(hq)
    total -= b

print(abs(a))

Measured memory_bytes: 22496
// Tenka1_Beginner2019_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    
    // calculation
    if (N == M) {
        cout << N*2 << "\n";
    } else {
        cout << max(N, M)*2 - 1 << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 384