akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

long long P = 998244353;

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;

  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }

  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }

  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }

  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }

  long long mul(long long a, long long b) { return (a * b) % P; }

  long long add(long long a, long long b) { return (a + b) % P; }

  // find c
  // where a^c = b (mod P)
  long long dlp(long long a, long long b) {
    long long m = ceil(sqrt(P));
    map<long long, long long> mp;
    for (int i = 0; i < m; i++)
      mp[power(a, i)] = i;
    long long ainvm = power(power(a, m), P - 2);
    cout << m << endl;
    for (int i = 0; i < m; i++) {
      if (mp.find(b) != mp.end()) {
        return i * m + mp[b];
      }
      b = mul(b, ainvm);
    }
    return -1;
  }
};

C cmb(2020202);

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  for (int i = 0; i <= min(m, n); i++) {
    ll rest = 3 * m - i;
    if (rest % 2 == 1) continue;
    rest /= 2;
    ans += (cmb.comb(rest + n - 1, n - 1) * cmb.comb(n, i)) % P;
    ans %= P;
  }
  for (int i = 0; i <= min(m, n); i++) {
    ll rest = m - i;
    if (rest % 2 == 1) continue;
    rest /= 2;
    ans += P - (n * cmb.comb(rest + n - 1, n - 1) % P * cmb.comb(n, i)) % P;
    ans %= P;
  }
  for (int i = 0; i <= min(m, n - 1); i++) {
    ll rest = m - i;
    if (rest % 2 == 1) continue;
    rest /= 2;
    ans += (n * cmb.comb(rest + n - 2, n - 2) % P * cmb.comb(n - 1, i)) % P;
    ans %= P;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 47616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
  Cin(int, n);
  int ans = 0;
  For(i, n){
    Cin(int, l);
    Cin(int, r);
    ans += r-l+1;
  }
  Cout(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
	int n;
	scanf("%d\n",&n);
	while(n--){
		string s;
		getline(cin,s);
		while(s.find("Hoshino")!=-1) s.replace(s.find("Hoshino"),7,"Hoshina");
		cout<<s<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
from bisect import bisect
import sys
input = sys.stdin.readline

A, B, Q = map(int, input().split())
INF = float('inf')
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
for _ in range(Q):
    x = int(input())
    i = bisect(s, x)
    j = bisect(t, x)
    ans = INF
    for a in [s[i-1], s[i]]:
        for b in [t[j-1], t[j]]:
            ans = min(ans, abs(a-x)+abs(b-a), abs(b-x)+abs(a-b))
    print(ans)


Measured memory_bytes: 79708
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    AB = list(list(map(int, readline().split())) for _ in range(N))
    ans = max(AB)[0] + max(AB)[1]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27184
//解説AC
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
long long gcd(long long y, long long x){
    return x ? gcd(x,y%x) : y;
}

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> y(n+1);
    rep(i, n){
        cin >> y.at(i);
    }
    y.at(n) = x;
    sort(y.begin(), y.end());
    
    int tmp = y.at(1)-y.at(0);
    rep(i, n){
        if(gcd(y.at(i+1)-y.at(i), tmp))
        tmp = gcd(y.at(i+1)-y.at(i), tmp);
    }
    
    cout << tmp << endl;
    return 0;
}


Measured memory_bytes: 640
from collections import Counter 
n=int(input())
a=[int(i) for i in input().split()]
c=Counter(a)
d=[]
for i in c:
  d.append(2-c[i]%2)
dc=Counter(d)

ans=0
for i in dc:
  if i==1:
    ans+=dc[i]
  elif i==2:
    if dc[i]%2==0:
      ans+=dc[i]
    else:
      ans+=dc[i]-1
print(ans)

Measured memory_bytes: 18656
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <forward_list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion

int gcd(int a, int b){
    while(b > 0){
        int t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int32_t main() {
    make(int, n);
    int lcm = 360 * n / gcd(360, n);
    cout << lcm / n;

    return 0;
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main() { _
	int n; cin >> n;
	ll k; cin >> k;
	vector<ii> v;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		v.pb({a, b});
	}
	sort(v.begin(), v.end());
	vector<ll> pref(n);
	pref[0] = v[0].s;
	for (int i = 1; i < n; i++) pref[i] = pref[i-1]+v[i].s;
	int l = 0, r = n-1;
	while (l < r) {
		int m = (l+r)/2;
		if (pref[m] >= k) r = m;
		else l = m+1;
	}
	cout << v[l].f << endl;
	exit(0);
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<double,double>P;

const int MAX_N = 100005;

vector<P> a;
int n;

double dir(P p1,P p2)
{
    return (p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second);
}

vector<P> circle_center(P p1,P p2)
{
    vector<P> cs;
    P mid = P((p1.first + p2.first) / 2.0,(p1.second + p2.second) / 2.0);
    P vec = P(p1.first - p2.first,p1.second - p2.second);
    double len = dir(vec,P(0.0,0.0));
    double real_len = sqrt(len);
    double len2 = sqrt(1.0 - len / 4.0);
    cs.push_back(P(-vec.second * len2 / real_len + mid.first,vec.first * len2 / real_len + mid.second));
    cs.push_back(P(vec.second * len2 / real_len + mid.first,-vec.first * len2 / real_len + mid.second));
    return cs;
}

int main()
{
    while(1){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        a.clear();
        rep(i,n){
            double x,y;
            scanf("%lf%lf",&x,&y);
            a.push_back(P(x,y));
        }
        int res = -1;
        rep(i,n){
            for(int j = i+1; j < n; j++){
                if(dir(a[i],a[j]) < 4.0){
                    int cnt = 0;
                    vector<P> cs = circle_center(a[i],a[j]);
                    rep(k,n){
                        if(k != i && k != j && dir(a[k],cs[0]) <= 1.0){
                            cnt++;
                        }
                    }
                    res = max(res,cnt);
                    cnt = 0;
                    rep(k,n){
                        if(k != i && k != j && dir(a[k],cs[1]) <= 1.0){
                            cnt++;
                        }
                    }
                    res = max(res,cnt);
                }
            }
        }
        printf("%d\n",res+2);
    }
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);
vector<ll>b;
ll cnt(ll a){
  ll sum=0;
  for(auto x:b){
    if((a&x)==a)sum++;
  }
  return sum;
}
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<ll>s(n+1);
  s[0]=0;
  rep(i,n){
    s[i+1]=s[i]+a[i];
  }
  rep(i,n){
    for(ll j=i;j>=0;j--){
      b.push_back(s[i+1]-s[j]);
    }
  }
  ll ans=0;
  for(int i=40;i>=0;i--){
    if(cnt(ans|(1ll<<i))>=k){
      ans|=(1ll<<i);
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 6388
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

use std::cmp::max;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut gcd_l = vec![0; n];
    let mut gcd_r = vec![0; n];
    gcd_l[0] = a[0];
    for i in 1..n {
        gcd_l[i] = gcd(a[i], gcd_l[i-1]);
    }

    gcd_r[n-1] = a[n-1];
    for i in (0..n - 1).rev() {
        gcd_r[i] = gcd(a[i], gcd_r[i+1]);
    }

    //let mut ans = Vec::new();
    let mut ans = std::i64::MIN;
    for i in 0..n {
        if i == 0 {
            //ans.push(gcd_r[1]);
            ans = max(ans, gcd_r[1]);
        } else if i == n - 1 {
            //ans.push(gcd_l[n-2]);
            ans = max(ans, gcd_l[n-2]);
        } else {
            //ans.push(gcd(gcd_l[i-1], gcd_r[i+1]));
            ans = max(ans, gcd(gcd_l[i-1], gcd_r[i+1]));
        }
    }
    //println!("{}", ans.into_iter().max().unwrap());
    println!("{}", ans);
}

Measured memory_bytes: 8444
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define mod 1000000007
using namespace std;
const int N=1234567;
int A[N];

int main()
{
ios_base::sync_with_stdio(false);


int n;
cin>>n;

vi odd,even;

for(int i=1;i<=n;i++)
{
    cin>>A[i];
    if(i%2 ==0)
        even.pb(A[i]);
    else
        odd.pb(A[i]);

}


if(n%2 ==0)
{
    reverse(even.begin(),even.end());
    for(int i=0;i<even.size();i++)
        cout<<even[i]<<" ";
    for(int i=0;i<odd.size();i++)
        cout<<odd[i]<<" ";
}
else
{
        reverse(odd.begin(),odd.end());
    for(int i=0;i<odd.size();i++)
        cout<<odd[i]<<" ";
    for(int i=0;i<even.size();i++)
        cout<<even[i]<<" ";
}

return 0;
}


Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            var S = Input.Line();
            int count = 0;

            for (int i = 0; i < S.Length; i++) {
                if(S[i] == ')' && count <= 0) {
                    S = "(" + S;
                    i++;
                } else if(S[i] == ')') {
                    count--;
                } else if(S[i] == '(') {
                    count++;
                }
            }

            Console.WriteLine(S + string.Join("", Enumerable.Repeat(')', count)));
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();

		String result = "";
		if(N == M){
			result = "Yes";
		}else{
			result = "No";
		}

		System.out.println(result);
	}

}


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

using namespace std;

string s,ss;
vector<int>pos,poss;

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

    int diff;
    while (cin>>s)
    {
        if (s[0]=='.') break;

        cin>>ss;
        int Ls=s.size(),Lss=ss.size();

        diff=0;
        if (s==ss) cout<<"IDENTICAL"<<endl;
        else
        {
            int i=0,j=0;
            while (s[i]==ss[j] && i<Ls && j<Lss)
            {
                if (s[i]=='"')
                {
                    i++;j++;
                    while (s[i]==ss[j] && s[i]!='"' && ss[j]!='"') {i++;j++;}
                    if (s[i]!='"' && ss[j]!='"')
                    {
                        diff++;
                    }
                    while (s[i]!='"') i++;
                    while (ss[j]!='"') j++;
                }
                if (diff>=2) break;
                i++;j++;
            }
            if (i!=Ls || j!=Lss) diff+=2;
            if (diff>=2) cout<<"DIFFERENT"<<endl;
            else cout<<"CLOSE"<<endl;
        }

    }

    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
int max(int a, int b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );

     int n;
     cin>>n;

     ll res = 0;
     map <ll, ll> m;
     for (int i=0;i<n;i++){
          int a;
          cin>>a;
          res+=m[i-a];
          m[i+a]++;
     }

     cout<<res<<endl;
}

Measured memory_bytes: 26220
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    string str;
    vector<int> mo(26);

    while (cin >> str) {
        int si = str.size();
        for (int i = 0; i < si; ++i) {
            if (str[i] >= 'a' && str[i] <= 'z') { ++mo.at(str[i] - '0' - 49); }
            if (str[i] >= 'A' && str[i] <= 'Z') { ++mo.at(str[i] - '0' - 17); }
        }
    }

        for (int j = 0; j < 26; ++j) {
            if (j == 0) cout << 'a' << " " << ":" << " " << mo[j] << endl;
            if (j == 1) cout << 'b' << " " << ":" << " " << mo[j] << endl;
            if (j == 2) cout << 'c' << " " << ":" << " " << mo[j] << endl;
            if (j == 3) cout << 'd' << " " << ":" << " " << mo[j] << endl;
            if (j == 4) cout << 'e' << " " << ":" << " " << mo[j] << endl;
            if (j == 5) cout << 'f' << " " << ":" << " " << mo[j] << endl;
            if (j == 6) cout << 'g' << " " << ":" << " " << mo[j] << endl;
            if (j == 7) cout << 'h' << " " << ":" << " " << mo[j] << endl;
            if (j == 8) cout << 'i' << " " << ":" << " " << mo[j] << endl;
            if (j == 9) cout << 'j' << " " << ":" << " " << mo[j] << endl;
            if (j == 10) cout << 'k' << " " << ":" << " " << mo[j] << endl;
            if (j == 11) cout << 'l' << " " << ":" << " " << mo[j] << endl;
            if (j == 12) cout << 'm' << " " << ":" << " " << mo[j] << endl;
            if (j == 13) cout << 'n' << " " << ":" << " " << mo[j] << endl;
            if (j == 14) cout << 'o' << " " << ":" << " " << mo[j] << endl;
            if (j == 15) cout << 'p' << " " << ":" << " " << mo[j] << endl;
            if (j == 16) cout << 'q' << " " << ":" << " " << mo[j] << endl;
            if (j == 17) cout << 'r' << " " << ":" << " " << mo[j] << endl;
            if (j == 18) cout << 's' << " " << ":" << " " << mo[j] << endl;
            if (j == 19) cout << 't' << " " << ":" << " " << mo[j] << endl;
            if (j == 20) cout << 'u' << " " << ":" << " " << mo[j] << endl;
            if (j == 21) cout << 'v' << " " << ":" << " " << mo[j] << endl;
            if (j == 22) cout << 'w' << " " << ":" << " " << mo[j] << endl;
            if (j == 23) cout << 'x' << " " << ":" << " " << mo[j] << endl;
            if (j == 24) cout << 'y' << " " << ":" << " " << mo[j] << endl;
            if (j == 25) cout << 'z' << " " << ":" << " " << mo[j] << endl;
        }
}


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

int main() {
    int n, a, b, c, ans = INT_MAX;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    rep(i, n) cin >> l.at(i);
    rep(i, pow(4, n)) {
        int temp = i, power = 0, ta = 0, tb = 0, tc = 0;
        rep(j, n) {
            if(temp % 4 == 0) {
                ta += l.at(j);
                power += 10;
            }
            if(temp % 4 == 1) {
                tb += l.at(j);
                power += 10;
            }
            if(temp % 4 == 2) {
                tc += l.at(j);
                power += 10;
            }
            temp /= 4;
        }
        if(ta == 0 || tb == 0 || tc == 0) continue;
        ans = min(ans, power - 30 + abs(a - ta) + abs(b - tb) + abs(c -tc));
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

string s;

signed main() {
	cin >> s;
	if (s[0] == '9' || s[1] == '9') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){
	
	int A;
	int B;
	int C;
	int D;

	scanf("%d %d %d",&A,&B,&C);
	
	D = abs(A - B) + abs(C - A);
	if (D > abs(B - A) + abs(C - B))
		D = abs(B - A) + abs(C - B);
	if (D > abs(A - C) + abs(B - A))
		D = abs(A - C) + abs(B - A);
	if (D > abs(B - C) + abs(A - B))
		D = abs(B - C) + abs(A - B);
	if (D > abs(C - A) + abs(B - C))
		D = abs(C - A) + abs(B - C);
	if (D > abs(C - B) + abs(A - C))
	D = abs(C - B) + abs(A - C);
	
	printf("%d", D);

	return 0;
}

Measured memory_bytes: 128
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

setrecursionlimit(10**6)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

(n, m, d) = reads()

if d == 0:
  ans = (m - 1) / n
else:
  ans = 2 * (n - d) * (m - 1) / n ** 2

print("{0:.15f}".format(ans))

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

int main() {
    int n;
    cin >> n;
    ll cnt[256] {};
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        cnt[s[0]]++;
    }
    string ma = "MARCH";
    ll ans = 0;
    for (int i = 0; i < 3; i++)
        for (int j = i+1; j < 4; j++)
            for (int k = j+1; k < 5; k++)
                ans += cnt[ma[i]] * cnt[ma[j]] * cnt[ma[k]];
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
linp = list(map(int, input().split()))

a, b = linp

if a == 0 or b == 0:
    print("Zero")
elif a < 0 and b > 0:
    print("Zero")
elif a < 0 and b < 0:
    if (b-a) % 2 == 0:
        print("Negative")
    else:
        print("Positive")
else:
    print("Positive")


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

int main() {
    int K, T;
    cin >> K;
    ll ans = 0;

    for(int i = 1; i < K + 1; i++) {
        for(int j = 1; j < K + 1; j++) {
            for(int l = 1; l < K + 1; l++) {
                T = gcd(i, j);
                ans += gcd(T, l);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int T,n;
struct basis
{
    ll bas[62];
    void clear()
    {
        memset(bas,0,sizeof(bas));
    }
    void ins(ll x)
    {
        for(int j=60;j>=0;j--)
        {
            if(x&(1ll<<j))
            {
                if(!bas[j])
                {
                    bas[j]=x;
                    break;
                }
                x^=bas[j];
            }
        }
    }
    bool check(ll x)
    {
        for(int j=60;j>=0;j--)
        {
            if(x&(1ll<<j))
            {
                if(!bas[j]) return true;
                x^=bas[j];
            }
        }
        return false;
    }
}b;
ll a[MAXN];
string str;
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
        cin>>str;
        bool f=true;
        b.clear();
        for(int i=n;i>=1;i--)
        {
            if(str[i-1]=='1')
            {
                if(b.check(a[i])) f=false;
            }
            else b.ins(a[i]);
        }
        if(!f) puts("1"); else puts("0");
    }
    return 0;
}

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

using namespace std;

#define int int64_t

const int maxn = 1e5 + 42;

vector<int> g[maxn];

void make_edge(int u, int v) {
    g[u].push_back(v);
    g[v].push_back(u);
}

int cnt[maxn];

void dfs(int v, int p) {
    for(auto u: g[v]) {
        if(u != p) {
            if(g[u].size() == 2) {
                dfs(u, v);
            } else if(g[u].size() > 2) {
                cnt[u]++;
            }
        }
    }
}


signed main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n - 1], b[n - 1];
    for(int i = 0; i < n - 1; i++) {
        cin >> a[i] >> b[i];
        make_edge(a[i], b[i]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(g[i].size() == 1) {
            ans++;
            dfs(i, i);
        }
    }
    bool sub = 0;
    for(int i = 0; i < n; i++) {
        if(cnt[i] > 0) {
            sub = 1;
            ans--;
        }
    }
    if(!sub) {
        ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12032
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int INF = 100000000;
		int N = sc.nextInt();
		int[][][] dp = new int[2][2][N + 1];
		for (int i = 0; i <= N; ++i) {
			dp[0][0][i] = dp[0][1][i] = dp[1][0][i] = dp[1][1][i] = INF;
		}
		dp[0][0][1] = 0;
		int t = 1;
		for (int i = 0; i < N - 1; ++i) {
			int C = sc.nextInt();
			for (int j = 0; j <= N; ++j) {
				dp[t][0][j] = dp[t][1][j] = INF;
			}
			for (int j = 0; j <= 1; ++j) {
				for (int k = 0; k <= Math.min(i + 1, N / 2); ++k) {
					if (dp[1 - t][j][k] == INF) continue;
					dp[t][j][k + 1] = Math.min(dp[t][j][k + 1], dp[1 - t][j][k]);
					dp[t][1 - j][i + 2 - k] = Math.min(dp[t][1 - j][i + 2 - k], dp[1 - t][j][k] + C);
				}
			}
			t = 1 - t;
		}
		System.out.println(Math.min(dp[1 - t][0][N / 2], dp[1 - t][1][N / 2]));
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef double flt;
const int MAXN = 100000 + 10;
const flt eps = 1e-7;

int vw[MAXN], pf[MAXN], vf[MAXN], th[MAXN];
int N, pw;

flt calc(flt W) {
  flt cost = W * pw;
  for (int i = 0; i < N; ++ i) {
    flt need = th[i] - W * vw[i];
    if (need <= 0) continue;
    flt f = need / vf[i];
    cost += f * pf[i];
  }
  return cost;
}

int main() {
  while (scanf("%d", &N) == 1 && N) {
    scanf("%d", &pw);
    for (int i = 0; i < N; ++ i) {
      scanf("%d%d%d%d", vw + i, pf + i, vf + i, th + i);
    }
    flt left = 0, right = INT_MAX;
    for (int _ = 0; _ < 200; ++ _) {
      flt m1 = (left + left + right) / 3.0;
      flt m2 = (left + right + right) / 3.0;
      flt c1 = calc(m1), c2 = calc(m2);
      if (c1 < c2) right = m2;
      else left = m1;
    }
    printf("%.10f\n", calc(left));
  }
  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s1, s2; cin >> s1 >> s2;
  reverse(s2.begin(), s2.end());
  cout << (s1 == s2 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

ll s;

ll G = 1e9;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> s;
	ll k = (s + G - 1) / G;
	cout << 0 << " " << 0 << " " << k << " " << k * G - s << " " << 1 << " " << G << "\n";
	return 0;
}




Measured memory_bytes: 764
n, k = [int(i) for i in input().split()]

ka = 0

for i in range(1, n+1):
    
    if(i >= k):
        # print(i, k, (n+1-i))
        
        ka += 1 * (n+1-i)
        break
    
    else:
        j = 1
        while(1):
            if (i * (2 ** j)) >= k:
                break
        
            j += 1
    
        ka += 1 * ((1/2)**j)
        
        # print(n, k, i, j, ka)
    
    # rint(n, k, i, j, ka)
    
print(ka/n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


//—————————————————BFSグラフ————————————————

using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int n;
    cin >> n;

    if(n==1){
      cout << "First" << endl;
      return 0;
    }

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(n);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1);
        G[b-1].pb(a-1);
    }

    // BFS のためのデータ構造
    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    deque<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.pb(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop_front();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.pb(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    int cho=0;
    int memo;
    rep(i,n){
      if(cho<dist[i]) memo=i;
      cho=max(cho,dist[i]);
    }

    rep(i,n){
      dist[i]=-1;
    }

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[memo] = 0;
    que.pb(memo); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop_front();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.pb(nv);
        }
    }

  cho=0;
  rep(i,n){
    cho=max(cho,dist[i]);
  }

cout << (cho%3==1?"Second":"First") << endl;

}


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

int main() {
    int H, W; cin >> H >> W;
    vector<vector<bool> > grid(H, vector<bool>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c; cin >> c;
            grid[i][j] = (c == '.');
        }
    }
    vector<vector<int> > yoko(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        int k = 0;
        for (int j = 0; j < W; j++) {
            if (grid[i][j]) {
                yoko[i][j] = ++k;
            } else {
                yoko[i][j] = 0;
                k = 0;
            }
        }
        k = 0;
        for (int j = W-1; 0 <= j; j--) {
            if (grid[i][j]) {
                k = max(k, yoko[i][j]);
                yoko[i][j] = k;
            } else {
                k = 0;
                yoko[i][j] = k;
            }
        }
    }
    vector<vector<int> > tate(H, vector<int>(W));
    for (int j = 0; j < W; j++) {
        int k = 0;
        for (int i = 0; i < H; i++) {
            if (grid[i][j]) {
                tate[i][j] = ++k;
            } else {
                tate[i][j] = 0;
                k = 0;
            }
        }
        k = 0;
        for (int i = H-1; 0 <= i; i--) {
            if (grid[i][j]) {
                k = max(k, tate[i][j]);
                tate[i][j] = k;
            } else {
                k = 0;
                tate[i][j] = k;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, tate[i][j] + yoko[i][j]);
        }
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 32256
#include <iostream>

using namespace std;

string s;
int n;
string v;
int c;

int main() {
    cin >> s;
    n = s.size();
    for (int i = 0; i < n; i++) {
        c++;
        if (v.size() == 1 && v[0] == s[i]) {
            if (i == n-1) {c--; break;}
            i++;
            v = s.substr(i,2);
        } else {
            v = s.substr(i,1);
        }
    }
    cout << c << "\n";
}

Measured memory_bytes: 1152
n = int(input())
ans = 0
l_list = [int(i) for i in input().split()]
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l_list[i] + l_list[j] > l_list[k] > abs(l_list[i] - l_list[j]):
                if (l_list[i] != l_list[j]) & (l_list[j] != l_list[k]) & (l_list[k] != l_list[i]):
                    ans += 1
print(ans)            

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

int main(){   
   int y,x,ans=0;
   char a;
   cin >> y >> x;
  
       for(int l=0;l<x*y;l++){
           cin >> a;
           if(a=='#'){
               ans++;
           }
       }
   
   if(ans==x+y-1){
       cout << "Possible" << endl;
   }else{
       cout << "Impossible" <<endl;
   }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const int N = 2e5+5;
int s[N];
void initset(int n){
    rep(i,1,n){
        s[i] = i;
    }
}
int getfa(int x){
    if(s[x]==x){
        return x;
    }else{
        return s[x] = getfa(s[x]);
    }
}
void merge(int x,int y){
    int fx = getfa(x),fy = getfa(y);
    if(fx!=fy){
        s[fx] = fy;
    }
}
int num[N];
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    initset(n);
    rep(i,1,m){
        int a,b;cin>>a>>b;
        merge(a,b);
    }
    int cnt= 0,ans = 0;
    rep(i,1,n){
        num[getfa(i)]++;
        //cout<<"id:"<<i<<"s[i]:"<<s[i]<<"num:"<<num[s[i]]<<endl;;
        ans = max(ans,num[getfa(i)]);
    }

    cout<<ans;
}


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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N, M, rest;
    map<int, int> m;
    long long ans;

    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        int A, B;
        cin >> A >> B;
        if(m.count(A) > 0) {
            m[A] += B;
        } else {
            m[A] = B;
        }
    }

    rest = M;
    ans = 0;
    for(auto i = m.begin(); i != m.end(); i++) {
        IFD cout << i->first << " " << i->second << endl;
        if(rest > i->second) {
            rest -= i->second;
            ans += (long long)i->first * i->second;
        } else {
            ans += (long long)rest * i->first;
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i > 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define PI 3.14159265358979

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

ll MOD = 1000000007;


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N-1);
    REP(i, N-1) cin >> A[i];
    vector<ll> ans(N);
    REP(i, N-1) {
        ans[A[i]-1] += 1;
    }
    REP(i, N) {
        PRINT(ans[i]);
    }
    return 0;
}


Measured memory_bytes: 6428
from collections import Counter
N = int(input())
As = list(map(int, input().split()))

MOD = 10 ** 9 + 7

factorials = [1]
fact_invs = [1]
for i in range(1, N+2):
    factorials.append((factorials[-1]*i) % MOD)
    fact_invs.append(pow(factorials[-1], MOD-2, MOD))
fact_invs.append(1)

def combi(n, k):
    if n < k:
        return 0
    ret = factorials[n]
    ret *= fact_invs[k]
    ret %= MOD
    ret *= fact_invs[n-k]
    return ret % MOD

ct = Counter(As)
mc = ct.most_common(1)[0][0]

L = R = None
for i, a in enumerate(As):
    if a == mc:
        if L is None:
            L = i
        else:
            R = N - i

for k in range(1, N+2):
    print((combi(N+1, k) - combi(L+R, k-1)) % MOD)


Measured memory_bytes: 30576
#include<iostream>
#include<algorithm>
#include <numeric>

using namespace std;
int main(void){
  long long int n, i=10, sum=0;
  cin >> n;
  long long int a[20];
  fill(a, a+20, 0);
  if(n%2==1) { cout << 0 << endl; return 0; }
  while(true) {
    sum += n/i;
    if(n/i==0) break;
    i*=5;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long int ll;
using namespace std;

int check(int x) {
    int c = 0;
    while (x % 2 == 0) {
        c++;
        x /= 2;
    }
    return c;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int sum = 0;
    REP(i, n) { sum += check(a[i]); }

    cout << sum << endl;

    return 0;
}

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



typedef pair<int,int> P;



//vector<vector<char>> maze;//[N][M+1];
//vector<vector<int>> d;//[N][M];



//int bfs(vector<vector<char>> &maze,vector<vector<int>> &d){
   
   //  return d[gx][gy];
//}

//void solve(){
    
//}

int main(){
    const int INF=-1;
    int sum=0;
    int N,M;
    int sx=1,sy=1;
    int gx,gy;
    
    cin>>N>>M;
    //cin>>sx>>sy;
   // cin>>gx>>gy;
    gx=N,gy=M;
    
    vector<int> dx={1,0,-1,0};
    vector<int> dy={0,1,0,-1};
    
    vector<vector<char>> maze(N,vector<char> (M));
    vector<vector<int>> d(N,vector<int> (M));
    
     for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>maze.at(i).at(j);
            if(maze.at(i).at(j)=='.')sum+=1;
             d.at(i).at(j)=INF;
            // cout<<d.at(i).at(j)<<endl;
        }
    }
    
  
    queue<P> que;
   //cout<<1<<endl;
    que.push(P(sx-1,sy-1));
   // cout<<d.at(sx).at(sy)<<endl;
    d.at(sx-1).at(sy-1)=0;
 
    while(que.size()){
        // cout<<1<<endl;
        //cout<<que.size()<<endl;
        P p=que.front();
        que.pop();
        if(p.first==gx-1&&p.second==gy-1) break;
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx&&nx<N && 0<=ny&&ny<M && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
     }
    //int res=bfs(maze,d);
    if(d[gx-1][gy-1]==-1)cout<<-1<<endl;
    else cout<<sum-d[gx-1][gy-1]-1<<endl;
    
    
}

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

using namespace std;

void solve()
{
    int k, t;
    cin >> k >> t;
    vector<int> dp(k + 1);
    dp[0] = 1;
    while (t--)
    {
        int a;
        cin >> a;
        for (int i = k - a; i >= 0; i--)
        {
            dp[i + a] |= dp[i];
        }
    }
    for (int i = (k + 1) / 2; i <= k; i++)
    {
        if (dp[i])
        {
            cout << max(2 * i - k - 1, 0) << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[m];
        String[] s = new String[m];

        for (int i=0; i<m; i++){
            p[i] = sc.nextInt();
            s[i] = sc.next();
        }

        int ac = 0;
        int wa = 0;

        Set<Integer> set = new TreeSet<>();

        for (int i=0; i<m; i++){
            int tmp = p[i];
            String str = s[i];
            if (str.equals("AC") && !set.contains(tmp)){
                ac++;
                set.add(tmp);
            }
        }

        Set<Integer> set1 = new TreeSet<>();

        for (int i=0; i<m; i++){
            int tmp = p[i];
            String str = s[i];
            if (str.equals("AC")){
                set1.add(tmp);
            }
            if (str.equals("WA") && !set1.contains(tmp)){
                wa++;
            }

        }

        int minus = 0;

        for (int i=0; i<m; i++){
            int tmp = p[i];
            String str = s[i];
            if (str.equals("WA") && !set1.contains(tmp)){
                minus++;
            }
        }

        System.out.print(ac+" ");
        System.out.println(wa-minus);

    }
}


Measured memory_bytes: 69944
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int solve(int u, int v, int n){
    if (n == 1) return min(u, v);
    set<int> st;
    while (u){
        st.insert(u);
        u = (u + n - 2) / n;
    }
    while (1){
        if (st.count(v)) return v;
        v = (v + n - 2) / n;
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    while (q--){
        int u, v;
        cin >> u >> v;
        cout << solve(u, v, n) << endl;
    }


    return 0;
}




Measured memory_bytes: 1280
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

type Node struct {
	Parent int
	Children []int
	Depth int
}

func main() {
	var n int
	fmt.Scan(&n)

	nodes := make([]Node, n)
	for i := 0; i < n; i++ {
		nodes[i].Parent = -1
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		id, _ := strconv.Atoi(sc.Text())
		
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		for j := 0; j < k; j++ {
			sc.Scan()
			c, _ := strconv.Atoi(sc.Text())
			nodes[id].Children = append(nodes[id].Children, c)
			nodes[c].Parent = id
		}
	}

	root := -1
	for i := 0; i < n; i++ {
		if nodes[i].Parent == -1 {
			root = i
			break
		}
	}
	setDepth(nodes, root, 0)

	for i := 0; i < n; i++ {
		no := nodes[i]
		t := "leaf"
		if i == root {
			t = "root"
		} else if len(no.Children) > 0 {
			t = "internal node"
		}
		children := strings.Replace(fmt.Sprintf("%v", no.Children), " ", ", ", -1)
		fmt.Printf("node %d: parent = %d, depth = %d, %s, %s\n", i, no.Parent, no.Depth, t, children)
	}
}

func setDepth(nodes []Node, current int, depth int) {
	nodes[current].Depth = depth
	for i := 0; i < len(nodes[current].Children); i++ {
		setDepth(nodes, nodes[current].Children[i], depth + 1)
	}
}



Measured memory_bytes: 13668