akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifdef ONLINE_JUDGE
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int main(){
#ifdef ONLINE_JUDGE
    freopen("meals.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    string s; cin >> s;

    ll res = 0;
    int pv = 0;
    for (int i = 0, p = 0; i < sz(s); i = p) {
        int x, y;
        for (x = i; x < sz(s) and s[x] == '<'; x++);
        for (y = x; y < sz(s) and s[y] == '>'; y++);

        p = y;

        ll c1 = x-i, c2 = y-x;
        res += c1*(c1-1)/2 + c2*(c2-1)/2 + max(c1, c2);
    }

    cout << res << endl;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    VS S(N);
    map<char, ll> count;
    rep(i,N){
        cin >> S[i];
        if(S[i][0]=='M' || S[i][0]=='A' || S[i][0]=='R' || S[i][0]=='C' || S[i][0]=='H'){
            count[S[i][0]]++;
        }
    }
    ll ans=0;
    stl_rep(i,count){
        stl_rep(j,count){
            stl_rep(k, count){
                if((i->F != j->F) && (j->F != k->F) && (i->F != k->F)){
                    ans+=i->S*j->S*k->S;
                }
            }
        }
    }
    cout << ans/6 << endl;
    
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

int main(){
    int a, b, c, d;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    int ans1 = a * b;
    int ans2 = c * d;

    if(ans1 >= ans2) printf("%d\n", ans1);
    else printf("%d\n", ans2);

    return 0;
}


Measured memory_bytes: 1720
#include<stdio.h>
int main(){
	long long n,k,q,a,dif,i,score[1000111];
	scanf("%lld %lld %lld",&n,&k,&q);
	dif=q-k;
	for(i=0;i<q;i++){
		scanf("%lld",&a);
		score[a-1]++;
	}
	for(i=0;i<n;i++){
		if(score[i]>dif){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    ll fib[n+1];
    fib[1] = 1;
    fib[2] = 2;
    REP(i,1,n-1){
        fib[i+2] = fib[i+1] + fib[i];
    }
    cout << fib[n] << endl;
}


Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  int ans = 0;
  for (int i = 105; i <= n; i += 2) {
    int temp = 1;
    FOR(j, 3, i + 1) {
      if (i % j == 0) ++temp;
    }
    if (temp == 8) ++ans;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Program
{

    static void Main()
    {
        var sc = new Scanner();
        string s = Console.ReadLine();
        int a = s.Length;
        if (s[0]==s[a-1])
        {
            if (a%2==0)
            {
                Console.WriteLine("First");
            }
            else
            {
                Console.WriteLine("Second");
            }
        }
    else
        {
            if (a % 2 == 0)
            {
                Console.WriteLine("Second");
            }
            else
            {
                Console.WriteLine("First");
            }
        }
    }
}
static class Extentions
{
    public static IEnumerable<T> Outpuut<T>(this IEnumerable<T> source)
    {
        foreach (var item in source)
        {
            Console.WriteLine(item);
        }
        return source;
    }
    public static T Print<T>(this T obj)
    {
        Console.WriteLine(obj);
        return obj;
    }
}
public class Scanner
{
    public Scanner()
    {
        byte[] inputBuffer = new byte[1024];
        System.IO.Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
        Console.SetIn(new System.IO.StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
    }
    string[] buffer = new string[0];
    int index = 0;
    public char[] SplitChars { get; set; }
    public string String()
    {
        if (index < buffer.Length) return buffer[index++];
        string line = "";
        while (line == "") line = Console.ReadLine();
        if (line == null) return null;
        buffer = line.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries);
        index = 0;
        return buffer[index++];
    }
    public string[] StringArray(int count) { return NextArray(count, x => x); }
    public void Skip(int count) { for (int i = 0; i < count; i++) String(); }
    public T Next<T>(Func<string, T> parser) { return parser(String()); }
    public T[] NextArray<T>(int count, Func<string, T> parser)
    {
        var arr = new T[count];
        for (int i = 0; i < count; i++) arr[i] = Next(parser);
        return arr;
    }
    public int Int() { return Next(int.Parse); }
    public int[] IntArray(int count) { return NextArray(count, int.Parse); }
    public double Double() { return Next(double.Parse); }
    public double[] DoubleArray(int count) { return NextArray(count, double.Parse); }
}


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

#define endl '\n'

long long M = 1e9 + 7;

long long fpow(long long b, long long e){
    if (e == 0) return 1;
    if (e == 1) return b;
    if (e & 1) return b * fpow(b, e-1) % M;
    long long temp = fpow(b, e/2);
    return temp*temp % M;
}

pair<long long, long long> norm(long long a, long long b){
    if (a == 0) return {0, 1};
    if (b == 0) return {1, 0};
    if (b < 0){
        a = -a;
        b = -b;
    }
    long long g = __gcd(abs(a), abs(b));
    return {a/g, b/g};
}

pair<long long, long long> comp(pair<long long, long long> x){
    long long a = x.first, b = x.second;
    if (a == 0) return {1, 0};
    if (b == 0) return {0, 1};
    if (a < 0) return {b, -a};
    return {-b, a};
}

void solve(){
    int n; cin >> n;
    if (n == 1){
        cout << 1 << endl;
        return;
    }
    set<pair<long long, long long>> fracs;
    map<pair<long long, long long>, long long> count;
    long long zeros = 0;
    for (int i=0; i<n; i++){
        long long a,b; cin >> a >> b;
        if (a == 0 && b == 0) zeros++;
        else{
            fracs.insert(norm(a, b));
            count[norm(a,b)]++;
        }
    }
    long long ans = 1;
    for (pair<long long, long long> x : fracs){
        /*
        cout << "x = " << x.first << " " << x.second << endl;
        pair<long long, long long> c = comp(x);
        cout << "comp(x) = " << c.first << " " << c.second << endl;
        cout << "count[x] = " << count[x] << endl << "count[comp(x)] = " << count[comp(x)] << endl;
        */
        if (count[x] == 0 && count[comp(x)] == 0) continue;
        if (count[comp(x)] == 0){
            ans = ans * fpow(2, count[x]) % M;
        } else{
            long long cur = 0;
            cur = ((fpow(2, count[x]) + fpow(2, count[comp(x)]))%M - 1 + M) % M;
            ans = ans * cur % M;
        }
        count[x] = 0; count[comp(x)] = 0;
    }
    cout << ((ans -1 + M)%M + zeros)%M << endl;
}

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

Measured memory_bytes: 40980
#include <stdio.h>

main()
{
	int array[256] ;
	int numcount ;
	int chcount ;

	scanf ( "%d", &array[0] ) ;

	numcount = 0 ;
	while ( 1 )
	{
		if ( array [ numcount ] % 2 )
		{
			array [ numcount + 1 ] = array [ numcount ] * 3 + 1 ;
		}
		else
		{
			array [ numcount + 1 ] = array [ numcount ] / 2 ;
		}
		numcount++ ;

		chcount = 0 ;
		while ( chcount < numcount )
		{
			if ( array [ chcount ] == array [ numcount ] )
			{
				printf ( "%d\n", numcount + 1 ) ;
				//chcount = 0 ;
				//while ( chcount <= numcount )
				//{
					//printf ( "array [ %d ] = %d\n", chcount, array [ chcount ] ) ;
					//chcount++ ;
				//}
				return 0 ;
			}
			chcount++ ;
		}
	}

}


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

const int INF = (1<<21);

class state{
public:
  int n,d;
  state(int n=0, int d=0):n(n),d(d){}
  bool operator < (const state &s) const {return d > s.d;}
};

int main(){
  int n,m;
  while(cin >> n >> m){
    int G[100][100];
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) G[i][j] = INF;
    for(int i=0;i<m;i++){
      int a;
      cin >> a;
      if(a){
	int b,c,d;
	cin >> b >> c >> d;
	b--;
	c--;
	if(G[b][c] > d) G[b][c] = G[c][b] = d;
      }
      else{
	int b,c,d[100];
	bool f[100];
	priority_queue<state> Q;
	for(int j=0;j<n;j++) d[j] = INF, f[j] = false;
	cin >> b >> c;
	b--;
	c--;
	d[b] = 0;
	state u(b,0);
	Q.push(u);
	while(!Q.empty()){
	  u = Q.top();
	  Q.pop();
	  f[u.n] = true;
	  if(u.n == c) break;
	  for(int j=0;j<n;j++){
	    if(!f[j] && d[u.n] + G[u.n][j] < d[j]){
	      state v(j,d[u.n]+G[u.n][j]);
	      d[j] = v.d;
	      Q.push(v);
	    }
	  }
	}
	if(d[c] == INF) d[c] = -1;
	cout << d[c] << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h> 
using namespace std; 
#define M int(1e9+7)
#define ll long long
#define lli long long int
#define I 10e5

int32_t main() 
{ 
   ios_base::sync_with_stdio(false);cin.tie(NULL); 
   
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout); 
   #endif
   int n, k;
   cin>>n>>k;
   vector<int> v(n);
   for(auto &i:v)
   {
      cin>>i;
   }
   int dp[k+1];
   memset(dp, 0, sizeof(dp));
   for(int i=1;i<=k;i++)
   {
      for(int j=0;j<n;j++)
      {
         if(v[j]>i)
            continue;
         if(dp[i-v[j]]==0)
            dp[i] = 1;
      }
   }
   cout<<(dp[k]==0?"Second":"First");
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
}


Measured memory_bytes: 4180
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, T, c[101], t[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> T;
    rep(i, 0, N) cin >> c[i] >> t[i];

    int ans = inf;
    rep(i, 0, N) if (t[i] <= T) chmin(ans, c[i]);
    if (ans == inf) cout << "TLE" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int T = I.nextInt();
		long[] a = new long[N-1];
		long ans = T;
		long curend = T;
		long start = I.nextLong();
		for (int i = 0; i < N-1; i++) {
			long cur = I.nextLong();
			if (cur<=curend) { //Overlap case
				start=cur;
				ans+=start+T-curend;
				curend=start+T; //If end = 4 and current = 1, end --> 4+1 and answer --> 4+1
			}else {
				ans+=T; //Disjoint case
				curend = cur+T;
				start = cur;
			}
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 49600
import sys
import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

n = readInt()
s = sys.stdin.readline().strip()

w = 0
b = 0
for c in s:
    w += int(c == '.')
    b += int(c == '#')


wc = 0
bc = 0
ret = min(w, b)
for c in s:
    wc += int(c == '.')
    bc += int(c == '#')

    ret = min(ret, bc + (w - wc))
print(ret)

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

using namespace std;

int main()
{
	long long a, b;
	std::cin >> a >> b;
	
	if(a == 0 || b == 0 || (a < 0 && b > 0))
	{
		std::cout << "Zero" << std::endl;
	}
	else if(a > 0)
	{
		std::cout << "Positive" << std::endl;
	}
	else
	{
		std::cout << ((((b - a) % 2) == 1) ? "Positive" : "Negative") << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main() {
  int d, n;
  scanf("%d%d", &d, &n);
  int ans = 1;
  if (d == 1) ans = 100;
  if (d == 2) ans = 10000;
  if (n == 100) n = 101;
  printf("%d\n", ans * n);

}

Measured memory_bytes: 128
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(1, h+1):
        if i == 1 or i == h:
            print("#"*w)
        else:
            print("#"+ "."*(w-2)  + "#")  # 位置の調整が面倒だよ...
    print()


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

bl = [int(k) for k in input().split()] 
count = 0

for i in range(n):
    ans = c
    a = [int(k) for k in input().split()] 
    
    for j in range(m):
        ans += a[j] * bl[j]
    if ans > 0:
        count += 1

print(count)
        

Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
c=[0]*60
for aa in a:
  for i in range(60):
    if aa&(1<<i):c[i]+=1
ans=0
for i,cc in enumerate(c):
  ans+=cc*(n-cc)*2**i
  ans%=mod
print(ans)




Measured memory_bytes: 117804
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int a[5],b[5],i,j,k,l,d;
    
    for(i=0;i<5;i++)
    scanf("%d",&a[i]);
    
    scanf("%d",&d);
    
    for(i=1;i<5;i++){
    if(abs(a[0]-a[i])>d)
    b[0]=1;
    else
    b[0]=0;
    }
    
    for(j=2;j<5;j++){
     if(abs(a[1]-a[j])>d)
    b[1]=1;
    else
    b[1]=0;
    }
    
    for(k=3;k<5;k++){
     if(abs(a[2]-a[k])>d)
    b[2]=1;
    else
    b[2]=0;}
    
    for(l=4;l<5;l++){
     if(abs(a[3]-a[l])>d)
    b[3]=1;
    else
    b[3]=0;}
    
    if(b[0]==0&&b[1]==0&&b[2]==0&&b[3]==0)
    printf("Yay!\n");
    else
    printf(":(\n");
    
    return(0);
}

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

#define MAXN 1000000
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define INF 2147483647
#define EPS 1e-9
#define PI 3.141592653589793238462
#define MOD 1000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<PII > VPII;
typedef vector<VPII > VVPII;
typedef map<int,int> MII;

int N, A;

int main()
{
    cin >> N >> A;
    cout << N * N - A;
    return 0;
}


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

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = int(input())
    a_list = input_to_int_tuple()

    all = 0
    for v in a_list:
        all ^= v

    ret = ""
    for v in a_list:
        ret += str(all ^ v) + " "

    print(ret.rstrip())


if __name__ == "__main__":
    main()


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



int main() {
  char c;
  cin >> c;
  if (c == 'a' ||
      c == 'i' ||
      c == 'u' ||
      c == 'e' ||
      c == 'o')
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

vl p(ll k){
    vl c;
    ll t = sqrt(k);
    for(ll i=1; i<=t; i++){
        if(k % i == 0){
            c.push_back(i);
            if((k / i) != i){
                c.push_back(k/i);
            }
        }
    }
    sort(c.rbegin(), c.rend());
    return c;
}

int main(){
    ll n,k; cin >> n >> k;
    vl a(n);
    ll sum=0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    vl b(p(sum));
    sum = 0;
    ll rsum = 0;
    ll cnt = 0;
    vl c(n);

    rep(i,b.size()){
        rep(j,n){
            c[j] = a[j] % b[i];
        }
        sort(all(c));
        sum = 0;
        rsum = 0;
        cnt = 0;
        rep(j,n){
            rsum += b[i] - c[j];
        }
        //cout <<  "#" << rsum << endl;
        
        rep(j,n){
            sum += c[j];
            rsum -= b[i] - c[j];
            cnt += c[j];
            //cout << sum << " " << rsum << cnt << endl;
            if(sum == rsum && cnt <= k){
                cout << b[i] << endl;
                return 0;
            }
            if(cnt > k) break;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int A[100][100];
    int B[100];
    int C[100]={0};
    
    int i,j,n,m;
    
    scanf("%d %d",&n,&m);
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
           scanf("%d",&A[i][j]);
        }
    }
    for(j=0;j<m;j++) scanf("%d",&B[j]);
    
    for(i=0;i<n;i++){
        C[i]=0;
        for(j=0;j<m;j++)C[i]+=A[i][j]*B[j];
    }
    for(i=0;i<n;i++){
        printf("%d\n",C[i]);
    }
    return(0);
}


Measured memory_bytes: 2104
from sys import stdin

input = stdin.readline
mi = lambda: map(int, input().split())
lmi = lambda: list(mi())
si = lambda: input().strip('\n')
ii = lambda: int(input())

n, k = mi()
cnt = 0
arr=lmi()
for i in arr:
    if i >= k:
        cnt+=1
print(cnt)

Measured memory_bytes: 11884
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}


int n,h[100005],ma,ans=0;
int main() {
	cin>>n;
	rep(i,0,n)cin>>h[i];
	ma=0;
	rep(i,1,n){
		if(h[i-1]>=h[i]){
			ma++;
		}else{
			ans=max(ma,ans);
			ma=0;
		}
	}
	ans=max(ma,ans);
	cout<<ans<<endl;
	return 0;
}


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

int main() {
	string s;
	cin >> s;
	cout << s;
	if(s.at(s.size()-1)=='s')
	{
		cout << "es" << endl;
	}
	else
	{
		cout << 's' << endl;
	}
	return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  unordered_set<int64_t> s;

  for (auto _ : irange(0L, 3L)) {
    int64_t x;
    cin >> x;
    s.insert(x);
  }

  cout << (s.size() == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

int c[4];

int main(){
	rep(i, 6){
		int a;
		scanf("%d", &a);
		++c[a - 1];
	}
	int p = 0;
	rep(i, 4){
		p += c[i] == 2;
	}
	printf("%s", p == 2 ? "YES": "NO");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

set<int> calc(set<int> a,set<int> b,string op)
{
	set<int> s;
	for(int x:a) for(int y:b){
		switch(op[0]){
		case '+': s.insert((x+y)%256);     break;
		case '-': s.insert((x-y+256)%256); break;
		case '*': s.insert((x*y)%256);     break;
		case '/': if(y==0) throw "error"; else s.insert(x/y);
		}
	}
	return s;
}

int main()
{
	for(int m;cin>>m && m!=-1;){
		map<string,pii> ntor; // name -> range
		rep(i,m){
			string s; int a,b; cin>>s>>a>>b;
			ntor[s]=mp(a,b);
		}
		int n; cin>>n;
		vs ts(n);
		rep(i,n) cin>>ts[i];
		
		try{
			stack<set<int>> st;
			for(string t:ts){
				if(t=="*" || t=="+" || t=="-" || t=="/"){
					set<int> b=st.top(); st.pop();
					set<int> a=st.top(); st.pop();
					st.push(calc(a,b,t));
				}
				else if(isdigit(t[0])){
					set<int> s; s.insert(atoi(t.c_str()));
					st.push(s);
				}
				else{
					pii r=ntor[t];
					set<int> s;
					repi(i,r.first,r.second+1) s.insert(i);
					st.push(s);
				}
			}
			cout<<"correct"<<endl;
		}
		catch(...){
			cout<<"error"<<endl;
		}
	}
}

Measured memory_bytes: 1376
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')


N = II()
u_li = []
v_li = []
w_li = []
for i in range(N-1):
    u, v, w = LI()
    u_li.append(u)
    v_li.append(v)
    w_li.append(w)

# 連結リストを作成。計算量削減のために、距離の情報も持つ。
max_node = max(max(u_li), max(v_li))
neighbor = [[] for i in range(max_node+1)]
for i in range(N-1):
    neighbor[u_li[i]].append((v_li[i], w_li[i]))
    neighbor[v_li[i]].append((u_li[i], w_li[i]))

# 深さ優先探索をしつつ色を塗っていく。
from collections import deque
def depth_first(neighbor, start):
    visited, stack = [False]*(N+1), deque()
    stack.append(start)
    result = [None, 0] + [None]*(N-1)
    while len(stack) > 0:
        next_node = stack.pop()
        if visited[next_node]: continue
        visited[next_node] = True
        for nei in neighbor[next_node]:
            if result[nei[0]] is not None: continue
            if nei[1]%2 == 0:
                result[nei[0]] = result[next_node]
            else:
                result[nei[0]] = (result[next_node]+1)%2
            stack.append(nei[0])
    return result

colors = depth_first(neighbor, 1)

for ans in colors[1:]:
    print(ans)


Measured memory_bytes: 42240
#include<stdio.h>

int sub(int n);

int main(void){
	int i,n,data[10],p;
	while(scanf("%d",&n)!=EOF){
		for(i=0;i<10;i++)data[i]=0;
		i=9;p=0;
		while(n!=0){
			if(n>=sub(i)){n=n-sub(i);data[p++]=sub(i);}
			i--;
		}
		printf("%d",data[--p]);
		while(p!=0){printf(" %d",data[--p]);}
		printf("\n");
	}
	return 0;
}

int sub(int n){
	int i,s=1;
	for(i=0;i<n;i++)s=s*2;
	return s;
}

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

int arr[3];
int main(){
string s,s1;
cin>>s>>s1;
int n,m;
cin>>n>>m;
string str;
cin>>str;
if(s==str) cout<<n-1 <<" " <<m;
else cout<<n <<" " <<m-1;




return 0;

}





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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  string S;cin>>S;
  // まずは全体のEの数を取得する
  int ecnt = count(ALL(S),'E');
  // idxがiを見た時、その左のWの数と右のEの数
  vector<P> dp(N);
  if (S[0] == 'E') dp[0] = {0,ecnt-1};
  else dp[0] = {0,ecnt};
  FOR(i,1,N) {
    char prevch = S[i-1];
    char curch = S[i];
    if (prevch=='W' && curch=='E') dp[i] = {dp[i-1].first+1,dp[i-1].second-1};
    else if (prevch=='W') dp[i] = {dp[i-1].first+1,dp[i-1].second};
    else if (curch=='E') dp[i] = {dp[i-1].first,dp[i-1].second-1};
    else dp[i] = dp[i-1];
  }
  ll ans = LLONG_MAX;
  REP(i,N) ans = min(ans, dp[i].first+dp[i].second);
  OUT(ans);

  return 0;
}

Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll n,k,x,y; cin>>n>>k>>x>>y;
	if(n<=k){ cout<<n*x; return 0; }
	cout<<k*x + (n-k)*y;
	
	
	return 0;
}


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

{
long long a,b,c,d,e,f,g,h,i,j,k,l=0,m,n;

cin>>a>>b>>c>>k;

if(a>=b)
{
    for(i=0;;i++)
    {
        b=b*2;
        l++;
        if(b>a) break;
    }
}
if(b>=c)
{
    for(i=0;;i++)
    {
        c=c*2;
        l++;
        if(c>b) break;
    }
}
if(l>k) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}

















Measured memory_bytes: 3624
#include <iostream>

using namespace std;

constexpr double EPS = 0.0000000001;

int main()
{
    double xA, yA, xB, yB, xC, yC, xD, yD;

    while(cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD) {
        double dot = (yA-yB) * (yC-yD) + (xC-xD) * (xA-xB);
        if (-EPS <  dot && dot < EPS) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}

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

class union_find{
    vector<int> dat;
    int find(int a) {
        return dat[a] < 0 ? a : dat[a] = find(dat[a]);
    }
public:
    union_find(int n) : dat(n, -1) {}
    int size(int a){
        return -dat[find(a)];
    }
    bool unite(int a, int b){
        a = find(a);
        b = find(b);
        if(a == b) return false;
        if(dat[a] < dat[b]){
            dat[a] += dat[b];
            dat[b] = a;
        }
        else{
            dat[b] += dat[a];
            dat[a] = b;
        }
        return true;
    }
};

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i = 0;i < M;i++){
        cin >> a[i] >> b[i]; --a[i], --b[i];
    }
    union_find uf(N);
    vector<ll> res(M);
    ll cnt = 1LL * N * (N - 1) / 2;
    for(int i = M - 1;i >= 0;i--){
        res[i] = cnt;
        ll sa = uf.size(a[i]);
        ll sb = uf.size(b[i]);
        if(uf.unite(a[i], b[i])){
            cnt += 1LL * sb * (sb - 1) / 2;
            cnt += 1LL * sa * (sa - 1) / 2;
            ll sc = sa + sb;
            cnt -= 1LL * sc * (sc - 1) / 2;
        }
    }
    for(int i = 0;i < M;i++){
        printf("%lld\n", res[i]);
    }
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)


const int N = 10;
string a[N];
int32_t main(){ fast;
	
	int n, m, k; cin>>n>>m>>k;
	rep(i, n) cin>>a[i];
	
	int ans = 1e9 + 7;
	rep(mask, 1 << ( n - 1)){
		int cnt = __builtin_popcount(mask);
		int tot = cnt;
		vector<int> cur(cnt + 1, 0);
		rep(j, m){
			int p = 0;
			rep(i, n){
				cur[p] += (a[i][j] == '1');
				if((mask >> i) & 1)
					p++;
			}
			bool bad = false;
			rep(i, sz(cur))
				if(cur[i] > k)
					bad = true;
					
			if(bad){
				tot++;
				fill(all(cur), 0);
				p = 0;
				rep(i, n){
					cur[p] += (a[i][j] == '1');
					if((mask >> i) & 1)
						p++;
				}
				bad = false;
				rep(i, sz(cur))
					if(cur[i] > k)
						bad = true;
				if(bad)
					tot = 1e9 + 7;
			}
		}
		ans = min(ans, tot);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   long long  h, w;
   cin >> h >> w;
   if(h==1||w==1) {
       cout << 1 << endl;
   } else {
   if(h*w%2==0)
   cout << h*w/2 << endl;
   else cout << h*w/2+1 << endl;
   }
}

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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'


int main()
{
	#ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int h , a ; 
	cin >> h >> a ; 
	cout << ceil(h/(float)a) ;


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int n;
long long int a[100005];
long long int b[100005];
long long int c[100005];
long long int dp[100005][5];

long long int calc(int i, int pastActivity)
{
	if(i<0)
		return 0;
	if(dp[i][pastActivity] != -1)
		return dp[i][pastActivity];
	if(pastActivity == 0)
		dp[i][pastActivity] = (long long int)fmax(calc(i-1,1) + b[i], calc(i-1,2) + c[i]);
	else if(pastActivity == 1)
		dp[i][pastActivity] = (long long int)fmax(calc(i-1,0) + a[i], calc(i-1,2) + c[i]);
	else
		dp[i][pastActivity] = (long long int)fmax(calc(i-1,0) + a[i], calc(i-1,1) + b[i]);
	return dp[i][pastActivity];
}

int main() 
{
	for(int i=0;i<100005;i++)
	{
		for(int j=0;j<5;j++)
		{
			dp[i][j] = -1;
		}
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);
	}
	long long int ans_starting0 = calc(n-2,0) + a[n-1];
	long long int ans_starting1 = calc(n-2,1) + b[n-1];
	long long int ans_starting2 = calc(n-2,2) + c[n-1];
	long long int ans = ans_starting0>ans_starting1?(ans_starting0>ans_starting2?ans_starting0:ans_starting2):(ans_starting1>ans_starting2?ans_starting1:ans_starting2);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 11136
a, b, c, k = map(int, input().split())

total=0
total+=a

if k - a == 0:
  print(total)
elif k - a < 0:
  print(k)
else:
  k-=a
  if k - b <= 0:
    print(total)
  else:
    k-=b
    print(total-k)

Measured memory_bytes: 61792
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

ll dp[2][110][50];  /* dp[id][i+1][j] : 先頭からi桁目までで0でない数がj個現れるs以下の数の個数。
                                       ただし、id = 0 のとき現時点でsと等しい。
                                       id = 1 のとき現時点でsより小さいことが確定。 */
int main() {
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    
    dp[0][0][0] = 1;
    rep(id, 2) {
        rep(i, n) {
            rep(j, 4) {
                ll lim = s[i] - '0';  //  先頭からi桁目にはlim以下の数を置ける
                if(id) {
                    lim = 9;
                }
                rep(x,lim+1) {  // 先頭からi桁目にxを置くとする
                    dp[id || x < lim][i+1][j + (x != 0)] += dp[id][i][j];
                }
            }
        }
    }
    
    ll ans = 0;
    rep(id, 2) {  
        ans += dp[id][n][k];
    }
    
    p(ans);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int n, m;
    char cal;
    while(1){
        cin >> n >> cal >> m;     
        if(cal == '?')
            break;
        if(cal == '+')
            cout << n+m << endl;
        if(cal == '-')
            cout << n-m << endl;
        if(cal == '*')
            cout << n*m << endl;
        if(cal == '/')
            cout << n/m << endl;
    }    
    return 0;
}

Measured memory_bytes: 3080
N,K = map(int,input().split())
n = int(N/K) #nはKの倍数の個数
m = int(2*N/K) #mはK/2の倍数の個数
if K % 2 == 1:
  print(n**3)
else:
  print(n**3+(m-n)**3)

Measured memory_bytes: 2940
$n = gets.to_i
INF = 1 << 30
$m = Array.new($n){ Array.new }
$n.times do
  l = gets.split.map(&:to_i)
  (1..l[1]).each{ |i| $m[l[0]] << l[2*i,2] }
end
$n.times{ |i| $m[i].sort! }

def dijkstra(x)
  cost = Array.new($n, INF)
  cost[x] = 0
  used = Array.new($n)
  while true
    m = INF
    $n.times{ |i| m = cost[i] if !used[i] && m > cost[i] }
    break if m == INF 
    $n.times do |i|
      if m == cost[i]
        used[i] = true
        $m[i].each do |r|
          u, w = r
          cost[u] = cost[i] + w if cost[u] > cost[i] + w 
        end
      end
    end
  end
  cost
end
ret = dijkstra(0)
ret.each_index{ |i| puts "#{i} #{ret[i]}" }

Measured memory_bytes: 45300
a_list = [input().split(" "),input().split(" "),input().split(" ")]
N = int(input())
for i in range(N):
    b = input()
    for j in range(3):
        for k in range(3):
            if a_list[j][k] == b:
                a_list[j][k] = ""
bingo = False
if a_list[0][0] =="" and  a_list[1][1] =="" and  a_list[2][2] == "":
    bingo = True
if a_list[0][2] =="" and  a_list[1][1] =="" and  a_list[2][0] == "":
    bingo = True
for i in range(3):
    if a_list[i][0] == "" and a_list[i][1] == "" and a_list[i][2] == "":
        bingo = True
    elif a_list[0][i] == "" and a_list[1][i] == "" and a_list[2][i] == "":
        bingo = True
if bingo:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import itertools

n = int(input())
triangle = [0,0]
now = 0
num = 1
while now < n:
  now += num
  triangle.append(now)
  num += 1
if n in triangle:
  print("Yes")
  K = triangle.index(n)
  print(K)
  ans = [list() for i in range(K)]
  for k,v in enumerate(itertools.combinations(range(K),2),1):
    for i in v:
      ans[i].append(k)
  for i in ans:
    print(K-1,*i)
else:
  print("No")

Measured memory_bytes: 47452
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1e6 + 1000;
int n,tot,cnt,ans; char s[N];
int vis[N],val[N],du[N],f[N];
int eu[N],ev[N],head[N];
struct node{int nex,to;} e[N << 1];
void add(int f,int t){e[++ tot].nex = head[f]; e[tot].to = t; head[f] = tot;}
queue<int> q;
void dfs(int now,int fa)
{
	f[now] = val[now];
	for(int i = head[now],to;i;i = e[i].nex)
	{
		to = e[i].to; if(to == fa) continue;
		dfs(to,now); ans = max(ans,f[to] + f[now]);
		f[now] = max(f[now],f[to] + val[now]);
	}
}

int main()
{
	n = read();
	for(int i = 1;i < n;i ++)
	{
		eu[i] = read(); ev[i] = read();
		add(eu[i],ev[i]); add(ev[i],eu[i]);
		du[eu[i]] ++ ; du[ev[i]] ++;
	}
	scanf("%s",s + 1);
	for(int i = 1;i <= n;i ++) if(s[i] == 'B' && du[i] == 1) q.push(i);
	while(!q.empty())
	{
		int f = q.front(); q.pop(); vis[f] = 1;
		for(int i = head[f],to;i;i = e[i].nex)
		{
			to = e[i].to; if(vis[to]) continue;
			du[to] --; if(du[to] == 1 && s[to] == 'B') q.push(to);
		}
	}
	tot = 0; memset(head,0,sizeof(head)); memset(du,0,sizeof(du));
	for(int i = 1;i < n;i ++) {if(vis[eu[i]] || vis[ev[i]]) continue; add(eu[i],ev[i]); add(ev[i],eu[i]); du[eu[i]] ++; du[ev[i]] ++;}
	for(int i = 1;i <= n;i ++)
	{
		val[i] = 0; if(vis[i]) continue;
		if((s[i] == 'B' && (du[i] & 1)) || (s[i] == 'W' && !(du[i] & 1))) {val[i] = 2; cnt ++;}
	}
	for(int i = 1;i <= n;i ++) if(!vis[i]) {dfs(i,0); break;}
	cout << tot + cnt - ans;
	return 0;
}

Measured memory_bytes: 24448
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof(a))

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        map<int,int>mp;
        mp.clear();
        stack<int>s;
        while(!s.empty())
            s.pop();
        while(m--)
        {
            int num;
            scanf("%d",&num);
            if(!mp[num])
            {
                mp[num]=1;
            }
            s.push(num);
        }
        map<int,int> np;
        np.clear();
        while(!s.empty())
        {
            if(!np[s.top()])
            {
                np[s.top()]=1;
                printf("%d\n",s.top());
                s.pop();
            }
            else
                s.pop();
        }
        for(int i=1;i<=n;i++)
        {
            if(!np[i])
                printf("%d\n",i);
        }
        
    }
}

Measured memory_bytes: 17264
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
      ll h;
      cin>>h;
      ll i=1,s=0;
      while(h>0)
      {
        h/=2;
        s=s+i;
        i=i*2;
        
      } 
      cout<<s<<"\n";      
    }
}



Measured memory_bytes: 3576