akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int ans = 0;
		for(int i =0 ;i<S.length();i++){
			if(S.charAt(i) != T.charAt(i)){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 32088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> height(N);
  
  int cnt = 0;
  cin >> height.at(0);
  for(int i = 1; i < N; ++i){
    cin >> height.at(i);
    if(height.at(i) < height.at(i-1)) cnt += height.at(i-1) - height.at(i);
  }

  cout << cnt + height.at(N-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    for(;;){
        cin >> x >> y;
        if(cin.eof())   break;
        cout << to_string(x+y).length() << "\n";
    }
}

Measured memory_bytes: 3228
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  A[a-1].append((b,i))
ans=[0]*M
for i in range(N):
  d=sorted(A[i])
  n=len(d)
  for j in range(n):
    a,b=d[j]
    D=str(i+1)
    E=str(j+1)
    r=D.zfill(6)+E.zfill(6)
    ans[b]=r
for i in ans:
  print(i)

Measured memory_bytes: 97868
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   
   string arr1[n];
   rep(n)
        cin>>arr1[i];
   
   ll arr[n][m];
   rep(n)
        repi(j,m)
            if(arr1[i][j] == '#')
                arr[i][j] = 1;
            else arr[i][j] = 0;
   
   ll dp[n][m];
   for(ll i=n-1;i>-1;i--)
   {
       for(ll j=m-1;j>-1;j--)
       {
           if(i == n-1 && j == m-1)
           {
               dp[i][j] = arr[i][j];
               continue;
           }
           dp[i][j] = inf;
           if(i<n-1)
           {
               if(arr[i][j] == arr[i+1][j])
                    dp[i][j] = min(dp[i][j], dp[i+1][j]);
               else if(arr[i][j] == 0 && arr[i+1][j] == 1)
                    dp[i][j] = min(dp[i][j], dp[i+1][j]);
               else if(arr[i][j] == 1 && arr[i+1][j] == 0)   
                    dp[i][j] = min(dp[i][j], dp[i+1][j]+1);
           }
           
           if(j<m-1)
           {
               if(arr[i][j] == arr[i][j+1])
                    dp[i][j] = min(dp[i][j], dp[i][j+1]);
               else if(arr[i][j] == 0 && arr[i][j+1] == 1)
                    dp[i][j] = min(dp[i][j], dp[i][j+1]);
               else if(arr[i][j] == 1 && arr[i][j+1] == 0)   
                    dp[i][j] = min(dp[i][j], dp[i][j+1]+1);
           }
       }
   }
   cout<<dp[0][0];
   
   
   return 0;        
}  
   

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;

int main() {
    // input
    int n; scanf("%d", &n);
    vector<pair<int, int> > a(n); REP (i, n) scanf("%d%d", &a[i].first, &a[i].second);
    vector<pair<int, int> > b(n); REP (i, n) scanf("%d%d", &b[i].first, &b[i].second);

    // solve
    sort(ALL(a));
    sort(ALL(b));
    vector<int> by;
    int result = 0;
    while (not a.empty()) {
        int ax, ay; tie(ax, ay) = a.back();
        a.pop_back();
        while (not b.empty() and ax < b.back().first) {
            by.push_back(b.back().second);
            b.pop_back();
        }
        int j = -1;
        REP (i, by.size()) if (ay < by[i]) {
            if (j == -1 or by[i] < by[j]) {
                j = i;
            }
        }
        if (j != -1) {
            by.erase(by.begin() + j);
            result += 1;
        }
    }

    // output
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
ll modpow(long long a, long long n, long long mod2) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod2;
        a = a * a % mod2;
        n >>= 1;
    }
    return res;
}

int main() {
    int a,b,c,x,y,ans = INT_MAX,x2,y2,x3,y3;
    cin >> a >> b >> c >> x >> y;
    ans = min(ans,a*x+b*y);
    //cout << ans << endl;
    int tmp = 2*min(x,y)*c;  // ABピザの値段
    x2 = (x-min(x,y));
    y2 = (y-min(x,y));
    tmp += a*x2+b*y2;
    ans = min(ans,tmp);
    //cout << ans << endl;

    int tmp2 = 2*max(x,y)*c;
    //x3 = (x-max(x,y));
    //y3 = (y-max(x,y));
    //tmp2 += a*x3+b*y3;
    ans = min(ans,tmp2);

    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  int a=0,b=0,c=0,d=0;
  cin >>N;
  string v;
  cin>>v;
  for(int i=0;i<N;i++){
    if(v[i]=='(')a--;
    if(v[i]==')')a++;
    if(v[i]==')'&&a>0){c++;a=0;}
  }
  for(int i=N-1;i>=0;i--){
    if(v[i]=='(')b--;
    if(v[i]==')')b++;
    if(v[i]=='('&&b<0){d++;b=0;}
  }
  while(c--)cout<<'(';
  cout<<v;
  while(d--)cout<<')';
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int K, X;
    cin >> K >> X;
    
    if(500 * K >= X) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

edge = Array.new(n+1) {[]}
(n-1).times do
    a, b = gets.split.map(&:to_i)
    edge[a] << b
    edge[b] << a
end

vis = Array.new(n+1)
vis[0] = vis[1] = 0
que = [1]
while now = que.shift
    edge[now].each do |e|
        next if vis[e]
        vis[e] = vis[now] + 1
        que << e
    end
end

vis[n] = 0
que = [n]
while now = que.shift
    edge[now].each do |e|
        next if vis[e] <= vis[now].abs + 1
        vis[e] = vis[now] - 1
        que << e
    end
end

puts 2 * (vis.count {|e| e > 0} + 1) > n ? "Fennec" : "Snuke"

Measured memory_bytes: 23300
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            //var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            //var x = line[0];
            //var y = line[1];
            var n = long.Parse(ReadLine());

            var dictionary = new Dictionary<string, int>();
            dictionary.Add("AC", 0);
            dictionary.Add("WA", 0);
            dictionary.Add("TLE", 0);
            dictionary.Add("RE", 0);

            for(var i = 0; i < n; i++)
            {
                dictionary[ReadLine()]++;
            }

            WriteLine($"AC x {dictionary["AC"]}");
            WriteLine($"WA x {dictionary["WA"]}");
            WriteLine($"TLE x {dictionary["TLE"]}");
            WriteLine($"RE x {dictionary["RE"]}");
        }
    }
}


Measured memory_bytes: 21156
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 1;
vl flag, color; vll path; vl D;
//***********//
int main() {
	cin >> N >> M;
	vpll A(M);
	for (i = 0; i < M; i++) {
		cin >> A[i].first >> A[i].second;
		A[i].first--; A[i].second--;
	}
	sort(A.begin(), A.end());
	ll left = 0;
	ll right = N - 1;
	for (i = 0; i < M; i++) {
		left = A[i].first;
		if (left >= right) {
			ans++;
			right = A[i].second;
		}
		else {
			right = min(right, A[i].second);
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int ans = int.Parse(s[0]) + int.Parse(s[1]) + int.Parse(s[2]);

            if(ans < 22)
            {
                Console.WriteLine("win");
            }
            else
            {
                Console.WriteLine("bust");
            }
        }
    }
}



Measured memory_bytes: 13140
w = gets.to_i
n = gets.to_i
arr = []

for i in 0...w
  arr[i] = i + 1
end

n.times do
  a, b = gets.split(",").map(&:to_i)
  arr[a - 1], arr[b - 1] = arr[b - 1], arr[a - 1]
end

for i in 0...w
  p arr[i]
end

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

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

const long long INF = 1LL << 60;

int main(){
  string s, t;
  cin >> s >> t;

  reverse(all(s));
  cout << (s == t ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int mx = 0, mn = 1000;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mx = max(mx, a);
        mn = min(mn, a);
    }
    int ans = mx - mn;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node{int parent, left, right;};

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

void setDepth(int u, int d)
{
    if(u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u)
{
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    return H[u] = (h1 > h2 ? h1:h2);
}

int getSibling(int u)
{
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
    return NIL;
}

void print(int u)
{
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if(T[u].parent == NIL) printf("root\n");
    else if(T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
    else printf("internal node\n");
}

int main()
{
    int v, l, r, root = 0;
    scanf("%d", &n);

    for(int i=0; i<n; i++) T[i].parent = NIL;

    for(int i=0; i<n; i++)
    {
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }

    for(int i=0; i<n; i++) if(T[i].parent == NIL) root = i;

    setDepth(root, 0);
    setHeight(root);

    for(int i=0; i<n; i++) print(i);
    return 0;
}


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

#define FASTIO1 ios_base::sync_with_stdio(false)
#define FASTIO2 cin.tie(NULL),cout.tie(NULL)
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll power(ll x,ll y,ll p);
const ll inf=999999999;
const ll mod=1e9+7;
bool tc=false;

void solve()
{
	ll d,t,s;
	cin>>d>>t>>s;
	cout<<((s*t)<d?"No":"Yes");
}

int main() 
{
    FASTIO1;
    FASTIO2;
    clock_t start=clock();
    ll t=1; 
    if(tc) cin>>t;
    while(t--)
        solve();
    cerr<<fixed<<setprecision(6);
    cerr<<(double)(clock()-start)/CLOCKS_PER_SEC<<endl;
    return 0;
}

ll power(ll x,ll y,ll p)  
{  
    ll res=1; x=x%p;
    if(x==0) return 0;
    while(y>0)  
    {
        if(y&1) res=(res*x)%p;
        y=y>>1; x=(x*x)%p;  
    }
    return res;  
}  


Measured memory_bytes: 3792
import sys
N = int(input())
c = [str(x) for x in list(input())]
R = sum([1 for i, x in enumerate(c) if(x=='R')])
W = 0
if(R==N)or(R==0):
  print(0)
  sys.exit()
ans = R
i = 0
while True:
  if(i==N):
    print(ans)
    sys.exit()
  if(c[i] == 'W'):
    W += 1
  else:
    R -= 1
  n_ans = max(W,R)
  if(n_ans>ans):
    print(ans)
    sys.exit()
  ans = n_ans
  i += 1

Measured memory_bytes: 12348
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s=input()
sl=len(s)
l=list(s)
nl=[l.pop(0)]
si=0
while len(l)>0:
  c=l.pop(0)
  if len(nl)>0:
    if nl[si]!=c:
      nl.pop(si)
      si=si-1
    else:
      nl.append(c)
      si=si+1
  else:
    nl=[c]
    si=0

print(sl-len(nl))



Measured memory_bytes: 4340
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int box[105],las[20000],edv[20000],cnt=1;
long long edw[20000];
void adde(int u,int v,long long w)
{
	las[++cnt]=box[u];
	box[u]=cnt;
	edv[cnt]=v;
	edw[cnt]=w;
}
void link(int u,int v,long long w)
{
	adde(u,v,w);
	adde(v,u,0);
}
queue<int>q;
int S,T;
int deep[105];
bool bfs()
{
	while(!q.empty())	q.pop();
	memset(deep,0,sizeof(deep));
	deep[S]=1;
	q.push(S);
	while(!q.empty())
	{
		int now=q.front();
		q.pop();
		for(int i=box[now];i;i=las[i])
			if(deep[edv[i]]==0 && edw[i])
			{
				deep[edv[i]]=deep[now]+1;
				q.push(edv[i]);
			}
	}
	return deep[T];
}
int cur[105];
long long dfs(int now,long long r)
{
	if(now==T)	return r;
	for(int& i=cur[now];i;i=las[i])
		if(edw[i] && deep[edv[i]]==deep[now]+1)
		{
			long long ans=dfs(edv[i],min(r,edw[i]));
			if(ans>0)
			{
				edw[i]-=ans;
				edw[i^1]+=ans;
				return ans;
			}
		}
	return 0;
}
int n;
int aa[105];
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
		read(aa[i]);
	S=0;
	T=n+1;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i)
			link(i,j,12345678987654321ll);
	for(int i=1;i<=n;i++)
		if(aa[i]<0)	link(S,i,-aa[i]);
		else if(aa[i]>0)	link(i,T,aa[i]);
	long long ans=0;
	long long sum=0;
	for(int i=1;i<=n;i++)
		if(aa[i]>0)	sum+=aa[i];
	while(bfs())
	{//cout<<"GG"<<endl;
		for(int i=0;i<=n+1;i++)
			cur[i]=box[i];
		ans+=dfs(S,12345678987654321ll);
	}
	cout<<sum-ans<<endl;
	return 0;
}

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

string = [input().split() for i in range(n)]

li = []
for i in string:
    li.append(int(i[0]) - int(i[1]))

c = 0
nli = len(li) - 1

while c != nli:
    if li[c] == 0:
        if c == nli - 1:
            print('No')
            exit()
        elif li[c + 1] == 0:
            if li[c + 2] == 0:
                print('Yes')
                exit()
    c += 1

print('No')


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

using namespace std;

int main() {
  int n;
  int num;
  int i = 0;
  int min = 1000000;
  int max = -1000000;
  long sum = 0;
  cin >> n;
  while (cin >> num) {
    i++;
    sum += num;
    if (num < min) min = num;
    if (num > max) max = num;
    if (i == n) break;
  }
  cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 3072
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
def dfs(a,v):
    global st,per
    if v in st: st.remove(v)
    else: return
    for tom in per:
        if a[v[0]+tom[0]][v[1]+tom[1]]==1: dfs(a,(v[0]+tom[0],v[1]+tom[1]))
while True:
    c,r=map(int,input().split())
    if c==0 and r==0 : exit(0)
    a=[[0]*(c+2)]
    for j in range(r):
        a.append([0]+[int(i) for i in input().split()]+[0])
    a.append([0]*(c+2))
    st=set()
    for i in range(len(a)):
        for j in range(len(a[i])):
            if a[i][j]==1:
                st.add((i,j))
    per=[[1,1],[1,0],[0,1],[-1,1],[1,-1],[-1,-1],[-1,0],[0,-1]]
    ans=0
    while st:
        ans+=1
        for i in st:
            dfs(a,i)
            break
    print(ans)
    


Measured memory_bytes: 8096
#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <climits>
#include <cmath>
#include <set>
#include <map>
#include <sstream>
#include <queue>
#include <stack>
using namespace std;
int dp[100010][3];
int main(){
	int n,a,b,c,temp;
	scanf("%d",&n);
	vector<vector<int>> arr(n,vector<int>(3));
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&arr[i][0],&arr[i][1],&arr[i][2]);
	}
	dp[n-1][0]=arr[n-1][0],dp[n-1][1]=arr[n-1][1],dp[n-1][2]=arr[n-1][2];
	for(int i=n-2;i>=0;i--){
		dp[i][0]=arr[i][0]+max(dp[i+1][1],dp[i+1][2]);
		dp[i][1]=arr[i][1]+max(dp[i+1][0],dp[i+1][2]);
		dp[i][2]=arr[i][2]+max(dp[i+1][0],dp[i+1][1]);
	}
	int ans=max(dp[0][1],dp[0][2]);
	ans=max(ans,dp[0][0]);
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int h, w;
    cin>>h>>w;
    while(h!=0 || w!=0){
        for(int i=0; i<h; i++){
            for(int j = 0; j<w; j++){
                cout<<"#";
            }
            cout<<endl;
        }    
        cin>>h>>w;
        cout<<endl;
    }
}


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

using namespace std;

struct node
{
	int num,fa,ls,rs;
	node(int _num,int _fa)
	{
		num=_num;
		fa=_fa;
		ls=rs=-1;
	}
};

typedef vector<node> Tree;

Tree T;

void insert(int t,int n)
{
	if(T[0].num==INT_MAX) 
		T[0].num=n;
	else if(T[t].num>n)
		if(T[t].ls==-1)
		{
			T[t].ls=T.size();
			T.push_back(node(n,t));
		}
		else insert(T[t].ls,n);
	else
		if(T[t].rs==-1)
		{
			T[t].rs=T.size();
			T.push_back(node(n,t));
		}
		else insert(T[t].rs,n);
}

void find(int t,int x)
{
	if(T.size()==0||t==-1)
		printf("no\n");
	else if(T[t].num==x)
		printf("yes\n");
	else if(x<T[t].num)
		find(T[t].ls,x);
	else find(T[t].rs,x);
}

void lc(int fa,int son)
{
	T[fa].ls=son;
	if(son!=-1) T[son].fa=fa; 
}

void rc(int fa,int son)
{
	T[fa].rs=son;
	if(son!=-1) T[son].fa=fa;
}

void del(int t,int x)
{
	if(t==-1) return ;
	if(T[t].num==x)
	{
		if(T[t].ls==-1)
			if(T[t].rs==-1)
				if(T[T[t].fa].ls==t)
					T[T[t].fa].ls=-1;
				else T[T[t].fa].rs=-1;
			else
				if(T[T[t].fa].ls==t)
				{
					T[T[t].fa].ls=T[t].rs;
					T[T[t].rs].fa=T[t].fa;
				}
				else
				{
					T[T[t].fa].rs=T[t].rs;
					T[T[t].rs].fa=T[t].fa;
				}
		else if(T[t].rs==-1)
				if(T[T[t].fa].ls==t)
				{
					T[T[t].fa].ls=T[t].ls;
					T[T[t].ls].fa=T[t].fa;
				}
				else
				{
					T[T[t].fa].rs=T[t].ls;
					T[T[t].ls].fa=T[t].fa;
				}
			else
			{
				int mir=T[t].rs;
				while(T[mir].ls!=-1) mir=T[mir].ls;
				del(t,T[mir].num);
				T[t].num=T[mir].num;
			}
	}
	else if(x<T[t].num)
		del(T[t].ls,x);
	else del(T[t].rs,x);
}

void Preorder(int t)
{
	if(t==-1) return;
	printf(" %d",T[t].num);
	Preorder(T[t].ls);
	Preorder(T[t].rs);
}

void Inorder(int t)
{
	if(t==-1) return;
	Inorder(T[t].ls);
	printf(" %d",T[t].num);
	Inorder(T[t].rs);
}

void print()
{
	Inorder(T[1].ls);
	printf("\n");
	Preorder(T[1].ls);
	printf("\n");
}

int main()
{
	T.clear();
	T.push_back(node(INT_MAX,1));
	T.push_back(node(-1,-1));
	T[1].ls=0;
	int n;
	scanf("%d",&n);
	while(n--)
	{
		char s[10];
		scanf("%s",s);
		if(s[0]=='i')
		{
			int t;
			scanf("%d",&t);
			insert(T[1].ls,t);
		}
		else if(s[0]=='f')
		{
			int t;
			scanf("%d",&t);
			find(T[1].ls,t);
		}
		else if(s[0]=='d')
		{
			int t;
			scanf("%d",&t);
			del(T[1].ls,t);
		}
		else print();
	}
	return 0;
}

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

int main()
{
  uint64_t sum, n, r = 0, g = 0, b = 0;
  string s;
  cin >> n >> s;
  for (auto c : s)
  {
    switch (c)
    {
    case 'R':
      r++;
      break;
    case 'G':
      g++;
      break;
    case 'B':
      b++;
      break;

    default:
      abort();
    }
  }
  sum = r * g * b;

  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1, k = i + 2; j < n && k < n; j++, k += 2)
    {
      if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k] && j - i == k - j)
      {
        sum--;
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int iw[100010]={},ih[100010]={};
int main(){
  int n,w,h;
  cin>>n>>w>>h;
  for(int i=0;i<n;i++){
    int x,y,z;
    cin>>x>>y>>z;
    iw[max(0,x-z)]++;
    iw[min(w+1,x+z)]--;
    ih[max(0,y-z)]++;
    ih[min(h+1,y+z)]--;
  }
  int f1=0,f2=0;
  for(int i=1;i<=w;i++){
    iw[i]+=iw[i-1];
    if(!iw[i-1])f1=1;
  }
  for(int i=1;i<=h;i++){
    ih[i]+=ih[i-1];
    if(!ih[i-1])f2=1;
  }
  cout<<(f1&&f2?"No":"Yes")<<endl;
  return 0;
}





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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	rep(i, N) cin >> p[i];
	rep(i, N) ++p[i];
	vector<ll> q(N);
	q[0] = p[0];
	rep(i, N-1) {
		q[i+1] = q[i] + p[i+1];
	}
	vector<ll> tmp(N);
	rep(i, N-K+1) {
		if (i == 0) tmp[i] = q[i+K-1];
		else tmp[i] = q[i+K-1] - q[i-1];
	}
	ll max = *max_element(tmp.begin(), tmp.end());
	double ans;
	ans = max/2.0;
	printf("%.12f\n", ans);
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <vector>

int compute(std::string& s) {
    int count = 0;
    for (int i = 0; i < s.size() - 1; ++i) {
        if (s.at(i) == 'A' && s.at(i+1) == 'C') {
            ++count;
        }
    }

    return count;
}

int main()
{
    std::string S;
    int N, Q;
    
    std::cin >> N >> Q;
    std::cin >> S;
    std::vector<int> l(Q), r(Q);

    for (int i = 0; i < Q; ++i) {
        std::cin >> l.at(i) >> r.at(i);
        --l.at(i);
        --r.at(i);
    }

    std::vector<int> ans(N);

    ans.at(0) = 0;
    int count = 0;
    for (int i = 1; i < S.size(); ++i) {
        if (S.at(i - 1) == 'A' && S.at(i) == 'C') {
            ++count;
        }
        ans.at(i) = count;
    }

    for (int i = 0; i < Q; ++i) {
        std::cout << ans.at(r.at(i)) - ans.at(l.at(i)) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 2176
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int k ,x;
		cin>> k >> x;
		if(k*500 >=x)cout<<"Yes\n";
		else
			cout<<"No";
	
	
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

#define MAX_N (100L)
#define MAX_V (1000L)
#define INF (1000000000000000000L)

using namespace std;

long dpss[MAX_N + 1][MAX_N * MAX_V + 1];

int main() {
  // read inputs
  long N, W, ws[MAX_N], vs[MAX_N];
  scanf("%ld %ld", &N, &W);
  for (long i = 0; i < N; i++) {
    scanf("%ld %ld", &ws[i], &vs[i]);
  }

  // solve dp
  dpss[0][0] = 0;
  for (long j = 1; j <= N * MAX_V; j++) {
    dpss[0][j] = INF;
  }
  for (long i = 0; i < N; i++) {
    for (long j = 0; j <= N * MAX_V; j++) {
      if (j >= vs[i]) {
        dpss[i + 1][j] = min(dpss[i][j], ws[i] + dpss[i][j - vs[i]]);
      } else {
        dpss[i + 1][j] = dpss[i][j];
      }
    }
  }

  // print answer
  long ans = 0;
  for (long j = 0; j <= N * MAX_V; j++) {
    if (dpss[N][j] <= W) {
      ans = max(ans, j);
    }
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 79104
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N, K = map(int, input().split())

    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(range(1, K + 1)):
        n = pow(K // k, N, mod=P)
        for kk in range(2 * k, K + 1, k):
            n -= n_gcd[kk]
        n_gcd[k] = n % P
        ans += k * n_gcd[k]
        ans %= P

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11216
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

void brute_force(int A, int B, int C, long long K) {
    long long a = A, b = B, c = C;
    for (int i = 0; i < K; i++) {
        // printf("%lld %lld %lld\n", a, b, c);
        long long na = b + c;
        long long nb = a + c;
        long long nc = a + b;
        a = na, b = nb, c = nc;
    }
    printf("diff = %lld\n", a - b);
    return;
}

int main() 
{
    // freopen("./input.txt", "r", stdin);
    // freopen("./output.txt", "w", stdout);
    
    int A, B, C;
    long long K;
    scanf("%d %d %d", &A, &B, &C);
    scanf("%lld", &K);
    long long diff;
    if (K % 2 == 0) {
        diff = A - B;
    } else {
        diff = B - A;
    }
    if (abs(diff) > 1e18) {
        printf("Unfair\n");
    } else {
        printf("%lld\n", diff);
    }
    
    // brute_force(A, B, C, K);

	return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> picture(H, vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) cin >> picture.at(i).at(j);
    }

    vector<vector<char>> expand(H + 2, vector<char>(W + 2, '#'));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            expand.at(i + 1).at(j + 1) = picture.at(i).at(j);
        }
    }

    for(int i = 0; i < H + 2; i++){
        for(int j = 0; j < W + 2; j++){
            cout << expand.at(i).at(j);
            if(j == W + 1) cout << endl;
        }
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    _ = int(readline())
    ds = map(int, readline().split())

    ans = 0
    for d1, d2 in itertools.combinations(ds, 2):
        ans += d1 * d2
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	cin>>n>>m>>k;
	vector<int>q1, q2;
	int sum=0;
	q1.push_back(0);
	q2.push_back(0);
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		sum+=x;
		q1.push_back(sum);
	}
	sum=0;
	for(int i=1;i<=m;i++){
		int x;
		cin>>x;
		sum+=x;
		q2.push_back(sum);
	}
	int ans=0;
	for(int i=0;i<=n;i++){
		int L=0, R=m;
		while(L<R){
			int M=(L+R+1)/2;
			if(q2[M]+q1[i]<=k) L=M;
			else R=M-1;
		}
		if(q2[L]+q1[i]<=k) ans=max(ans, i+L);
	}
	cout<<ans;
}

Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int H, W; std::cin >> H >> W;
    std::vector<std::vector<int>> fi(H+5, std::vector<int>(W+5, 1)), dp(H+5, std::vector<int>(W+5, 0));
    repr(i, 1, H+1) repr(j, 1, W+1) {
        std::cin >> fi[i][j];
        if (fi[i][j]) dp[i][j] = 0;
        else dp[i][j] = dp[i-1][j]+1;
    }

    int ans = 0;
    repr(i, 1, H+1) {
        stack<pair<int, int>> st;
        repr(j, 1, W+2) {
            if (st.empty()) { st.push(make_pair(j, dp[i][j])); }
            else if (st.top().second < dp[i][j]) { st.push(make_pair(j, dp[i][j])); }
            else if (st.top().second > dp[i][j]) {
                int pos;
                while(!st.empty() && st.top().second > dp[i][j]) {
                    auto p = st.top(); st.pop();
                    chmax(ans, p.second*(j-p.first));
                    pos = p.first;
                }
                st.push(make_pair(pos, dp[i][j]));
            }
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 18384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 5003;
int k, q, d[N], b[N];
ll a[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> k >> q;
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}
	while (q--) {
		int n, x, m;
		cin >> n >> x >> m;
		x %= m;
		ll total = 0;
		for (int i = 0; i < k; i++) {
			b[i] = d[i] % m;
			if (b[i] == 0) {
				b[i] = m;
			}
			total += b[i];
			//cout << b[i] << ' ';
		}
		//cout << '\n';
		int r = (n - 1) % k;
		int l = (n - 1) / k;
		a[0] = x;
		for (int i = 1; i <= r; i++) {
			a[i] = a[i - 1] + b[i - 1];
			//cout << "a[" << i << "] = " << a[i] << '\n';
		}
		cout << (n - 1) - (a[r] + l * total) / m << '\n';
	}
}


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

const int MAX_N = 1010;

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

    int n;
    while(cin >> n && n){

        int num[MAX_N], p[MAX_N], q[MAX_N], r[MAX_N], c[MAX_N];
        for(int i = 0; i < n; ++i){
            cin >> num[i];
            cin >> p[i] >> q[i] >> r[i];
            c[i] = 4 * p[i] + 9 * q[i] + 4 * r[i];
        }

        int pmax, qmax, rmax, cmax;
        cin >> pmax >> qmax >> rmax >> cmax;

        bool check = true;
        for(int i = 0; i < n; ++i){
            if(pmax >= p[i] && qmax >= q[i] && rmax >= r[i] && cmax >= c[i]){
                check = false;
                cout << num[i] << endl;
            }
        }

        if(check){
            cout << "NA" << endl;
        }
    }
    
   return 0;
}

Measured memory_bytes: 1216
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

double absol(double a, double b)
{
	double to_return = a - b;
	if(to_return < 0.00)
	{
		to_return = to_return * -1.00;
	}
	return to_return;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	double deg_min = 6 * m;
	double deg_hr = 30*h;
	deg_hr += 1.00 * 0.5 * m;
	double delta = absol(deg_min, deg_hr);
	if(delta > 180.00)
	{
		delta = 360.00 * 1.00 - delta;
	}
	//apply rule of cosines
	double x = a*a*1.00;
	x += b*b*1.00;
	double z = 2.00*a*b*1.00;
	delta = delta * 3.141592653589793238;
	delta = delta/(180.00 * 1.00);
	z = z * cos(delta);
	x -= z;
	double ans = sqrt(x);
	cout<<setprecision(30)<<ans;
	return 0;
}

Measured memory_bytes: 4132
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int h[100009];
int main(){
	int n;
	long long int a,b;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	long long int sa=a-b;
	long long int mi=0,ma=1000000000,mid;
	while(ma-mi>1){
		mid=(mi+ma)/2;
		long long int cnt=0;
		for(int i=0;i<n;i++){
			if(h[i]>b*mid){
				cnt+=(h[i] - b * mid + a - b - 1) / (a-b);
			}
		}
		if(cnt>mid){
			mi=mid;
		}
		else{
			ma=mid;
		}
	}
	cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int t, x;
    cin >> t >> x;
    printf("%.14f\n", (double)t / x);

    return 0;
}

Measured memory_bytes: 256
def readInt():
    return list(map(int, input().split()))

n,x,t = readInt()
# print(n,x,t)
set_t = n // x
# print(set_t, n%x)
if n % x == 0:
    ans = t * set_t
else:
    ans = t * (set_t+1)
print(ans)

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

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> C(H);
  for(int i = 0; i < H; ++i)
    cin >> C[i];
  int ans = 0;
  for(int i = 0; i < (1<<H); ++i){
    for(int j = 0; j < (1<<W); ++j){
      int c = 0;
      for(int k = 0; k < H; ++k){
        if(i>>k&1) continue;
        for(int l = 0; l < W; ++l){
          if(j>>l&1) continue;
          if(C[k][l] == '.') continue;
          ++c;
        }
      }
      if(c == K) ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, t;
    cin >> n >> t;
    akari<int> dp(t + 1, -1e9);
    akari<pair<int, int>> ps(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ps[i].first >> ps[i].second;
    }
    sort(ps.begin(), ps.end());
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        int a = ps[i].first, b = ps[i].second;
        for (int j = t - 1; j >= 0; j--)
        {
            dp[min(t, j + a)] = max(dp[min(t, j + a)], dp[j] + b);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <queue>

using namespace std;

int main()
{
  int t;
  cin >> t;
  for(int i = 0; i < t; i++)
  {
	int n, d;
	cin >> n >> d;
	if(n % 2 == 0)
	{
	  cout << 127 * (n - 1) + (d ^ 127) << endl;
	}
	else
	{
	  cout << 127 * (n - 1) + d << endl;
	}
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
long long  bitcount64(long long bits)
{
	bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555);
	bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333);
	bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f);
	bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff);
	bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff);
	return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff);
}
void solve() {
	int N;
	cin >> N;
	int ans = 0;
	int a;
	while (N--) {
		cin >> a;
		ans += bitcount64((a^(a-1))>>1);
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out

class UnionFind {
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;
    //作るときはParentの値を全て-1にする
    //こうすると全てバラバラになる
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//親をとってきたい]
    }
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらひっくり返しちゃう。
        if (size(A) < size(B)) swap(A, B);
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        return true;
    }
};


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    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]--;
    }
    vector<long long> ans(M);
    ans[M - 1] = (long long)N * (N - 1) / 2;
    UnionFind Uni(N);
    for (int i = M - 1; i >= 1; i--){
        ans[i - 1] = ans[i];
        //繋がってなかったのが繋がった時
        if (Uni.root(A[i]) != Uni.root(B[i])) {
            ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
            Uni.connect(A[i], B[i]);
        }
    }
    for (int i = 0; i < M; i++){
        cout << ans[i] << endl;
    }

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3328
import java.util.Scanner

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val a = for(i <- 0 until n) yield sc.nextInt()
  val c = a.count(_ % 2 == 1)
  if(c % 2 == 0) println("YES")
  else println("NO");
}

Measured memory_bytes: 47228
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
	int x[2], y[2];
	int a, b;

	cin >> x[0] >> y[0] >> x[1] >> y[1];

	a = x[1] - x[0];
	b = y[1] - y[0];

	cout << x[1] - b << " ";
	cout << y[1] + a << " ";
	cout << x[0] - b << " ";
	cout << y[0] + a << " ";

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var inp = ReadLine().Split(' ').Select(s => double.Parse(s)).ToList();
        var n = inp[0];
        var m = inp[1];
        var d = inp[2];
        double hoge = 0;

        if (d == 0) {
            hoge = 1 / n;
        } else {
            hoge = (n - d) * 2 / Math.Pow(n, 2);
        }

        WriteLine((hoge * (m - 1)).ToString("F10"));
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define all(n)      (n).begin(), (n).end()
#define ll long long 
#define PI 3.14159265358979323846

void solve(){
	int r; cin >> r;
	long double ans;
	ans = (2.000000000000 * PI * (long double)r);
	cout << setprecision(12) << ans << endl;
	

}


int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	
		solve();
	
	return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#define FLAG -1
using namespace std;
typedef pair<int,int> P;
int main(){
      int h,w,dh[] = {1,1,1,0,-1,-1,-1,0}, dw[] = {1,0,-1,-1,-1,0,1,1},ctn,i,j;
      int solve = -1 ;
      cin >> h >> w;
      queue<P> que,tmp;
      char d[h][w];
      for(i=0;i<h;i++){
            for(j=0;j<w;j++)
            {
                  cin >> d[i][j];
                  if('1'<=d[i][j]&&'9'>=d[i][j])
                        que.push(make_pair(i,j));
            }
      }

      que.push(make_pair(FLAG,FLAG));
      for(;;){
            solve++;
            map<P,bool> m;
            for(;;){
                  //cout << que.size()<<endl;
                  P p = que.front();
                  que.pop();
                  if(p.first==FLAG)
                  {//cout <<" break "<<endl<<endl;
                  break;
                  }
                  if(d[p.first][p.second]=='.')continue;
                  ctn = 0;
                  for(i = 0;i < 8;i++){
                        if(d[p.first+dh[i]][p.second+dw[i]]=='.')ctn++;
                  }

                  if(ctn >= d[p.first][p.second]-'0'){
                        tmp.push(p);
                        for(j=0;j<8;j++)
                        if(m.count(make_pair(p.first+dh[j],p.second+dw[j]))==0){
                        que.push(make_pair(p.first+dh[j],p.second+dw[j]));
                        m[make_pair(p.first+dh[j],p.second+dw[j])]=true;
                        }
                  }
            }
            if(tmp.empty())break;
            while(!tmp.empty())
            {
                  d[tmp.front().first][tmp.front().second]='.';
                  tmp.pop();
            }
            /*for(i =0 ;i<h;i++)
            {
                  for(j=0;j<w;j++)cout << d[i][j];
                  cout <<endl;
            }
            */

            que.push(make_pair(FLAG,FLAG));

      }
      cout << solve << endl;
}

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

#define ll long long

int main() {
    int N, K;
    cin >> N >> K;
    int V[N];
    for(int i = 0;i < N;i++) {
        cin >> V[i];
    }

    int mx = -1;

    for(int l = 0;l <= min(N, K);l++) {
        for(int r = 0;r + l <= min(N, K);r++) {
            int vlr[l + r];
            int sum = 0;
            for(int i = 0;i < l;i++) {
                vlr[i] = V[i];
                sum += V[i];
            }
            for(int i = N - 1;N - r <= i;i--) {
                vlr[N - i - 1 + l] = V[i];
                sum += V[i];
            }
            sort(vlr, vlr + l + r);
            for(int i = 0;i < min(l + r, K - (l + r));i++) {
                sum -= vlr[i] < 0 ? vlr[i] : 0;
            }
            mx = max(sum, mx);
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, k = gets.split.map(&:to_i)

ans = 0

# a枚からk枚全部取って終わり
if k <= a
  ans += k
else
  # aまい全部取る
  ans += a
  # -1点を残りのk枚だけ取る必要がある
  if k  > a + b
    ans -= (k-a-b)
  end
end

puts ans

Measured memory_bytes: 14356