akhauriyash/Code-Regression huggingface dataset:
S = gets.chomp.chars
odd_table = {
  '0' => 0,
  '1' => 0
}
even_table = {
  '0' => 0,
  '1' => 0
}
S.each.with_index do |ch, i|
  if i.odd?
    odd_table[ch] += 1
  else
    even_table[ch] += 1
  end
end
mid1 = S.size / 2
mid2 = (S.size % 2) == 0 ? mid1 : mid1 + 1
ans = [
  (mid1 - odd_table['0']).abs + (mid2 - even_table['1']).abs,
  (mid2 - odd_table['0']).abs + (mid1 - even_table['1']).abs,
  (mid1 - odd_table['1']).abs + (mid2 - even_table['0']).abs,
  (mid2 - odd_table['1']).abs + (mid1 - even_table['0']).abs
].min
puts ans


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

long long int gcd(long long int m, long long int n)
{
  long long int temp;
  while (m % n != 0)
    {
      temp = n;
      n = m % n;
      m = temp;
    }
  return n;
}

int main() {
  long long int N;
  cin >> N;
 
  for (long long int h = 1; h<=3500; h++) {
    int M = N;
    if (4*h <= N) continue;
    if (M > 1) {
      if (gcd(M, h) == 1) continue;
      M = M / gcd(M, h);
    }
    for (long long int n = 1; n<=3500; n++) {
      if (4*h*n <= N*(h + n)) continue;
      if (M > 1) {
	if (gcd(M, n) == 1) continue;
        M = M / gcd(M, h);
      }
      if (4*h*n-N*n-N*h < 0) continue;
      if ((N*h*n)%(4*h*n-N*n-N*h) != 0) continue;
      long long int w = (N*h*n)/(4*h*n-N*n-N*h);
      cout << h << ' ' << n <<' ' << w <<' ' << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm> 
#include <vector>
#include <list>
#include <set>
#define INF 100000000
using namespace std;

int cmp_sort(pair<int, int> a, pair<int, int> b){
    return a.first < b.first;
}

int main(void){
    int N;
    cin >> N;
    vector<pair<int, int>> P;
    for(int i = 0; i < N; i++){
        int x;
        int y;
        cin >> x;
        cin >> y;
        P.push_back(make_pair(x, y));
    }

    sort(P.begin(), P.end(), cmp_sort);

    if(N == 1 || N == 2){
        printf("1\n");
        return 0;
    }

    int min_count = N - 1;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j){
                continue;
            }
            int p = P[i].first - P[j].first;
            int q = P[i].second - P[j].second;

            int count = N;
            for(int k = 0; k < N; k++){
                for(int l = 0; l < N; l++){
                    if(k == l){
                        continue;
                    }
                    if(P[k].first - p == P[l].first &&
                            P[k].second - q == P[l].second){
                        count--;
                    }
                }
            }

            min_count = min(min_count, count);
        }
    }

    cout << min_count << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int zoro = 0;
    rep(i,n) {
        int d1,d2;
        cin >> d1 >> d2;
        if(d1 == d2) {
            zoro++;
        } else {
            zoro = 0;
        }
        if(zoro == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S >> T;
    ostringstream os;
    os << setw(110) << setfill('0') << S << endl;
    S = os.str();
    os.str("");
    //os.clear(stringstream::goodbit);
    os << setw(110) << setfill('0') << T << endl;
    T = os.str();
    dump(S, T);
    if (S > T)
        cout << "GREATER" << endl;
    else if (S < T)
        cout << "LESS" << endl;
    else
        cout << "EQUAL" << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
  
int main() {
  int n;
  cin >> n;
  vector<int64_t> lucas(n+1);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for (int i=2; i <= n; i++){
  	lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
  }
  cout << lucas.at(n);
  return 0;
}

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

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put("AC", 0);
		map.put("WA", 0);
		map.put("TLE", 0);
		map.put("RE", 0);
		for (int i=0; i<n; i++){
			String s = sc.next();
			map.put(s, map.get(s) + 1);
		}
		System.out.println("AC x " + map.get("AC"));
		System.out.println("WA x " + map.get("WA"));
		System.out.println("TLE x " + map.get("TLE"));
		System.out.println("RE x " + map.get("RE"));
	}

}

Measured memory_bytes: 58668
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) { cin >> a[i]; }

  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());

  cout << (a.size() == n ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 1024
import Data.List
import Data.Ratio

main = do
  n <- readLn
  print $ phi n

phi :: Int -> Int
phi 1 = 1
phi n = numerator $ foldl (\acc x -> acc * (1 - (1 % x)))
                      (n % 1) $ nub (primeFactor n)

factors :: Int -> [Int]
factors n = [d | d <- [1..n], n `mod` d == 0]

isPrime :: Int -> Bool
isPrime x = null [y | y <- [2..(sqr x)], x `mod` y == 0]
  where sqr a = floor $ sqrt $ fromIntegral a

primeFactor :: Int -> [Int]
primeFactor n
  | isPrime n = [n]
  | otherwise = reverse $ go [] n
  where
    go res 1 = res
    go res n = go (d : res) (n `div` d)
      where d = factors n !! 1

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

int main(){
  int H,W;
  cin >> H >> W;

  vector<string> A(H);
  vector<vector<long long>> c(H,vector<long long>(W,0));
  long long MOD = 1000000007;//10e9+7;

  int h,w;
  for(h=0;h<H;h++){
    cin >> A[h];
  }
  c[0][0] = 1;
  for(h=1;h<H;h++){
    if (A[h][0] == '.')
      c[h][0] = 1;
    else
      break;
  }  
  for(w=1;w<W;w++){
    if (A[0][w] == '.')
      c[0][w] = 1;
    else
      break;
  }
  for(h=1;h<H;h++)
    for(w=1;w<W;w++)
      if (A[h][w] == '.')
        c[h][w] = (c[h-1][w]+c[h][w-1]) % MOD;

  cout << c[H-1][W-1] << endl;
    
  return 0;
}

Measured memory_bytes: 13376
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#define ll long long
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
struct Data{
	int x,y;
	friend bool operator < (Data a,Data b)
	{
		return (ll)a.x*(b.y+1)!=(ll)b.x*(a.y+1)?(ll)a.x*(b.y+1)>(ll)b.x*(a.y+1):a.y<b.y;
	}
}a[maxn];
ll f[maxn][30];
int n,T;
int main()
{
	n=read(); T=read();
	for(int i=1;i<=n;i++)
		a[i].x=read(),a[i].y=read();
	std::sort(a+1,a+n+1);
	int tot=0;
	while(tot<n&&a[tot+1].x)++tot;
	for(int i=1;1<<i<=T;i++)
		f[0][i]=T+1;
	f[0][0]=0;
	for(int i=1;i<=tot;i++){
		f[i][0]=0;
		for(int j=1;1<<j<=T;j++)
			f[i][j]=std::min(f[i-1][j],f[i-1][j-1]+1+(ll)a[i].x*(f[i-1][j-1]+1)+a[i].y);
	}
	int ans=0;
	for(int i=0;1<<i<=T;i++)
		if(f[tot][i]<=T){
			int cur=i,p=tot+1,cost=f[tot][i];
			while(p<=n&&cost+a[p].y+1<=T){
				++cur;
				cost+=a[p++].y+1;
			}
			ans=std::max(ans,cur);
		}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 48640
type t = {
  id : int;
  ch : char;
  num : int;
}

let a = Array.make 100001 { id = 0; ch = '\000'; num = 0 }

let rec partitoin r = function
  | (i, j) when j = r ->
    let tmp = a.(i) in
    a.(i) <- a.(j);
    a.(j) <- tmp;
    i
  | (i, j) when a.(j).num <= a.(r).num ->
    let tmp = a.(i) in
    a.(i) <- a.(j);
    a.(j) <- tmp;
    partitoin r (i + 1, j + 1)
  | (i, j) ->
    partitoin r (i, j + 1)

let rec quick_sort p r =
  if p < r then begin
    let q = partitoin r (p, p) in
    quick_sort p (q - 1);
    quick_sort q r
  end

let rec stable_str n i =
  if i = n then "Stable"
  else if a.(i-1).num = a.(i).num && a.(i-1).id > a.(i).id then "Not stable"
  else stable_str n (i + 1)

let rec read i n =
  if i < n then begin
    begin match Str.split (Str.regexp " ") (read_line ()) with
    | [c; d] -> a.(i) <- { id = i; ch = c.[0]; num = int_of_string d }
    | _ -> exit 1
    end;
    read (i + 1) n
  end

let rec print i n =
  if i < n then begin
    print_char a.(i).ch;
    print_string " ";
    print_int a.(i).num;
    print_string "\n";
    print (i + 1) n
  end

let () =
  let n = read_int () in
  read 0 n;
  quick_sort 0 (n - 1);
  print_endline (stable_str n 1);
  print 0 n

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

int main(){
    char a, b;
    cin >> a >> b;
    if ( a > b ) {
        rep(i, a-'0') {
            cout << b;
        }
        cout << endl;
    }
    else if ( b > a ) {
        rep(i, b-'0') {
            cout << a;
        }
        cout << endl;
    }
    else if ( a-'0' > b-'0' ) {
        rep(i, a-'0') {
            cout << b;
        }
        cout << endl;
    }
    else {
//        cout << "test" << " " << b-'0' << endl;
        rep(i, b-'0') {
            cout << a;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int a, b, c, count = 0;
        String[] num = in.readLine().split(" ");
        a = Integer.parseInt(num[0]);
        b = Integer.parseInt(num[1]);
        c = Integer.parseInt(num[2]);
        for (int i = a; i <= b; i += 1) {
            if (c % i == 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

const ll N = 3*MAX5;
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, l;
string s, t, d, c;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> k >> s;
	s[k-1] = s[k-1] -'A' +'a';
	cout<<s;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3628
from collections import Counter
N, P = map(int, input().split())


# 素因数分解
def prime_factorization(n):
    table = []
    for x in range(2, int(n**0.5)+1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


T = prime_factorization(P)
C = Counter(T)

ans = 1
for x, n in C.items():
    if n >= N:
        ans *= (x ** (n // N))
print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int a, b, x;
  cin >> a >> b >> x;

  if (x > a+b) puts("NO");
  else if (x >= a) puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 256
def lcm(n,m):
    return n * m // gcd(n,m)

def gcd(n,m):
    while n:
        m,n = n,m%n
    return m

A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if V - W <= 0:
    print("NO")
elif (V - W) * T >= abs(A-B):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61700
import java.util.*;
public class Main{

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String s = input.next();
		String t = input.next();
		Map<String, Integer> store = new HashMap<>();
		store.put(s , input.nextInt());
		store.put(t , input.nextInt());
		String remove = input.next();
		store.put(remove , store.getOrDefault(remove, 0) - 1);
		System.out.println(store.getOrDefault(s , 0) + " " + store.getOrDefault(t, 0));
		input.close();
	}

}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll bit1[12345678], bit2[12345678], nn;//[1, nn]
ll sum1(ll i) {
	ll s = 0;
	while (i > 0) {
		s += bit1[i]; i -= i & -i;
	}
	return s;
}
void add1(ll i, ll x) {//iの値にxを加える
	while (i <= nn) {
		bit1[i] += x; i += i & -i;
	}
}
ll sum2(ll i) {
	ll s = 0;
	while (i > 0) {
		s += bit2[i]; i -= i & -i;
	}
	return s;
}
void add2(ll i, ll x) {//iの値にxを加える
	while (i <= nn) {
		bit2[i] += x; i += i & -i;
	}
}
ll test[12345678];
signed main() {
	ll n, k, a, cnt = 0, ans = 0; cin >> n >> k; nn = 2002;
	vector<ll> v; map<ll, ll> ma;
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = a; //cout << ' ' << sum(n + 2) << endl;
		ans += h - sum1(a); // cout << sum(a) << endl;
		add1(a, 1);
	}
	sort(test, test + n); reverse(test, test + n);
	for (int h = 0; h < n; h++) {
		cnt += h - sum2(test[h]); // cout << sum(a) << endl;
		add2(test[h], 1);
	}
	cout << (((ans % mod) * k % mod) + ((cnt % mod) * ((k * (k - 1) / 2) % mod)) % mod) % mod << endl;
	return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  int z, w; cin >> z >> w;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  if(n == 1) cout << abs(a[0] - w) << endl;
  else cout << max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2])) << endl;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int n, a, b;
vi h;

bool check(int x)
{
	vi v;
	rep(i, 0, n) v.pb(max(0LL, h[i]-b*x));
	int cnt = 0;
	rep(i, 0, n){
		cnt += (v[i]+(a-b)-1)/(a-b);
	}
	return cnt <= x;
}

signed main()
{
	cin >> n >> a >> b;
	h.resize(n);
	rep(i, 0, n) cin >> h[i];

	int l = 0, r = 1e9;
	while(r-l > 1){
		int m = (l+r)/2;
		if(check(m)) r = m;
		else l = m;
	}
		
	cout << r << endl;

	return 0;
}


Measured memory_bytes: 2896
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,a=0; cin>>n;
    if(n%2) return puts("0"),0;
    a += n / 10;
    a += n / 50;
    a += n / 250;
    a += n / 1250;
    a += n / 6250;
    a += n / 31250;
    a += n / 156250;
    a += n / 781250;
    a += n / 3906250;
    a += n / 19531250;
    a += n / 97656250;
    a += n / 488281250;
    a += n / 2441406250;
    a += n / 12207031250;
    a += n / 61035156250;
    a += n / 305175781250;
    a += n / 1525878906250;
    a += n / 7629394531250;
    a += n / 38146972656250;
    a += n / 190734863281250;
    a += n / 953674316406250;
    a += n / 4768371582031250;
    a += n / 23841857910156250;
    a += n / 119209289550781250;
    a += n / 596046447753906250;
    cout << a << endl;
}

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

int main() {
  int N, K, S;
  cin >> N >> K >> S;
  for (int i = 0; i < K; ++i)
    if (i == K - 1 && K == N)
      cout << S << endl;
    else
      cout << S << ' ';
  for (int j = K; j < N; ++j)
    if (j == N - 1)
      cout << S % 1000000000 + 1 << endl;
    else
      cout << S % 1000000000 + 1 << ' ';
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
	char s[11];
	scanf("%s",s);
	int i;
	int min = 999999;
	int n = strlen(s);
	for(i=0;i<n-2;i++){
		int temp = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0')*1;
		int difference = abs(753 - temp);
		if( min > difference){
			min = difference;
		}	
	}
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    ll ans = 1e9;
    ans = min(ans,a*x+b*y);
    ans = min(ans,c*2*max(x,y));
    if(x>y){
        ans = min(ans,c*2*y+a*(x-y));
    }else{
        ans = min(ans,c*2*x+b*(y-x));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 200005
using namespace std;
char str[maxn];
int main(){
	scanf("%s",str+1);
	ll cnt=0,ret=0;
	int len=strlen(str+1);
	for(int i=1;i<=len;++i){
		if(str[i]=='W')ret+=cnt;
		else cnt++;
	}
	printf("%lld",ret);
	return 0;
}

Measured memory_bytes: 384
// abc055_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  ll ans=1;
  for(int i=1;i<=n;++i) {
    ans = (i * ans) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size();++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main(){
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		vector<complex<double>> go;
		REP(i, n) {
			double a, b;
			scanf("%lf,%lf", &a, &b);
			go.push_back(complex<double>(a, b));
		}
		vector<int> s = convex_hull(go);
		cout << n - s.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3272
/*
Author: CNYALI_LK
LANG: C++
PROG: A.cpp
*/
#include<bits/stdc++.h>
#define up(a,b,c) for (int a(b),a##end(c);a<=a##end;++a)
#define down(a,c,b) for (int a(b),a##end(c);a>=a##end;--a)
#define uup(a,c,b) for (int a(b),a##end(c);a<=a##end;++a)
#define udown(a,b,c) for (int a(b),a##end(c);a>=a##end;--a)
#define endl '\n'
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int q,h,s,d,n;
	scanf("%d%d%d%d%d",&q,&h,&s,&d,&n);
	if(q*2<=h)h=q*2;
	if(h*2<=s)s=h*2;
	if(s*2<=d)d=s*2;
	ll t=0;
	t+=n/2;
	t*=d;
	if(n&1)t+=s;
	printf("%lld\n",t);
	return 0;
}



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

int main() {
	long long S = 1;
	for (int i = 0; i < 15; i++) {
		cout << "? " << S << endl;
		string P; cin >> P; if (P == "N") break;
		S *= 10;
	}
	if (S >= (1LL << 40)) {
		S = 10;
		for (int i = 0; i < 14; i++) {
			cout << "? " << S - 1 << endl;
			string P; cin >> P; if (P == "Y") break; S *= 10;
		}
		cout << "! " << (S / 10) << endl;
		return 0;
	}
	S /= 10;
	long long L = S, R = S * 10, M, minx = S - 1;
	for (int i = 0; i < 50; i++) {
		M = (L + R) / 2;
		cout << "? " << min(M, S * 10 - 1) * 10 << endl;
		string P; cin >> P;
		if (P == "Y") R = M;
		else { L = M; minx = max(minx, M); }
	}
	cout << "! " << (minx + 1) << endl;
	return 0;
}

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

using namespace std;

#define endl '\n'
#define tab " "
#define lli long long int
#define pb push_back

void read(){
    string s;
    lli si;

    cin >> si >> s;

    if(s.size() <= si) cout << s;
    else{
        for(int i = 0; i < si; ++i){
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return;
}

int main(){
    read();
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = n / (a+b) * a + min(n%(a+b), a);
    cout << ans << "\n";
}


Measured memory_bytes: 3656
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(to!long).array;
    long x, y;
    int cnt = 0;
    int first = N;
    int zero = -1;

    foreach (i; 0..N) {
        if (A[i] == 0) {
            zero = i;
            break;
        }
    }
    if (zero != -1) {
        A.remove(zero);
        N -= 1;
        K -= 1;
    }

    if (K == 0) {
        writeln(0);
        return;
    }

    foreach (i; 0..N) {
        if (A[i] >= 0) {
            first = i;
            break;
        }
    }

    if (first == N) {
        writeln(-A[N-K]);
        return;
    }


    int bk = max(first - K, 0);
    long ans = 1L << 59;
    if (first - K >= 0) ans = min(ans, -A[bk]);
    if (first + K - 1 < N) ans = min(ans, A[first + K - 1]);
    foreach (i; first..N) {
        int len = i - bk + 1;
        if (len < K) continue;
        if (len > K) bk += 1;
        if (A[bk] > 0) continue;
        long x1 = A[i] * 2 - A[bk];
        long x2 = - A[bk] * 2 + A[i];
        ans = min(ans, x1, x2);
    }

    ans.writeln;
}


Measured memory_bytes: 4352
n,k0=map(int,input().split())
mod=10**9+7

# DP[j,k]=l で,j個保留してスコアkのときの場合の数がl

from collections import defaultdict

DP=defaultdict(int)
DP[0,0]=1

for i in range(n):
    NDP=defaultdict(int)

    for j,k in DP:
        l=DP[j,k]

        NDP[j,k+2*j]=(NDP[j,k+2*j]+l)%mod

        if j>=1:
            NDP[j,k+2*j]=(NDP[j,k+2*j]+2*j*l)%mod

        if j>=1:
            NDP[j-1,k+2*(j-1)]=(NDP[j-1,k+2*(j-1)]+j*j*l)%mod

        NDP[j+1,k+2*(j+1)]=(NDP[j+1,k+2*(j+1)]+l)%mod

    DP=NDP

ANS=0
for j,k in DP:
    if j==0 and k==k0:
        ANS+=DP[j,k]

print(ANS%mod)

Measured memory_bytes: 17152
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; ++i)
            arr[i] = in.nextInt();

        PriorityQueue<Double> q = new PriorityQueue<>();
        for (int i : arr)
            q.offer(1.0 * i);

        while (q.size() > 1) {
            double x = q.poll();
            double y = q.poll();

            q.offer((x + y) / 2);
        }

        System.out.println(q.poll());
    }

}

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

#define IOS cin.tie(0);ios::sync_with_stdio(0)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//void print(){}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
//    IOS;
    CIN(N);
    long double sum=0.0;
    rep(i,N){
        double x;
        string v;
        cin>>x>>v;
        if(v=="BTC") sum+=x*380000.0;
        else sum+=x;
    }
    cout<<setprecision(10)<<fixed<<sum<<endl;
    
    return 0;
}

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

ll n,k,m,a,b,c,x,y;
string s;

int main() {
  cin >> a >> b >> c >> x >> y;
  if(c*2<=a+b){
    if(x>y)
      cout << min(y*2*c+(x-y)*a,2*x*c) << endl;
    else 
      cout << min(x*2*c+(y-x)*b,2*y*c) << endl;
  }else 
      cout << a*x+b*y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    int x; cin >> x;
    for (int i = 1; i <= 360; i++) {
        int d = i * 360;
        if (d % x == 0) {
            cout << d / x << endl;
            return 0;
        } 
    }
} 


Measured memory_bytes: 3620
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxv = 2e5+5;
vector<int> G[maxv]; int deg[maxv][2], colr[maxv], inQ[maxv];

int main()
{
#ifdef FOO_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,m; string s;
    while (cin >> n >> m >> s) {
        s = '#' + s;
        FOR(i,1,n+1) {
            G[i].clear();
            colr[i] = s[i]-'A';
        }
        memset(inQ,0,sizeof(inQ));
        memset(deg,0,sizeof(deg));
        FOR(_,0,m) {
            int a,b; cin >> a >> b;
            G[a].push_back(b);
            G[b].push_back(a);
            deg[a][colr[b]]++;
            deg[b][colr[a]]++;
        }
        vector<int> Q;
        FOR(u,1,n+1) if (!deg[u][0] || !deg[u][1])
            Q.push_back(u), inQ[u]++;
        for (int i = 0; i < Q.size(); i++) {
            const int u = Q[i];
            FOR_ALL(v,G[u]) if (!inQ[*v]) {
                deg[*v][colr[u]]--;
                if (!deg[*v][0] || !deg[*v][1]) {
                    Q.push_back(*v);
                    inQ[*v]++;
                }
            }
        }
        if (Q.size() == n)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 14864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long a[10000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  cout<<abs(a[0]-a[n-1])<<'\n';
  return(0);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
class UnionFind {
private:
  int siz;
  vector<int> a;

public:
  UnionFind(int x) : siz(x), a(x, -1) {}

  int root(int x) {
    return a[x] < 0 ? x : a[x] = root(a[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    siz--;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] =x;
    return true;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return -a[root(x)];
  }
  
  int connected_component() {
  	return siz;
  }
};
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> deg(n);
  set<pair<int, int>> edges;
  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    deg[a]++;
    deg[b]++;
    uf.unite(a, b);
  }
  vector<int> ans(n);
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    if (edges.count(make_pair(a, b))) continue;
    if (uf.same(a, b)) {
      deg[a]++;
      deg[b]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << uf.size(i) - deg[i] - 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define long long long
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  int N;
  scanf("%d", &N);
  for (int i = 0; i < (1 << N); ++i) {
    printf("%d:", i);

    for (int j = 0; j < N; ++j) {
      if((i>>j) & 1) printf(" %d", j);
    }
    puts("");
  }

  return 0;
}




Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a-b <= c){
    cout << c - (a-b) << endl;
  }
  else{
    cout << 0 << endl;
  }
    
  
}

Measured memory_bytes: 3668
// Longest Path

/*

Given a Directed Acyclic Graph. Let's find the topological order first
Now, let distance[i]=distance of vertex i from s

take the topologically smallest one and relax all others

*/

#include<bits/stdc++.h>

using namespace std;


vector<int> getTopologicalSort(vector<list<int>> & A){
    int n=A.size();
    vector<int> indegree(n);
    for(int i=0;i<n;i++){
        for(int x:A[i]){
            indegree[x]++;
        }
    }
    queue<int> q;
    for(int i=0;i<n;i++){
        if(indegree[i]==0){
            q.push(i);
        }
    }

    vector<int> ans;
    while(!q.empty()){
        int front=q.front();
        ans.push_back(front);
        q.pop();
        for(int x:A[front]){
            indegree[x]--;
            if(indegree[x]==0){
                q.push(x);
            }
        }
    }

    return ans;

}

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

    int n, m;
    cin>>n>>m;
    
    vector<list<int>> adj(n);
    int source, dest;
    for(int i=0;i<m;i++){
        cin>>source>>dest;
        source--;
        dest--;
        adj[source].push_back(dest);
    }
    vector<int> topoSort=getTopologicalSort(adj);
    vector<int> distance(n);

    for(int i=0;i<n;i++){
        int current=topoSort[i];
        for(int x:adj[current]){
            distance[x]=max(distance[current]+1, distance[x]);
        }
    }

    int ans=0;
    for(int x:distance){
        ans=max(ans,x);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 9776
from collections import deque

N,M = map(int, input().split())
E = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    E[a-1].append((b-1, i))
    E[b-1].append((a-1, i))
    
ans = 0
for i in range(M):
    used = [0]*N
    q = deque()
    if i == 0:
        used[1] = 1
        q.append(1)
    else:
        used[0] = 1
        q.append(0)
    while q:
        t = q.popleft()
        for L in E[t]:
            j = L[0]
            e = L[1]
            if used[j] == 0 and e != i:
                q.append(j)
                used[j] = 1
    if sum(used) < N:
        ans += 1
        
print(ans)

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a>=13){
    cout << b;
  }
 else if(a >= 6){
   cout << b/2;
 }
  else{
    cout << "0";
  }
}

Measured memory_bytes: 3608
def gcd(A, B):
    if B > A: 
        A, B = B, A

    if B == 0:
        return A
    else:
        return gcd(B, A%B)


A, B = map(int, raw_input().split())

gcdAB = gcd(A, B)

print '{}'.format(A*B/gcdAB)



Measured memory_bytes: 2568
import java.util.*;

public class Main{
	public static void main(String[] args) throws Exception{
	
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
 
    int ans = A+B;
    ans = ans < A-B ? A-B : ans;
    ans = ans < A*B ? A*B : ans;
    
    System.out.print(ans);
 
      
	}
} 


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int main(){
  long h,w;
  cin >> h >> w;
  long sx,sy,gx,gy;
  cin >> sx >> sy >> gx >> gy;
  sx--;sy--;gx--;gy--;
  vvc data(h, vector<char>(w, '#'));
  rep(i,h){
    rep(j,w){
      cin >> data.at(i).at(j);
    }
  }
  
  deque<pll> que;
  deque<long> qu;
  vvl dist(h, vl(w, -1));
  que.push_back(pll(sx,sy));
  qu.push_back(0);

  while(que.size()){
    pll P = que.front();
    que.pop_front();
    int d = qu.front();
    qu.pop_front();
    int x = P.first;
    int y = P.second;
    if(dist.at(x).at(y) != -1) continue;
    dist.at(x).at(y) = d;
    for(int i=-2;i<=2;i++){
      for(int j=-2;j<=2;j++){
        int c = abs(i) + abs(j);
        if(c == 0) continue;
        int nx = x + i;
        int ny = y + j;
        if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if(data.at(nx).at(ny) == '#') continue;
        if(dist.at(nx).at(ny) != -1) continue;
        if(c == 1){
          que.push_front(pll(nx,ny));
          qu.push_front(d);
        }else{
          que.push_back(pll(nx,ny));
          qu.push_back(d+1);
        }
      }
    }
  }
  cout << dist.at(gx).at(gy) << endl;
}

Measured memory_bytes: 13408
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int C[10][10],perm[10]={1,2,3,4,5,6,7,8};
bool flag=true;

int main(){
  int N,M,a,b,ans=0,count=0;
  cin>>N>>M;

  for(int i=0;i<M;i++){
    cin>>a>>b;
    C[a][b]++; C[b][a]++;
  }
  
  do{
    //for(int i=0;i<N;i++) cout<<perm[i]<<endl;
    //count++;
    for(int i=1;i<N;i++){
      if(C[perm[i-1]][perm[i]]==0) flag=false;
    }
    if(flag) ans++;
    flag=true;
  }while(next_permutation(perm+1,perm+N));
  //cout<<count<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%s", $s);

$len = strlen($s);

$first = substr($s, 0, floor($len / 2));
$last = substr($s, ceil($len / 2));
$last_rev = strrev($last);

$first_arr = str_split($first);
$last_arr = str_split($last_rev);

$count = 0;
foreach ($first_arr as $i => $first_char) {
    if ($first_char !== $last_arr[$i]) {
        ++$count;
    }
}

echo $count;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;




int main(void) {
  ll N;
  cin >> N;
  pt((N+1)/2);
  
  
  
  
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
bool judge(int x)
{
    int tmp=x%10;
    while(x)
    {
        if(x%10!=tmp) return false;
        x/=10;
    }
    return true;
}
int main()
{
    int x;
    cin>>x;
    for(int i=x;i<=999;i++)
    {
        if(judge(i))
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;   
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int n;

    while (~scanf("%d", &n)) {
        if (n == 0) break;
        int P, Q, R, C;
        int s[n], p[n], q[n], r[n];
        int flg[1001] = {};

        REP (i, n) {
            scanf("%d%d%d%d", &s[i], &p[i], &q[i], &r[i]);
        }
        scanf("%d%d%d%d", &P, &Q, &R, &C);

        REP (i, n) {
            if (p[i] > P || q[i] > Q || r[i] > R || (p[i] + r[i]) * 4 + q[i] * 9 > C) {
                flg[i] = 1;
            }
        }

        int isout = 0;
        REP (i, n) {
            if (!flg[i]) {
                isout = 1;
                printf("%d\n", s[i]);
            }
        }

        if (!isout) {
            OUT("NA");
        }

    }
    return 0;
}




Measured memory_bytes: 3220