akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main () {
 ll n; cin >> n;
 ll ans=0;
 if(n%2==1){
   cout << 0 <<endl;
   return 0;
 }
 else{
  for(ll i=5;i<=n/2;i*=5){
    ll d=n/(i*2);
    ans+=d;
  }
  cout << ans << endl;
 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	priority_queue<pii> que;
	int ceil = 0;
	REP(i, n)
	{
		int a; cin >> a;
		chmax(ceil, a);
		que.emplace(a, i);
	}
	ll cnt = 0;
	vi ans(n);
	int tmpp = 1e9;
	while (!que.empty())
	{
		ll v = que.top().first;
		int p = que.top().second;
		chmin(tmpp, p);
		que.pop();
		cnt++;
		if (!que.empty())
		{
			ll d = v - que.top().first;
			ans[tmpp] += d * cnt;
		}
		else
		{
			ans[0] += v * n;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2804
#include <iomanip>
#include <utility>
#include <algorithm>
#include <type_traits>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
#include <memory>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <queue>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <forward_list>
#include <iomanip>
#include <functional>
using namespace std;
#define MFOR(i,end) for(size_t i = 0, end_i = (end); i < end_i; ++ i)

bool red[100005];
int ball_num[100005];
int main()
{
	red[1] = true;
	int N, M;
	std::cin >> N >> M;
	for (size_t i = 0; i <= N; ++i) {
		ball_num[i] = 1;
	}

	int count = 1;
	for (int i = 0; i < M; ++i)
	{
		int x, y;
		std::cin >> x >> y;

		if (red[y] == false && red[x] == true) {
			red[y] = true;
			++count;
		}
		--ball_num[x];
		++ball_num[y];
		if (red[x] == true && ball_num[x] == 0) {
			red[x] = false;
			--count;
		}
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 768
H, W = map(int, input().split())
matrix = []

for _ in range(H):
    row = list(input())
    for i in range(W):
        if row[i] == ".":
            row[i] = 0
    matrix.append(row)

for i in range(H):
    for j in range(W):
        if matrix[i][j] == "#":
            for k in [-1, 0, 1]:
                for l in [-1, 0, 1]:
                    if i+k < 0 or i+k == H or j+l < 0 or j+l == W:
                        continue
                    try:
                        matrix[i+k][j+l] += 1
                    except:
                        pass

for row in matrix:
    row = [str(x) for x in row]
    print("".join(row))


Measured memory_bytes: 3064
"""
fast way to compute a combination using inverse factorials
O(N) to construct tables -> O(1) to compute each combination
"""


def get_fact_and_inv(limit: int, MOD: int) -> tuple:
    """Compute mod tables of factorials and inverse factorials (1-indexed)."""
    factorials = [0] * (limit + 1)
    factorials[0] = 1
    x = 1
    for i in range(1, limit + 1):
        x = (x * i) % MOD
        factorials[i] = x

    inverse_factorials = [1] * (limit + 1)
    inverse_factorials[-1] = pow(factorials[-1], MOD - 2, MOD)
    x = inverse_factorials[-1]
    for i in range(limit - 1, 0, -1):
        x = (x * (i + 1)) % MOD
        inverse_factorials[i] = x
    return factorials, inverse_factorials


def mod_comb(n: int, r: int, MOD: int) -> int:
    """Compute nCr % MOD using a mod table of inverse factorials."""
    return fact[n] * inv[r] * inv[n - r] % MOD


# e.g. ARC058D - いろはちゃんとマス目 / Iroha and a Grid (ABC042D)
def main():
    global fact, inv
    H, W, A, B = map(int, input().split())
    MOD = 10 ** 9 + 7
    fact, inv = get_fact_and_inv(H + W, MOD)
    x, y, a = H - A - 1, W + A - 2, A - 1  # fixed variables
    f = lambda i: mod_comb(x + i, i, MOD) * mod_comb(y - i, a, MOD) % MOD
    ans = sum(f(i) for i in range(B, W)) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18804
//
// Created by maze on 2019/11/03.
//

#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)le18
#define INF (int32)le9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

int comp(const string& lhs, const string& rhs) {
  if (isdigit(lhs[0]) && isdigit(rhs[0])) {
    if (lhs.size() != rhs.size()) return lhs.size() < rhs.size() ? -1 : 1;
    else return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
  } else if (isdigit(lhs[0]) || isdigit(rhs[0])) {
    return isdigit(lhs[0]) ? -1 : 1;
  } else {
    return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
  }
}

int comp(const vector<string>& lhs, const vector<string>& rhs) {
  REP(i, min(lhs.size(), rhs.size())) {
    int ret = comp(lhs[i], rhs[i]);
    if (ret == -1) return -1;
    else if (ret == 1) return 1;
  }
  return (lhs.size() < rhs.size() ? -1 : (lhs.size() == rhs.size() ? 0 : 1));
}

int main(void) {

  int64 n;
  cin >> n;
  vector<vector<string>> s(n+1);
  REP(i, n+1) {
    string t;
    cin >> t;
    string now = "";
    REP(j, t.size()) {
      if (now == "" || isdigit(t[j]) == isdigit(now[0])) {
        now += t[j];
      } else {
        s[i].push_back(now);
        now = t[j];
      }
    }
    if (now != "") {
      s[i].push_back(now);
    }
  }
  FOR(i, 1, n+1) {
    int ret = comp(s[i], s[0]);
    if (ret == -1) {
      cout << '-' << endl;
    } else {
      cout << '+' << endl;
    }
  }
}


Measured memory_bytes: 3356
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/abc174/tasks/abc174_b
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,d;
    cin >> n >> d;
    ll ans = 0;
    for(int i = 0;i<n;i++){
        ll s,e;
        cin >> s >> e;
        ll dis = s*s+e*e;
        if(dis <= d*d) ans++;
    }
    cout << ans;

    return 0; 
}

Measured memory_bytes: 3656
<?php

$line = trim(fgets(STDIN));
$stack = array();
$operator = array_flip(explode(',', '+,-,*,/'));
foreach (explode(' ', $line) as $str) {
    if (!isset($operator[$str])) {
        $stack[] = (int)$str;
        continue;
    }
    $b = array_pop($stack);
    $a = array_pop($stack);
    switch ($str) {
        case '+':
            $result = $a + $b;
            break;
        case '-':
            $result = $a - $b;
            break;
        case '*':
            $result = $a * $b;
            break;
        case '/':
            $result = $a / $b;
            break;
        default:
            throw new Error('error');
    }
    $stack[] = $result;
}

echo array_shift($stack), PHP_EOL;

Measured memory_bytes: 6664
import java.util.*;

class Main {
	
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();
	int b = scan.nextInt();
	if (a <= 8 && b <= 8) {
	    System.out.println("Yay!");
	} else {
	    System.out.println(":(");
	}
    }
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int n;
int a[1111];

signed main() {
   cin >> n;
   int odd = 1;
   rep (i, n){ 
      cin >> a[i];
      if (a[i] % 2 == 0) {
         odd *= 2;
      }
   }

   int all = 1;
   rep (i, n) {
      all *= 3;
   }

   dbg2(all, odd)
   cout << all - odd << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

bool comp(const string& i, const string& j){
	return (i > j);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	cout << n/3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e5 + 5;
typedef long long ll; 
using namespace std;

int n, a[N], b[N];
ll f[N][3];
char s[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
	n = read <int> (), a[1] = read <int> ();
	for(int i = 2; i <= n; i++)
	{
		scanf("%s", s + 1), b[i] = s[1] == '-' ? 0 : 1;
		a[i] = read <int> (); 
	}
	memset(f, -0x3f, sizeof(f)), f[1][0] = a[1];
	for(int i = 2; i <= n; i++)
	{
		if(b[i])
		{
			f[i][0] = max(f[i - 1][0] + a[i], f[i - 1][1] - a[i]); 
			f[i][1] = max(f[i - 1][1] - a[i], f[i - 1][2] + a[i]); 
			f[i][2] = f[i - 1][2] + a[i]; 
		}
		else
		{
			f[i][0] = max(f[i - 1][0] - a[i], f[i - 1][1] + a[i]); 
			f[i][1] = max(f[i - 1][1] + a[i], f[i - 1][2] - a[i]);
			f[i][1] = max(f[i][1], f[i - 1][0] - a[i]);
			f[i][2] = max(f[i - 1][2] - a[i], f[i - 1][1] + a[i]); 
		}
	}
	printf("%lld\n", f[n][0]); 
	return 0; 
}

Measured memory_bytes: 6352
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
        int res=0;
        for(int i=1;i<=5;i++){
            int x=ni();
            if(x==0)
                res=i;
        }        
        pn(res);
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
//        t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 36684
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (ll i = 0; i < n; i++)
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const ll MX = 300005;
const ll inf = 2e18;

#define ptr nodo*
#define tam 301000
ll n,m,v,p;
ll  valor[tam],arr[tam];
bool f(int pos0)
{
    forr(i,0,n)
    arr[i]=valor[i];
    arr[pos0]+=m;
    ll avalor=arr[pos0];
    if (arr[pos0]<arr[p-1])
        return 0;
    ll tot= n-pos0;
    sort(arr,arr+pos0+1);
    reverse(arr,arr+pos0+1);
    
    /*int cnt=0,ant=-1;
    forr(i,0,pos0+1)
    {
        if (ant==arr[i])
            cnt++;
        else
        {
            if (cnt>=p)break;
            cnt++;
            ant=arr[i];
        }
    }*/
    tot+=p-1;
    ll atot=0;
    
    forr(i,p,pos0+1)
    {
        //<<arr[i]<<' ';
        atot+=(avalor-arr[i]);
    }
    tot+=(atot/m);
    
    return (tot>=v);
}
int main () 
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin>>n>>m>>v>>p;
    
    forr(i,0,n)
    {
        cin>>valor[i];
    }
    sort(valor,valor+n);
    reverse(valor,valor+n);    
    int cnt,iz,ant=-1;
    cnt=0;
    forr(i,0,n)
    {
        

        iz=i;
        if (ant==valor[i])
            cnt++;
        else
        {
            if (cnt>=p)break;
            ant=valor[i];
            cnt++;
        }
    }
    
    int der,mid;
    der=n;
    while(iz+1<der)
    {
        mid=(iz+der)/2;
        if (f(mid))
            iz=mid;
        else
            der=mid;
    }
    
    if (f(iz)==0)
        iz=iz-1;

    cout<<iz+1<<endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    ll N, M;
    cin >> N;
    cout << 180 * (N - 2) << endl;
}

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

typedef long long LL;

const int N=200000,mod=998244353;

int n,m,l[N+9],r[N+9];
int dp[N+9],sum[N+9];

void work(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=m;++i)
	scanf("%d%d",&l[i],&r[i]);
  dp[1]=sum[1]=1;
  for (int i=2;i<=n;++i){
	for (int j=1;j<=m;++j){
	  //printf("%d : %d %d\n",i,l[j],r[j]);
	  if (i-l[j]>=1) dp[i]=(dp[i]+sum[i-l[j]])%mod;
	  if (i-r[j]>=1) dp[i]=(dp[i]-sum[i-r[j]-1]+mod)%mod;
	}
	sum[i]=(dp[i]+sum[i-1])%mod;
  }
  printf("%d\n",dp[n]);
}

int main(){
  int T=1;
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 5388
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    string r;
    while(n>0)
    {
        n--;
        r= string(1,('a'+(n%26)))+r;
        n/=26;
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define REP(i,a,b) for(int i=a; i<=int(b); i++)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,a;
    cin >> n;
    ll ans=0;
    REP(i,1,n){
        cin >> a;
        ans+=(a&1 && i&1);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  priority_queue<P> que;
  vector<ll> a(n), b(n);
  rep(i,n) {
    cin >> a[i] >> b[i];
    que.push(P(a[i]+b[i],i));
  }
  ll ans = 0;
  rep(i,n) {
    P p = que.top(); que.pop();
    if (i % 2 == 0) ans += a[p.second];
    else ans -= b[p.second];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	cout << 48 - N << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define ll long long int
#define li long int
using namespace std;
int n;
li weight;
vector<int> w(101);
vector<int> v(101);
vector<vector<ll>> dp(101,vector<ll> (100005,-1));
int sum=0;
ll cost(int ind,int sum1)
{
    if(ind>n||sum1<=0)
    {
        if(sum1==0)
            return 0;
        else
            return INT_MAX;
    }
    if(dp[ind][sum1]==-1)
    {
        if(v[ind]<=sum1)
        {
            ll left=cost(ind+1,sum1-v[ind])+w[ind];
            ll right=cost(ind+1,sum1);
            dp[ind][sum1]=min(left,right);
        }
        else
            dp[ind][sum1]=cost(ind+1,sum1);
    }
    return dp[ind][sum1];
}

int check()
{
    for(int i=sum;i>0;i--)
    {
        ll ans=cost(1,i);
        //cout<<ans<<" "<<weight;
        if(ans<=weight)
        {
            return i;
        }
    }
    return 0;
}

int main()
{
    cin>>n>>weight;
    //cout<<"hello"<<weight;
    fo(i,1,n+1)
        cin>>w[i]>>v[i];
    fo(i,1,n+1)
        sum+=v[i];
    cout<<check();
    //ll ans=cost(1,sum,weight);
    //cout<<ans;
}


Measured memory_bytes: 83036
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

typedef long long ll;
//No change above here

const ll maxi = 302;
ll mod = (1e9 + 7);

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret=0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }

//declare needed things here



int main()
{
	IOS;
	ll h, w, k;
	cin >> h >> w >> k;
	ll r = pow(2, h);
	ll c = pow(2, w);
	ll ans = 0;
	vector<string> v(h);
	for (int i = 0; i < h; ++i)
		cin >> v[i];
	for (ll i = 0; i < r; ++i)
	{
		for (ll j = 0; j < c; ++j)
		{
			ll count = 0;
			for (ll y = 0; y < h; ++y)
			{
				for (ll z = 0; z < w; ++z)
				{
					if (((1 << y) & i) || ((1 << z) & j))
						continue;
					if (v[y][z] == '#')
						++count;
				}
			}
			if (count == k)
				++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4056
use std::collections::HashMap;
fn main() {
    let n = read::<usize>();
    let mut v = vec![];
    let mut hmall = HashMap::new();
    let HASH_MAX = 10000;
    for _ in 0..n {
        let s = read::<String>().chars().collect::<Vec<_>>();
        let mut hm = HashMap::new();
        for c in s {
            let cc = hm.entry(c).or_insert(0);
            *cc += 1;

            let cc = hmall.entry(c).or_insert(HASH_MAX);
        }
        v.push(hm);
    }
    //println!("{:?}", v);

    let hmall2 = hmall.clone();
    //println!("{:?}", hmall2);
    for (key, val) in hmall2 {
        for i in 0..n {
            if let Some(cv) = v[i].get(&key) {
                let c = hmall.entry(key).or_insert(0);
                if *c > *cv {
                    *c = *cv;
                }
            } else {
                hmall.insert(key, 0);
            }
        }
    }
    //println!("{:?}", hmall);

    let mut ansv = vec![];
    for &k in hmall.keys() {
        if let Some(&cc) = hmall.get(&k) {
            if cc != HASH_MAX {
                for _ in 0..cc {
                    ansv.push(k);
                }
            }
        }
    }
    ansv.sort();
    let ans = ansv.into_iter().collect::<String>();
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


int main()
{
    int N;
    cin >> N;
    vector<int> R(N);
    int maxv = -1000000000;
    rep(i,N) {
        cin >> R[i];
    }
    int minv = R[0];
    for (int j = 1; j < N; j++) {
        maxv = max(maxv, R[j]-minv);
        minv = min(minv, R[j]);
    }
    cout << maxv << endl;
}


Measured memory_bytes: 3544
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <sstream>
#include <vector>
using namespace std;

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    string ABC = "ABC";

    int counter = 0;
    for (int i = 0; i < N - 2; i++)
    {
        if (S.compare((size_t)i, 3, ABC) == 0)
        {
            counter++;
        }
    }

    cout << counter << endl;
    return 0;
}


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

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

int main() {
    int n;
    cin >> n;
    vector<ll> a (n);
    ll minus = 0;
    vector<ll> rev (n);
    ll ans = 0;
    for(int i=0; i<n; i++){
        ll x;
        cin >> x;
        a.at(i) = x;
        if(x < 0){
            x = -x;
            minus++;
        }
        rev.at(i) = x;
        ans += x;
    }
    sort(rev.begin(),rev.end());
    if(minus%2 == 1) ans -= rev.at(0)*2;
    cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	int s;
	vector<int>a;
	for (int i = 0; i < n; i++) {
		cin >> s;
		a.push_back(s);
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	cout << a.size() << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict


def main():
    n, v = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    b = list(map(int, sys.stdin.readline().split()))
    c = list(map(int, sys.stdin.readline().split()))
    d = list(map(int, sys.stdin.readline().split()))
    mp = defaultdict(int)
    for val1 in c:
        for val2 in d:
            mp[val1 + val2] += 1
    print(sum(mp[v - val1 - val2] for val1 in a for val2 in b))

if __name__ == '__main__':
    main()



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

int main () {
    int n;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n, 0);
        for (auto &x : a) scanf("%d", &x);

        int res = 0;
        for (int i = 1; i <= n; i++)
            res += i % 2 && a[i - 1] % 2;
        printf("%d\n", res);
    }
}



Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	ll n = 0,a = 1;
	std::cin >> n;
	for(ll i = 1; i<=n;i++){
		a = (a * i)%1000000007;
	}
	std::cout << a << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>//WA 1 may 2020
using namespace std;
int main()
{
char str[6];
scanf("%s",str);
if(strcmp(str,"ABC")==0)
        cout<<"ARC"<<endl;
else if(strcmp(str,"ARC")==0)
        cout<<"ABC"<<endl;


    return 0;
}



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

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

  cin >> N >> M >> X;

  vector<int> c(N);
  vector<vector<int>> a(N, vector<int>(M));

  for (int i = 0; i < N; i++) {
    cin >> c[i];
    for (int j = 0; j < M; j++) {
      cin >> a[i][j];
    }
  }
  int ans=1e9;
  for(int tmp=0;tmp<(1<<12);tmp++){
    bitset<12> s(tmp);
    vector<int> sum(M);
    int pri=0;
    for(int i=0;i<N;i++){
      if(s.test(i)){
        pri +=c[i];
        for(int j=0;j<M;j++){
          sum[j] +=a[i][j];
        }
      }
    }
    bool all=true;
    for(int i=0;i<M;i++){
      if(sum[i]<X){
        all=false;
      }
    }
    if(all){
      ans =min(ans,pri);
    }
  }
  if(ans == 1e9){
  cout<<-1<<endl;
  }else{
  cout<<ans<<endl;
}}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	ll num, i, k, ans = 0;
	cin >> num >> k;
	num++;
	for (i = k; i <= num; i++) {
		ans += (num - i) * i + 1;
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[10000000];
#define mod 1000000007
int solve(int arr[][3],int idx,int i){

	return max(arr[idx][(i+1)%3],arr[idx][(i+2)%3]);
}
int main(){
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++)
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	for(int i=n-2;i>=0;i--){
		arr[i][0] += solve(arr,i+1,0);
		arr[i][1] += solve(arr,i+1,1);
		arr[i][2] += solve(arr,i+1,2);
	}
	cout<<max(arr[0][0],max(arr[0][1],arr[0][2]));
	return 0; 
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    for(int i=0;i<n;i++){
        cin >> m[i];
    }
    int sum;
    sum = accumulate(m.begin(),m.end(),0);
    int mn;
    mn = *min_element(m.begin(),m.end());
    int res;
    res = x-sum;
    int ad;
    ad = res/mn;
    cout << n+ad << endl;
}




Measured memory_bytes: 256
use proconio::input;
use std::collections::BTreeSet;

// n mod k = 1 なら k で可
// n = mk^e (m⊥k) のとき、m mod k = 1 なら k で可

fn main() {
    input!(n: u64);
    let mut s = BTreeSet::new();
    s.extend(divisors(n - 1));
    for &k in divisors(n).iter().filter(|&&x| x > 1) {
        let mut m = n;
        while m % k == 0 {
            m /= k;
        }
        if m % k == 1 {
            s.insert(k);
        }
    }
    s.remove(&1);
    println!("{}", s.len())
}

fn divisors(n: u64) -> Vec<u64> {
    let mut res = Vec::new();
    for d in 1.. {
        if d * d > n {
            break;
        }
        if n % d == 0 {
            res.push(d);
            res.push(n / d)
        }
    }
    res[0] = res[1];
    res
}


Measured memory_bytes: 2200
#include<iostream>
#include<string>
using namespace std;
int main(void) {
    int count = 0;
    string W, T;
    cin >> W;
    for (int i = 0; i < W.size(); i++) W[i] = tolower(W[i]);
    while (true) {
        cin >> T;
        if (T == "END_OF_TEXT") break;
        for (int i = 0; i < T.size(); i++) T[i] = tolower(T[i]);
        if (W == T) count++;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
    int r, c; cin >> r >> c;
    vector<vector<int>> a(r + 1, vector<int>(c + 1, 0));
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> a[i][j];
            a[r][j] += a[i][j];
            a[i][c] += a[i][j];
            a[r][c] += a[i][j];
        }
    }
    for(int i = 0; i <= r; i++){
        for(int j = 0; j <= c; j++){
            if(j) cout << ' ';
            cout << a[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3200
import  itertools

d,g=map(int,input().split())
p=[]
c=[]

for i in range(d):
    x,y=map(int,input().split())
    p.append(x)
    c.append(y)

ans=float('inf')

def judge(tmp):
    ss=g
    count=0

    for i in range(d):
        if tmp[i]==1:
            ss-=((i+1)*p[i]*100+c[i])
            count+=p[i]
    if ss<=0:

        return count
    else:
        for i in range(d-1,-1,-1):
            if tmp[i]==0:
                if ss%((i+1)*100)==0:
                    fgh=ss//((i+1)*100)
                else:
                    fgh=1+ss//((i+1)*100)

                if fgh>=p[i]:
                    count+=float('inf')
                else:
                    count+=fgh

                ss -= fgh * ((i + 1) * 100)
            if ss<=0:
                
                return count
       
        return count+float('inf')

nums=[0,1]
for sd in itertools.product(nums,repeat=d):
    pat=list(sd)
    sdf=judge(pat)
    ans=min(ans,sdf)

print(ans)

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

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

switch (N%10){
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    
    cout << "hon";
    break;
    
  case 0:
  case 1:
  case 6:
  case 8:
    
    cout << "pon";
    break;

  case 3:
    
    cout << "bon";
    break;
}
}

Measured memory_bytes: 3612
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }
    let mut v = vec![0; 100_001];
    for &a_ in a.iter() {
        if a_ > 0 {
            v[a_ - 1] += 1;
        }
        v[a_] += 1;
        v[a_ + 1] += 1;
    }

    println!("{}", v.iter().max().unwrap());
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String a = input.next();
		String b = input.next();

		int ai = Integer.parseInt(a);
		int bi = Integer.parseInt(b);

		int s = ai * bi;
		int l = 2*(ai + bi);

		System.out.println(s + " " + l);
		
		
	}
}

Measured memory_bytes: 26292
#include <iostream>
using namespace std;
int count(int n,int s,int i)
{
  if(n == 1){
    if(i <= s && s < 10) return 1;
    return 0;
  }
  int res = 0;
  for(; i<10; i++){
    res += count(n-1, s-i,i+1);
  }
  return res;
}
int main()
{
  int n,s;
  while(cin >> n >> s, n!=0){
    int cnt = count(n,s,0);
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main()
{
	long long int n, i, max, min, b;
	scanf("%lld", &n);
	int a[10005] = {0};
	b=0;
	max=-1000005;
	min=1000005;
	for(i = 0; i < n; i++)
	{	
		scanf("%lld", &a[i]);
		b=b+a[i];
		if(a[i]>=max)
			max =a[i];
		if(a[i]<=min)
			min = a[i];
	}
	printf("%lld %lld %lld\n", min, max, b);
	return 0;
}


Measured memory_bytes: 2784
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  vector<int> b(n);
  rep(snip_i, n) cin >> b.at(snip_i);
  int ans = 0;
  ll mi = 0;
  vector<ll> pl;
  rep(i, n){
    int diff = a.at(i) - b.at(i);
    if(diff > 0) pl.push_back(diff);
    else if(diff < 0){
      mi += diff;
      ans++;
    }
  }
  // cerr << mi << endl;
  // cerr << "t" << ans << endl;
  sort(pl.rbegin(), pl.rend());
  for(int i : pl){
    if(mi >= 0) break;
    mi += i;
    ans++;
  }
  if(mi < 0){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }

  return 0;
}

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

int A[3][3],N,b;

int main(){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>A[i][j];
		}
	}
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>b;
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(A[j][k]==b)A[j][k]=0;
			}
		}
	}
	bool f=false;
	for(int i=0;i<3;i++){
		if(A[i][0]==0&&A[i][1]==0&&A[i][2]==0)f=true;
		if(A[0][i]==0&&A[1][i]==0&&A[2][i]==0)f=true;
	}
	if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0)f=true;
	if(A[2][0]==0&&A[1][1]==0&&A[0][2]==0)f=true;
	if(f)puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
# coding=utf-8


def calc_weights(weight):
    weights_list = []
    counter = 0
    while weight > 0:
        if weight % 2 == 0:
            weight /= 2
        else:
            weights_list.append(2**counter)
            weight = (weight - 1)/2
        counter += 1
    print(' '.join(map(str, weights_list)))


if __name__ == '__main__':
    while True:
        try:
            W = int(input())
            calc_weights(W)
        except EOFError:
            break



Measured memory_bytes: 5600
require 'prime'

class Array
  def upper_bound(x)
    bsearch_index { |v| v > x }
  end

  def lower_bound(x)
    bsearch_index { |v| v >= x }
  end
end

class Integer
  def divisor_list
    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

# 75の素因数分解は、3 * (5 ^ 2 )
# p 75.prime_division #=> [3, 1], [5, 2]]
# 75の素因数分解は、以下の6つ
# p 75.divisor_list # => [1, 3, 5, 15, 25, 75]
# 75 = 5 * 5 * 3 = 25 * 3 = 15 * 5
# 9と10の違いを見ると答えがみれそう
# 10!の素因数分解は、{2=>8, 3=>4, 5=>2, 7=>1}
# 9!の素因数分解は、{2=>7, 3=>4, 5=>1, 7=>1}
# [4, 4, 2], [24, 3], [14,4],[74]
# [74]は、80以上で+1
#[14, 4]は、

# 最小の七五数32400 = (2^4) * (3^4) * (5^2)
# p 32400.prime_division #=> [[2, 4], [3, 4], [5, 2]]

# 今回の問題での最大の七五数は2^74。100!を素因数分解すると、50 + 25 + 12 + 6 + 3 + 1 > 75
# 80!で、素因数分解すると、2^78がでてくる。(頑張って求めた)

# k = 0
# 1.upto(100) do |i|
#   k +=1 if i%2 == 0
#   k +=1 if i%4 == 0
#   k +=1 if i%8 == 0
#   k +=1 if i%16 == 0
#   k +=1 if i%32 == 0
#   k +=1 if i%64 == 0
#   p i if k >= 75
#   break if k >= 75
# end

N = gets.to_i

h = Hash.new(0)
1.upto(N) do |i|
  (i.prime_division).each do |k|
    h[k[0]] += k[1]
  end
end
# p h

cnt = Hash.new(0)
h.each do |k, v|
  [2, 4, 14, 24, 74].each do |t| 
    cnt[t]+=1 if v >= t
  end
end

ans = 0
ans += cnt[4] * ( cnt[4] - 1 ) / 2 * ( cnt[2] - 2 )
ans += cnt[14] * ( cnt[4] - 1 )
ans += cnt[24] * ( cnt[2] - 1 )
ans += cnt[74]

p ans

Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int nwd;
    cin >> nwd;
    for (int i = 1; i < n; ++i)
    {
        int x;
        cin >> x;
        nwd = __gcd(nwd, x);
    }
    cout << nwd;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mdsaqib std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

signed main(){
    mdsaqib;
    int k;
    cin >> k;
    string s="ACL";
    for(int i=0;i<k;i++)cout << s;
    
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail +1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

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

int main(){
  int elaps = 0, c;
  int i,q;
  P u;

  scanf("%d %d", &n, &q);
  
  
  for(i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while( head != tail ){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0)enqueue(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }
  return 0;
}



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

void solve()
{
    long long  a,c,b,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
}



main()
{
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
     
     int t;
     t=1;
     while(t--)
     {
         solve();
     }

}




Measured memory_bytes: 3608
n = int(input())

tlist = [] #太郎
hlist = [] #花子

for _ in range(n):
  a = list(map(str, input().split()))
  tlist.append(a[0])
  hlist.append(a[1])
  
tscore = 0
hscore = 0

for t,h in zip(tlist,hlist):
  if t > h:
    tscore += 3
  elif t == h:
    tscore += 1
    hscore += 1
  else:
    hscore += 3

print(tscore, hscore)


Measured memory_bytes: 5620
N = int(input())
H = list(map(int, input().split()))
maxmove = 0
skip = 0
now=0
for i,h in enumerate(H):
    if skip > 0:
        skip -= 1
    else:
        now = h
        for j in range(i+1, N):
            if now < H[j]:
                    break
            else:
                now = H[j]
                skip += 1
        if skip > maxmove:
            maxmove = skip
print(maxmove)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

void solve(long long N, long long K, std::vector<long long> H)
{
    long long ans = 0;
    sort(H.begin(), H.end());
    for (int i = 0; i < N - K; i++)
    {
        ans += H[i];
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> H(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792
var
 ch:char;
 i,a,b,f:longint;
begin
 readln(a,b);
 for i:=1 to a do begin read(ch);if not (ch in ['0'..'9']) then f:=1;end;
 if f=1 then begin writeln('No');halt;end;
 read(ch);
 if ch<>'-' then f:=1;
 if f=1 then begin writeln('No');halt;end;
 for i:=1 to b do begin read(ch);if not (ch in ['0'..'9']) then f:=1;end;
 if f=1 then begin writeln('No');halt;end;
 writeln('Yes');
end.

Measured memory_bytes: 128
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		float t = long.Parse(input[0]);
		float a = long.Parse(input[1]);
		float[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),float.Parse);

    float answer = float.MaxValue;
    int answerNum = 0;

    for(int i = 0; i < n; i++)
    {
      if(answer > Math.Abs(t-a-nums[i]*0.006f))
      {
        answer = Math.Abs(t-a-nums[i]*0.006f);
        answerNum = i+1;
      }
    }

    
		Console.WriteLine(answerNum);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 13204
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
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()
{
	string s; cin >> s;
	int n = SZ(s);
	int STpair_cnt = 0, S_cnt = 0;
	rep(i, n)
	{
		if (s[i] == 'S')S_cnt++;
		else
		{
			if (S_cnt>0)
			{
				STpair_cnt++;
				S_cnt--;
			}
		}
	}
	int ans = n - STpair_cnt * 2;
	co(ans);
	return 0;
}


Measured memory_bytes: 640