akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;


int st[35][(1<<16)]; //���׻�
int a[31]; //������
int b[31]; //������
int dp[31][(1<<16)];
        
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    while( true ) {
        int n, c;
        cin >> n >> c;
        if( n == 0 ) break;
        for( int i = 0; i < 31; ++i ) a[i] = 0;
        for( int i = 0; i < 31; ++i ) b[i] = 0;

        for( int i = 0; i < 35; ++i ) {
            for( int j = 0; j < (1<<16); ++j ) st[i][j] = 0;

        }
        for( int i = 0; i < 31; ++i ) {
            for( int j = 0; j < (1<<16); ++j ) dp[i][j] = MIN;

        }

        for( int i = 0; i < n; ++i ) {
            for( int j = 0; j < 16; ++j ) {
                int in;
                cin >> in;
                a[i] |= ( in << j );

            }
        }

        for( int i = 0; i < c; ++i ) {
            for( int j = 0; j < 16; ++j ) {
                int in;
                cin >> in;
                b[i] |= ( in << j );

            }
        }

        //���׻�
        for( int i = 0; i < n; ++i ) {
            for( int j = 0; j < (1<<16); ++j ) {
                int score = 0;
                unsigned int bits = j & a[i];
                while( bits ) {
                    if( bits & 1 ) ++score;
                    bits >>= 1;
        
                }
                st[i][j] = score;

            }
        }
        /*
        for( int i = 0; i < n; ++i ) {
            for( int j = 0; j < (1<<16); ++j ) {
                if( dp[i % 2][j] < 0 ) continue;
                int nx = ( j | a[i + 1] );
                dp[(i + 1) % 2][nx] = max( dp[(i + 1) % 2][nx], dp[i % 2][j] );

                for( int k = 0; k < c; ++k ) {
                    int tx = ( nx - ( nx & b[k] ) );
                    dp[(i + 1) % 2][tx] = max( dp[(i + 1) % 2][tx], 
                                                dp[i % 2][j] + st[k][nx] );
                }
            }
        }*/

        dp[0][0] = 0;
        for( int i = 0; i < n; ++i ) {
            for( int j = 0; j < (1<<16); ++j ) {
                int nx = ( j | a[i] );
                dp[i + 1][nx] = max( dp[i + 1][nx], dp[i][j] );

                for( int k = 0; k < c; ++k ) {
                    int tx = ( nx & ~( nx & b[k] ) );
                    dp[i + 1][tx] = max( dp[i + 1][tx], dp[i][j] + __builtin_popcount( nx & b[k] ) );

                }
            }
        }

        int res = 0;
        for( int i = 0; i < (1<<16); ++i ) {
            res = max( res, dp[n][i] );

        }
        cout << res << endl;

    }

    return 0;
}



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

public class Main {

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static List<Pair>[] edges;
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		edges = new ArrayList[n+1];
		for(int i=0;i<=n;++i) edges[i] = new ArrayList<>();
		for(int i=1;i<n;++i) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int w = sc.nextInt();
			edges[u].add(new Pair(v,w));
			edges[v].add(new Pair(u,w));
		}
		int[] col = new int[n+1];
		bfs(1,0,col);
		for(int i=1;i<=n;++i) {
			out.println(col[i]);
		}
		
        out.close();
		
	}
	
	private static void bfs(int i, int j, int[] col) {
		Queue<Integer> q = new ArrayDeque<>();
		q.add(1);
		boolean[] vis = new boolean[col.length];
		vis[1] = true;
		while(q.size() > 0) {
			int node = q.poll();
			for(Pair child : edges[node]) {
				if(!vis[child.v]) {
					q.add(child.v);
					if((child.w&1) == 0)
					col[child.v] = col[node];
					else col[child.v] = col[node]^1;
					vis[child.v] = true;
				}
			}
		}
		
		
	}

	static class Pair{
		int v;
		int w;
		Pair(int v,int w){
			this.v = v;
			this.w = w;
		}
	}
}


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


//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences you’ll be able to get past them and grow even closer.
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
//than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.
//Whatever you do, enjoy it to the fullest. That is the secret of life.
//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for.


#define ps push_back
#define le length
#define in insert
#define vint vector<int>
#define vlld vector<long long int>
#define pii pair<int,int>
#define mk make_pair
#define vst vector<string>
#define lld long long int 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)

int main()
{
	int a,b;
	cin>>a>>b;
	a = max(0 , (a*(a-1))/2);
	b = max(0 , (b*(b-1))/2);
	cout<<a+b<<endl;
	return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var S = Number(inputs);
  var h =Math.floor (S/3600);
  var m = Math.floor(( S - (h * 3600)) / 60 );
  var m = Math.floor(S%3600 / 60);
  var s = S % 60;
  console.log([h,m,s].join(':'));
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15532
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
#define N 1005
int a[N],b[N];
int f[N*20];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int h,n;
	cin>>h>>n;
	for(int i=1;i<=n;i++) a[i]=read(),b[i]=read();
	for(int i=1;i<=h+10000;i++)
	{
		f[i]=-1;
		for(int j=1;j<=n;j++)
		{
			if(i>=a[j]&&f[i-a[j]]!=-1)
			{
				if(f[i]==-1||f[i]>f[i-a[j]]+b[j]) f[i]=f[i-a[j]]+b[j];
			}
		}
	}
//	for(int i=0;i<=h*2;i++) printf("%d ",f[i]);
//	cout<<"\n";
	int ans=-1;
	for(int i=h;i<=10000+h;i++) if(f[i]!=-1) if(ans==-1||f[i]<ans) ans=f[i];
	cout<<ans<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 384
# -*-coding:utf-8-*-
"""
A:長さNの要素不明の正数列
B:要素bi(1<=i<=N-1)でbiはbi>=max(ai,ai+1)を満たす
Aの要素の総和の最大値を求めよ
要素ai(i>2)はbi-1,biから(両方を超えないように)制約を受ける.その中で最大となるaiを選ぼうと思えば、bi,bi-1の最小値に等しくなる
i==0とi==Nのときは特殊
"""
N=int(input())
B=list(map(int,input().split()))

sum_ai=0
for i in range(N):
    if i==0: # i==0のときbi-1が存在しないので
        min_b = B[i]
        sum_ai += min_b
    elif i<N-1: # i>0
        min_b = min(B[i], B[i-1])
        sum_ai += min_b
    else: # i==N-1
        min_b = B[i-1]
        sum_ai += min_b

print(sum_ai)


Measured memory_bytes: 3064
/*
 * Moonlight Farm
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2198
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {
  int n;
  while(cin >> n, n) {
    vector<pair<double, string>> farm;
    string l;
    REP(i, n){
      int p, a, b, c, d, e, f, s, m;
      cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      farm.push_back({-(s * f * m - p) / (double)(a + b + c + (d + e) * m), l});
    }

    SORT(farm);
    for(pair<double, string> s : farm) {
      cout << s.second << endl;
    }
    printf("#\n");
  }
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    string S;
    cin >> S;
    rep(i, 0, S.size()){
        cout << "x";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 1e7 + 5;

int facs[N];
				
int32_t main() {
	fast_cin();  
	for (int i = 1; i < N; ++i) {
		for (int j = i; j < N; j += i) {
			++facs[j];
		}
	}
	int n; cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += i * facs[i];
	}
	cout << ans << endl;
	return 0;
}

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

void solve(long long A, long long B)
{
    if (A > B)
    {
        cout << A + (A - 1) << endl;
    }
    else if (A == B)
    {
        cout << A + B << endl;
    }
    else
    {
        cout << B + (B - 1) << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int N,M;
int P[100000],Y[100000];
vector<int> idy[100001];


int main(){
    cin>>N>>M;
    rep(i,0,M){
        cin>>P[i]>>Y[i];
        idy[P[i]].push_back(Y[i]);
    }
    rep(i,1,N+1){
        sort(idy[i].begin(),idy[i].end());
    }
    rep(i,0,M){
        printf("%06d",P[i]);
        int x=(int)(lower_bound(idy[P[i]].begin(),idy[P[i]].end(),Y[i])-idy[P[i]].begin())+1;
        printf("%06d\n",x);
    }
    return 0;
}

Measured memory_bytes: 7808
#include <cstdio>
#include <iostream>
#include <climits>

using namespace std;

int cnt = 0;
int Arr[500010];
int L[500010];
int R[500010];

void merge(int A[], int l, int m, int r)
{
  int n1 = m - l;
  int n2 = r - m;
  for(int i = 0; i < n1; i++) L[i] = A[l + i];
  for(int i = 0; i < n2; i++) R[i] = A[m + i];
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;

  int a = 0;
  int b = 0;
  for(int i = l; i < r; i++)
  {
    cnt++;
    if(L[a] <= R[b])
    {
      A[i] = L[a];
      a++;
    }
    else
    {
      A[i] = R[b];
      b++;
    }
  }
}

void mergeSort(int A[], int l, int r)
{
  if(l + 1 < r){
    int m = (l + r) / 2;
    mergeSort(A, l, m);
    mergeSort(A, m, r);
    merge(A, l, m ,r);
  }
}

void printArr(int A[], int n)
{
  for(int i = 0; i < n-1 ; i++) cout << A[i] << " ";
  cout << A[n-1] << endl;
}

int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> Arr[i];
  mergeSort(Arr, 0, n);
  printArr(Arr, n);
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 6048
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        //Zero Sum の気持ち
        int N = NextInt(), M = NextInt();
        int[] A = LineInt();
        int[] B = new int[N + 1];
        for (int i = 1; i <= N; i++) B[i] = (B[i - 1] + A[i - 1]) % M;
        Dictionary<int, long> d = new Dictionary<int, long>();
        for (int i = 0; i <= N; i++)
        {
            int b = B[i];
            if (!d.ContainsKey(b)) d[b] = 0;
            d[b]++;
        }
        long ans = 0;
        foreach (var e in d) { ans += (e.Value - 1) * e.Value / 2; }
        Console.WriteLine(ans);
        //Console.WriteLine(string.Join(' ', B));
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 21472
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef vector < int > vint;
typedef pair < int, int > pii;
typedef pair < int, bool > pib;
typedef unsigned long long ull;

#define PB push_back
#define MP make_pair
#define RANGE(V) V.begin(), V.end()
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORN(i,n) for(int i=1;i<=n;++i)
#define debug(x) cerr<<#x<<":"<<x<<"\n";
#define FORS(i,n) for(int i=0;i<n.length();++i)
const int INF = INT_MAX;
const int MAX = 10000001;
const int M = 1000000007;
int mod{ 1000000007 };

char s[200010];
int main() {
    scanf("%s", s);
    int len = strlen(s);
    int sum = 0;
    for (int i = 0; i < len; i++)sum += s[i] - '0';
    if (sum % 9 == 0) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}






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

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

  string S;
  set<string> st;
  rep(i, N) {
    cin >> S;
    st.insert(S);
  }

  if (st.size() == 3)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

Measured memory_bytes: 3628
line = gets.chomp.split(" ").map { |num| num = num.to_i }
k = gets.to_i

max = line.max
total = 0

# p line
# p max

line.each { |num|
  if num == max
    total += num * (2 ** k)
    max = 0
  else
    total += num
  end
}

puts total

Measured memory_bytes: 1916
e1,e2,e3,e4=input().split()
e1=int(e1)
e2=int(e2)
e3=int(e3)
e4=int(e4)
if e1==e2 and e1==e3 and e1==e4:
    print("yes")
elif e1==e2:
    if e3==e4:
        print("yes")
    else:
        print("no")
elif e1==e3:
    if e2==e4:
        print("yes")
    else:
        print("no")
elif e1==e4:
    if e3==e2:
        print("yes")
    else:
        print("no")
elif e3==e2:
    if e1==e4:
        print("yes")
    else:
        print("no")
elif e4==e2:
    if e3==e1:
        print("yes")
    else:
        print("no")
elif e3==e4:
    if e1==e2:
        print("yes")
    else:
        print("no")
else:
    print("no")


Measured memory_bytes: 5596
N, M = map(int, input().split(" "))
vote = list(map(int, input().split(" ")))
vote.sort()
total = sum(vote)
count = 0
thres = total/(4*M)
for i in range(N)[::-1] :
    if vote[i] >= thres :
        count += 1
    else :
        break 

if count >= M :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n, v, num[200007], val[20], l, tl[200007][20], tr[200007][20], dp1[500007], dp2[500007], s;
int mn[200007];
int read()
{
	int num = 0, f = 1;
	char c = getchar();
	while ((c < '0' || c>'9') && c != '-')c = getchar();
	if (c == '-')f = -1, c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num * f;
}
int main()
{
	n = read();
	v = read();
	for (int i = 1; i <= n; i++)
		num[i] = read();
	while (v >> l)l++;
	val[l] = v;
	for (int i = l - 1; i >= 0; i--)
		val[i] = (val[i + 1] >> 1);
	for (int i = 0; i <= l; i++)
		tl[1][i] = 1;
	for (int i = 2; i <= n; i++)
		for (int j = 0; j <= l; j++)
			if (num[i] - num[i - 1] > val[j])
				tl[i][j] = i;
			else tl[i][j] = tl[i - 1][j];
	for (int i = 0; i <= l; i++)
		tr[n][i] = n;
	for (int i = n - 1; i >= 1; i--)
		for (int j = 0; j <= l; j++)
			if (num[i + 1] - num[i] > val[j])
				tr[i][j] = i;
			else tr[i][j] = tr[i + 1][j];
	for (int i = 0; i < (1 << l); i++)
		for (int j = 0; j < l; j++)
			if (!((i >> j) & 1))
				dp1[i ^ (1 << j)] = max(dp1[i ^ (1 << j)], dp1[i] == n ? n : tr[dp1[i] + 1][j]);
	memset(dp2, 0x3f3f3f, sizeof dp2);
	dp2[0] = n + 1;
	for (int i = 0; i < (1 << l); i++)
		for (int j = 0; j < l; j++)
			if (!((i >> j) & 1))
				dp2[i ^ (1 << j)] = min(dp2[i ^ (1 << j)], dp2[i] == 1 ? 1 : tl[dp2[i] - 1][j]);
	s = (1 << l) - 1;
	memset(mn, 0x3f3f3f, sizeof mn);
	for (int i = 0; i <= s; i++)
		mn[dp1[i]] = min(mn[dp1[i]], dp2[i ^ s]);
	for (int i = n; i >= 0; i--)
		mn[i] = min(mn[i], mn[i + 1]);
	for (int i = 1; i <= n; i++)
		if (mn[tl[i][l] - 1] <= tr[i][l] + 1)
			printf("Possible\n");
		else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 39168
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, ans = 0;
	cin >> n;
	vi a(n);
	Foz(i, n) cin >> a[i];
	Foz(i, n) while (a[i] % 2 == 0) { ans++; a[i] /= 2; }
	cout << ans << '\n';
}



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

template<long long mod>
class ModInt {
public:
	long long v;
	ModInt(long long v = 0) : v((v % mod + mod) % mod) {}
	ModInt operator+(ModInt t) {return ModInt((v + t.v) % mod);}
	ModInt operator-(ModInt t) {return ModInt((v - t.v + mod) % mod);}
	ModInt operator*(ModInt t) {return ModInt((v * t.v) % mod);}
	ModInt operator+=(ModInt t) {return *this = *this + t;} 
	ModInt operator-=(ModInt t) {return *this = *this - t;}
	ModInt operator*=(ModInt t) {return *this = *this * t;}
	ModInt operator-() {return ModInt(-v);}
	ModInt mpow(long long t) {
		if (t == 0) return ModInt(1);
		ModInt a = mpow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	ModInt inv() {return mpow(mod - 2);}
	ModInt operator/(ModInt t) {return ModInt(v) * t.inv();}
	ModInt operator/=(ModInt t) {return *this = *this / t;}
	ModInt operator==(ModInt t) {return *this.v == t.v;}
	ModInt operator!=(ModInt t) {return *this.v != t.v;}
	friend ostream& operator<<(ostream& os, const ModInt& mi) {
		os << mi.v;
		return os;
	}
};

const long long mod = 1000000007;
using mint = ModInt<mod>;

template<const long long mod>
class BinominalCoefficient {
public:
    using mint = ModInt<mod>;

    int MAX;
    vector<mint> fac, inv, finv;
    BinominalCoefficient(int MAX = 2000005) {
        this->MAX = MAX;
        fac = vector<mint>(MAX, 1);
        inv = vector<mint>(MAX, 1);
        finv = vector<mint>(MAX, 1);
        for (int i = 2; i < MAX; ++i) {
            fac[i] = fac[i - 1] * mint(i);
            inv[i] = -inv[mod % i] * mint(mod / i);
            finv[i] = finv[i - 1] * inv[i];
        }
    }
    mint com(int n, int k) {
        if (k > n || n < 0 || k < 0) return 0;
        return fac[n] * finv[k] * finv[n - k];
    }
    mint Okcom(int n, int k) {
        if (k > n || n <= 0 || k < 0) return 0;
        mint ans = 1;
        for (int i = 0; i < k; i++) {
            ans *= mint(n - i) * inv[k - i];
        }
        return ans;
    }
};

int main() {

    BinominalCoefficient<mod> bf;

    int N, K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A, A + N);
    mint ans = mint(0);
    for (int i = 0; i < N; i++) {
        ans += bf.com(i, K - 1) * mint(A[i]);
        ans -= bf.com(N - i - 1, K - 1) * mint(A[i]);
    }

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

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

int main(){
    int conditions;//条件
    cin>>conditions;
    string str;
    cin>>str;
    if(str.length() <= conditions){
        cout<<str<<endl;
    } else {
        for(unsigned i=0;i<conditions;i++){
            cout<<str[i];
        }
        cout<<"..."<<endl;
    }

    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int ans = 1;
  ll a, b; cin >> a >> b;
  while(a * 2 <= b){
    ans++;
    a *= 2;
  }
  cout << ans << endl;
  return 0;
}


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

long long int dp[100000];

int main() {
    long long int n,w,i,j;
    cin>>n>>w;
    long long int a[n],wt[n],su=0;
    for(i=0;i<100000;i++){
        dp[i]=10000000000;
    }
    for(i=0;i<n;i++){
        cin>>wt[i]>>a[i];
        su+=a[i];
    }
    dp[0]=0;
    for(i=0;i<n;i++){
        for(j=su;j>=0;j--){
            if(j-a[i]>=0){
                dp[j] = min(dp[j],dp[j-a[i]]+wt[i]);
            }
        }
    }
    for(j=su;j>=0;j--){
        if(dp[j]<=w){
            cout<<j<<endl;
            break;
        }
    }
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
char Solve(char c)
{
  if(isupper(c))
  {
    return 'A';
  }
  else
  {
    return 'a';
  }
}
int main()
{
  char c;
  cin>>c;
  cout<<Solve(c)<<"\n";
  return 0;
}


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

int main() {

    char s[555];
    scanf("%s", &s);

    int n = strlen(s);
    int r = 0;
    for(int i=0; i<n-1-i; i++) {
        if (s[i] != s[n-1-i]) r++;
    }

    printf("%d\n", r);

    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d=0;
			if(a>b){
				d=b;
				b=a;
				a=d;
				if(b>c){
					d=c;
					c=b;
					b=d;
					
				}
			}
		     else if(a>c){
					d=c;
					c=a;
					a=d;
			}
			if(a>b){
				d=b;
				b=a;
				a=d;
			}
			if(b>c){
				d=c;
				c=b;
				b=d;
			}
		System.out.println(+a+" "+b+" "+c);
	}

}

Measured memory_bytes: 26236
import math

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

A,B,C,D = map(int,input().split())

C_ = len(range(A//C*C if A%C==0 else (A//C+1)*C,B+1,C))
D_ = len(range(A//D*D if A%D==0 else (A//D+1)*D,B+1,D))
CD = lcm(C,D)
CD_ = len(range(A//CD*CD if A%CD==0 else (A//CD+1)*CD,B+1,CD))

print(B-A+1-C_-D_+CD_)

Measured memory_bytes: 3064
import numpy as np

N, K = map(int, input().split())
p = [int(i) for i in input().split()]
p = np.array(p)
p = (p + 1)/2
p = np.cumsum(np.insert(p, 0, 0))
stride = K
print(np.max(p[stride:] - p[:-stride]))

Measured memory_bytes: 33992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  int ans = -1;
  bool can_ans = false;
  int a = 0;
  int z = 0;
  for(int i = 0; i < s.length(); ++i){
    if(s[i] == 'A'){
      a = i;
      break;
    }
  }
  rep(i, s.length()){
    if(s[i] == 'Z'){
      z = i;
    }
  }
  cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){

string s;
cin>>s;
string t;
cin>>t;

bool ans=false;
if(s.size()!=t.size())ans=false;
s.append(s);
int p=0;
rep(i,s.size()){
    if(s[i]==t[p]){
        p++;
    }
    else{
        p=0;
    }
    if(p==t.size()){
        ans=true;
        break;
    }
}

if(ans){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
 return 0;
}
/*
kyoto
tokyo

Yes


abc
arc

No

aaaaaaaaaaaaaaab
aaaaaaaaaaaaaaab

Yes
*/

Measured memory_bytes: 256
import math

a, b = map(int,input().split())

flg = False
for i in range(0, 1011):
    x = math.floor(0.08 * i)
    y = math.floor(0.10 * i)
    if x == a and y == b:
        flg = True
        break
print(i) if flg else print(-1)

Measured memory_bytes: 9144
def main():
    s = input()
    for i in range(len(s)):
        if ((i + 1) % 2 == 1 and s[i] == 'L') or ((i + 1) % 2 == 0 and s[i] == 'R'):
            print('No')
            exit(0)
    print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b) {
		cout << "delicious" << endl;
	}
	else if (x >= b - a) {
		cout << "safe" << endl;
	}
	else cout << "dangerous" << endl;
}

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

int main() {
  int N, S, t;
   cin >> N;
  
  t = N;
  S = 0;
  for (int i = 0; t > 0; i++) {
    S += t % 10;
    t /= 10;
    }
  if (N % S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  string s;
  cin >> n >> s;
  int left = 0, right = 0, stack = 0;
  rep(i,n) {
    if (s[i] == '(') stack++;
    else if (s[i] == ')') {
      if (stack == 0) left++;
      else stack--;
    }
  }
  if (stack > 0) right = stack; // '('が余っている
  debug(left,right);
  string ans = "";
  if (left > 0) ans += string(left, '(');
  ans += s;
  if (right > 0) ans += string(right, ')');
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
li=["AC","WA","TLE","RE"]
l=[0]*4
for i in range(int(input())):
    n=input()
    if n=="AC":l[0]+=1
    if n == "WA": l[1] += 1
    if n == "TLE": l[2] += 1
    if n == "RE": l[3] += 1
for i in range(4):
    print(li[i],"x",l[i])



Measured memory_bytes: 9196
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = A[::-1]
MOD = int(1e9+7)
count1 = 0
count2 = 0
for i in range(N):
    for j in range(N - 1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            count1 += 1
        if B[j] < B[j-1]:
            B[j], B[j-1] = B[j-1], B[j]
            count2 += 1
print((count1 * K * (K+1) // 2 + count2 * K * (K-1) // 2) % MOD)

Measured memory_bytes: 3188
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)
{
    if(a[i]==0) zero ++;
}
if(zero >0){
     printf("0\n");
     return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

Measured memory_bytes: 2432
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]

p = sorted(p)
q = sorted(q)
tmp = sorted(p[-x:] + q[-y:] + r)
ans = sum(tmp[-(x+y):])

print(ans)

Measured memory_bytes: 113644
#include <stdio.h>
#define M 8000000
int T[M];
int main(){
	int m,n,i,j;
	for(;scanf("%d%d",&m,&n),m;){
		for(i=m;i<M;i++)T[i]=0;
		for(i=m;i<M;i++)if(T[i]==0){
			if(n--==0){printf("%d\n",i);break;}
			for(j=i;j<M;j+=i)T[j]=1;
		}
	}
	return 0;
}

Measured memory_bytes: 31848
const int isDebugMode = 0;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    string S; cin >> S;
    ll N = S.size();
    ll K; cin >> K;
    rep(i, N){
        if(i != N - 1){
            if ((26 - (S[i] - 'a') % 26) % 26 <= K){
                K -= (26 - (S[i] - 'a') % 26) % 26;
                S[i] = 'a';
            }
        }else{
            S[i] = abc[(S[i] - 'a' + K) % 26];
        }
    }
    pt(S);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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; }

int main()
{   
    int n;
    cin >> n;
    vi a(n+1);
    rep(i, n) cin >> a[i+1];

    vi b(n+1);
    for(int i = n; i > 0; i--) {
        int t = a[i];
        for(int j = i+i; j<=n; j+=i) {
            t ^= b[j];
        }
        b[i] = t;
    }

    vi ans;
    rep(i, n) if(b[i+1]) ans.push_back(i+1); 

    cout << ans.size() << endl;
    for(auto x : ans) cout << x << endl;
    
    return 0;
}


Measured memory_bytes: 5404
import numpy as np
import statistics
N = int(input())
XY = np.array([tuple(map(int, input().split())) for i in range(N)])
ans = 0
for i in range(N):
    av = statistics.mean([np.linalg.norm(XY[i]-XY[j]) for j in range(N)])
    ans += av
print(ans)

Measured memory_bytes: 27280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


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

  int N, T;
  cin >> N >> T;
  int ans = INF;
  rep(i, N) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      chmin(ans, c);
    }
  }

  if (ans == INF) {
    puts("TLE");
  } else {
    cout << ans << endl;
  }

  return 0;
}


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

using namespace std;

int n;
int a[200000];

int bit = 0;

int main(){
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int l = 0;
    int r = 0;

    bit = a[0];
    long long ans = 0;

    // for (int i = 0; i < n; ++i) {
    //     cout << i << " ";
    //     for (int k = 19; k >= 0; k--) {
    //         cout << (a[i] >> k & 1);
    //     }
    //     cout << endl;
    // }
    while(l < n - 1 && r < n - 1) {
        // cout << l << ", "<< r << endl;
        // for (int k = 19; k >= 0; k--) {
        //     cout << (bit >> k & 1);
        // }
        // cout << endl;
        if ((a[r + 1] ^ bit) != (a[r + 1] + bit)) {
            int w = r - l + 1;
            ans += w;
            // cout << "can't go, add " << w << "ans = " << ans << endl;
            bit = bit - a[l];
            l++;
            if (l > r) {
                r = l;
                bit = a[r];
            }
        } else {
            r++;
            bit = a[r] ^ bit;
        }
    }

    // cout << endl << l << " " << r << endl;
    int w = r - l + 1;
    ans += (long long)w * (w + 1) / 2;

    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        char[] c = n().toCharArray();
        Arrays.sort(c);
        pn((c[0] == c[1] && c[1] != c[2] && c[2] == c[3])?"Yes":"No");
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long IINF = (long)1e18, mod = (long)1e9+7;
    final int INF = (int)1e9, MX = (int)2e5+5;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-6;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}

Measured memory_bytes: 21588
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long K = scn.nextLong();
		Pair[] P = new Pair[N];
		for (int i = 0; i < N; i++) {
			P[i] = new Pair(scn.nextLong(), scn.nextLong());
		}
		Arrays.sort(P);
		long ans = 0;
		for (int i = 0; i < N; i++) {
			K -= P[i].getB();
			if (K <= 0) {
				ans = P[i].getA();
				break;
			}
		}
		System.out.println(ans);
	}

}

class Pair implements Comparable<Pair> {
	long a;
	long b;

	Pair(long a, long b) {
		this.a = a;
		this.b = b;
	}

	@Override
	public int compareTo(Pair o) {
		if (this.getA() > o.getA())
			return 1;
		if (this.getA() < o.getA())
			return -1;
		return 0;
	}

	long getA() {
		return this.a;
	}

	long getB() {
		return this.b;
	}
}


Measured memory_bytes: 89832
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

import copy

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    arr = copy.deepcopy(d)
    n = len(arr)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                arr[i][j] = min(arr[i][j], arr[i][k] + arr[k][j])
    return arr

def main(): 
    N = II()
    tizu = []
    for _ in range(N):
        tizu.append(LI())

    min_road = warshall_floyd(tizu)
    for i in range(N):
        for j in range(N):
            if tizu[i][j] > min_road[i][j]:  # 回り道をしたほうが速い。
                print(-1)
                return

    # 残っているのは、回り道をしても早くならないもののみ。
    # → 2点間距離と、別の町に行ってから目的地に行く距離とは、同じかそれより大きいかしかない。
    # → 経由地は1つだけ考えれば良い。

    for keiyu in range(N):
        for i in range(N):
            if i == keiyu: continue
            for j in range(N):
                if j == keiyu: continue
                if tizu[i][j] == tizu[i][keiyu] + tizu[keiyu][j]:
                    min_road[i][j] = 0
                    min_road[j][i] = 0
    
    ans = 0
    for i in range(N):
        ans += sum(min_road[i])

    print(ans//2)


main()

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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> G(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
    }

    vector<ll> points(N, 0);

    rep(i, Q) {
        int p, x;
        cin >> p >> x;
        p--;
        points[p] += x;
    }

		rep(i,N){
			for(auto e:G[i]){
				points[e] += points[i];
			}
		}

    rep(i, N) cout << points[i] << " ";
		cout << endl;
}

Measured memory_bytes: 14848
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main(){
    long M,D;
    cin>>M>>D;
    
    
    long ans=0;
    for(int m=1;m<=M;m++){
        for(int d=1;d<=D;d++){
            if(d%10>=2 && d/10>=2 &&(d%10)*(d/10)==m) ans++;
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import itertools
import bisect

input = sys.stdin.readline

def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    Acum = list(itertools.accumulate(A))
    Bcum = list(itertools.accumulate(B))
    A = A[:bisect.bisect_right(Acum, K)]
    B = B[:bisect.bisect_right(Bcum, K)]
    base = sum(A)
    books = len(A)
    ans = max(books, len(B))
    i = 0; Bflag = True
    while True:
        if Bflag:
            if i == len(B):
                break
            tmp = base + B[i]
            if tmp > K:
                if len(A) == 0:
                    break
                Bflag = False
                continue
            base = tmp
            books += 1
            i += 1
            ans = max(books, ans)
        else:
            if len(A) == 0:
                Bflag = True
            Atmp = A.pop()
            base -= Atmp
            books -= 1
            if base <= K:
                Bflag = True
    print(ans)
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 49196
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    string s; cin>>s;
    ll t; cin>>t;
    int op = 0, hand = 0, f = 0;
    char c;
    while(t--){
        cin>>op;
        if(op==1){
            hand += 1;
            hand %= 2;
        }

        if(op==2){
            cin>>f>>c;
            if(!hand){
                if(f==1) s.insert(0,1,c);
                else if(f==2) s.push_back(c);
            }
            else{
                if(f==1) s.push_back(c);
                else if(f==2) s.insert(0,1,c);
            }
        }
    }
    if(hand){
        ll n = s.size();
        loop(n){
            cout<<s[n-1-i];
        }   
        return 0;
    }
    cout<<s;
    return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int[] Enum = new int[N];
		int[] Wnum = new int[N];
		int ans = Integer.MAX_VALUE;
		if(S.charAt(0) == 'E')
			Enum[0] = 1;
		else
			Wnum[0] = 1;
		for(int i = 1; i < N; i++) {
			Enum[i] = Enum[i-1];
			Wnum[i] = Wnum[i-1];
			if(S.charAt(i) == 'E') {
				Enum[i] += 1;
			}
			else
				Wnum[i] += 1;
		}
		for(int i = 0; i < N-1; i++) {
			ans = Math.min(ans, Wnum[i] + Enum[N-1] - Enum[i+1]);
		}
		ans = Math.min(ans, Enum[N-1]-Enum[0]);
		ans = Math.min(ans, Wnum[N-2]);
		System.out.println(ans);
	}

}

Measured memory_bytes: 34116