akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n % 10 == 9 || n / 10 == 9)
                out.println("Yes");
            else
                out.println("No");
        }

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                String nextLine = null;
                try {
                    nextLine = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (nextLine == null)
                    return null;
                st = new StringTokenizer(nextLine);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23252
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int maxn = 2e5 + 5;
map<int,int>dp[maxn];
vector<int>ve[maxn];
int n;
int ans[maxn];
int dfs2(int x,int ba,int v) {
if(dp[x].count(v)) return dp[x][v];
int sm = 1;
for(int y:ve[x]) {
if(y==ba) continue;
if(y<v) sm += dfs2(y,x,v);
}
return dp[x][v] = sm;
}
void dfs1(int x,int ba,int pr,int cc) {
cc += dfs2(x,ba,max(ba,pr));
if(pr>x) cc -= dfs2(x,ba,pr);
ans[x] = cc;
for(int y:ve[x]) {
if(y==ba) continue;
dfs1(y,x,max(pr,ba),cc);
}
}
int main() {
scanf("%d",&n);
for(int i=1;i<n;i++) {
int x,y; scanf("%d%d",&x,&y);
ve[x].push_back(y);
ve[y].push_back(x);
}
for(int y:ve[1]){dfs1(y,1,1,0);}for(int i=2;i<=n;i++) printf("%d ",ans[i]);}

Measured memory_bytes: 53888
#include <stdio.h>
int main()
{
 short int a, b, c;
 scanf("%hd%hd%hd", &a, &b, &c);
 int x, y;
 x = a;
 if(x > b)
  x = b;
 if(x > c)
  x = c;
// int y;
 if(x == a)
  y = b < c ? b : c;
 else if(x == b)
  y = a < c ? a : c;
 else if(x == c)
  y = a < b ? a : b;
 printf("%d\n", x + y);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<char> T(Q);
	vector<int> D(Q);
	char c;
	for (int i = 0; i < Q; i++) {
		cin >> T[i] >> c;
		if (c == 'L') {
			D[i] = 0;
		}
		else {
			D[i] = 1;
		}
	}
	
	int l = 0;
	int r = N + 1;
 
	for (int i = Q - 1; i >= 0; i--) {
		if (D[i] == 0) {
			if (S[l + 1 - 1] == T[i]) {
				l++;
			}
 
			if (r <= N) {
				if (S[r - 1] == T[i]) {
					r++;
				}
			}
		}
		else {
			if (S[r - 1 - 1] == T[i]) {
				r--;
			}
			if (l >= 1) {
				if (S[l - 1] == T[i]) {
					l--;
				}
			}
		}
		if (l >= r)break;
 
	}
	//cerr << l << " " << r << endl;
	int res = N - l - (N + 1 - r);
	res = max((int)0, res);
 
	cout << res << endl;
}

Measured memory_bytes: 2384
//ues the stable sort-mergesort to chek quick-sort

#include<iostream>
#include<limits.h>
using namespace std;

const int MAX = 100000;

const int STN = INT_MAX;

struct Card {
	char suit;
	int num;
};
Card L[MAX / 2 + 2]; Card R[MAX / 2 + 2];
void merge(Card *A, int left, int mid, int right)
{

	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++)L[i] = A[left + i];
	for (int i = 0; i < n2; i++)R[i] = A[mid + i];
	L[n1].num = R[n2].num = STN;
	int k, j;
	k = j = 0;
	for (int i = left; i < right; i++)
	{
		if (L[k].num<=R[j].num)
			A[i] = L[k++];
		else
			A[i] = R[j++];
	}
}

void mergeSort(Card *A, int left, int right)
{
	int mid = (left + right) / 2;
	if (left + 1<right)
	{
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}


int partition(Card *A, int left, int right) //[left,right];
{
	int x = A[right].num;
	int i = left-1;

	for (int j = left; j<right; j++)
	{
		if (A[j].num<=x)
		{
		i++;
		Card t = A[i]; A[i] = A[j]; A[j] = t; 
		}
	}
	Card t = A[i + 1]; A[i + 1] = A[right]; A[right] = t;
	return i + 1;
}

void quickSort(Card *A, int left, int right)
{
	if (left<right)
	{
		int p = partition(A, left, right);
		quickSort(A, left, p - 1);
		quickSort(A, p + 1, right);
	}
}

bool isStable(Card *A, Card *B, int n)
{
	for (int i = 0; i < n; i++)
		if (A[i].suit != B[i].suit)
			return false;
	return true;
}

Card smp[MAX];
Card smp1[MAX];
int main()
{
	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> smp[i].suit >> smp[i].num;
		smp1[i] = smp[i];
	}
	mergeSort(smp, 0, n);
	quickSort(smp1, 0, n-1);
	if (isStable(smp, smp1, n))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;

	for (int i = 0; i<n; i++)
	{
		//cout << smp[i].suit << " " << smp[i].num << endl;
		cout << smp1[i].suit << " " << smp1[i].num << endl;
	}


}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int X, t;
	cin >> X >> t;
	cout << (X <= t ? 0 : X - t) << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = ['.'] * N
B = ['.'] * M
for i in range(N):
    A[i] = input()
for i in range(M):
    B[i] = input()

Ans = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        tmp = True
        for k in range(M):
            for l in range(M):
                if A[i + k][j + l] != B[k][l]:
                    tmp = False
                    break
        if tmp:
            Ans = True

if Ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 100000070

#define MAXR 100000
#define PI 3.14159265358979323846
#include <iomanip>

using namespace std;

signed main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double kaku1 = 30 * (h+(double)m/60) - 6 * m;
    if (kaku1 > 180) {
        kaku1 = 360 - kaku1;
    }

 //   cout << kaku1 << endl;

    double CC = (double)(a * a) + (double)(b * b) -
                2.0 * (double)b * (double)a * cos((double)kaku1 * PI / 180.0);

    cout << fixed << setprecision(15)<< sqrt(CC) << endl;

    return 0;
}

Measured memory_bytes: 4288
#include <stdio.h>


int main(void){
  int i,n;
  char sym[4];

  scanf("%s",sym);
  for(i=0, n=0; i<4; i++){
    if(sym[i]=='+'){
      n++;
    }else if(sym[i]=='-'){
      n--;
    }
  }
  printf("%d\n", n);
}

Measured memory_bytes: 128
//#include <iostream>
#include <stdio.h>

int main(void) {
  
  // input
  int a,b;
  scanf("%d %d",&a,&b);
  
  // output
  if( ((a*b)%2) <= 0 ){
    printf("Even");
  } else {
    printf("Odd");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  multiset<ll> a;
  rep(i,n){
    ll x;
    cin>>x;
    a.insert(x);
  }
  ll ans=0;
  while(!a.empty()){
    auto itr=a.end();
    itr--;
    ll now=*itr;
    a.erase(itr);
    ll tar=1;
    while(tar<=now) tar*=2;
    auto ser=a.lower_bound(tar-now);
    if(ser!=a.end() && *ser==tar-now){
      ans++;
      a.erase(ser);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9600
N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

if len(set(l)) != len(l):
    print("No")
    exit()

for h in range(0,len(words),2):
    if words[h] != words[h+1]:
        print("No")
        exit()
print("Yes")

    

    


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <ctime>
#include <map>
#include <queue>

using namespace std; using ll=long long; using P=pair<ll,ll>; const int INF=1e9; const ll LNF=1e18;

int main(){
  ll a,b; cin>>a>>b;
  if (a<=0&&b>=0) {
    cout<<"Zero"<<endl;
    return 0;
  }
  if (a>0){
    cout<<"Positive"<<endl;
    return 0;
  } else {
    if ((b-a+(ll)1e12)%2==1) {
      cout<<"Positive"<<endl;
      return 0;
    } else {
      cout<<"Negative"<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;


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

  cout << (s == t.substr(0, s.length()) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 0; i <= n; i++) {
		    arr[i] = sc.nextInt();
		}
		if (n == 0) {
		    if (arr[0] == 1) {
		        System.out.println(1);
		    } else {
		        System.out.println(-1);
		    }
		    return;
		} else {
		    if (arr[0] != 0) {
		        System.out.println(-1);
		        return;
		    }
		}
		long[] sums = new long[n + 1];
		sums[n] = arr[n];
		for (int i = n - 1; i >= 0; i--) {
		    sums[i] = sums[i + 1] + arr[i];
		}
		long total = 0;
		long current = 1;
		for (int i = 0; i < n; i++) {
		    total += current;
		    current -= arr[i];
		    if (current <= 0) {
		        System.out.println(-1);
		        return;
		    }
		    current = Math.min(current * 2, sums[i + 1]);
		}
		if (current != arr[n]) {
		    System.out.println(-1);
		    return;
		}
		total += current;
		System.out.println(total);
	}
}


Measured memory_bytes: 59240
#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>
#include <unistd.h>

using namespace std;

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

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[300005],y[300005],z[100005];
ll dp[500005][15];
char s[500005];

int main(){
	cin >> s;
    n = strlen(s);
    dp[0][0] = 1;
    for(i=0;i<n;i++){
        for(j=0;j<13;j++){
            if(s[i] == '?'){
                for(k=0;k<=9;k++){
                    dp[i+1][(j * 10 + k) % 13] += dp[i][j];
                    dp[i+1][(j * 10 + k) % 13] %= mod;
                }
            }else{
                dp[i+1][(j * 10 + (s[i] - '0')) % 13] += dp[i][j];
                dp[i+1][(j * 10 + (s[i] - '0')) % 13] %= mod;
            }
        }
    }
    for(i=0;i<n;i++){
        //p(dp[i][0]);
    }
   // line;
    p(dp[n][5]);
    
	return 0;
}



Measured memory_bytes: 24960
n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
ans = []
st = 0
en = k
(n-k).times do 
    if a[st] < a[en]
        puts "Yes"
    else
        puts "No"
    end
    st += 1
    en += 1
end

Measured memory_bytes: 36000
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int w,a,b; cin >> w >> a >> b;
    if((b<=a && a<=b+w) || (a<=b && b<=a+w)) pr(0);
    else if(b>a) pr(abs(b-a-w));
    else if(b<a) pr(abs(a-b-w));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	
	void dfs(vector<int> adj[], bool vis[], int &count, int s)
	{
	    vis[s] =true;
	    count++;
	    for(auto x: adj[s])
	    {
	        if(!vis[x])
	        dfs(adj, vis, count, x);
	    }
	}
	
	int main()
	{
		std::ios::sync_with_stdio(false);
		int n, e;
		cin>>n>>e;
		vector<int> adj[n];
		for(int i =0;i<e;i++)
		{
		    int x, y;
		    cin>>x>>y;
		    x--; y--;
		    adj[x].push_back(y);
		    adj[y].push_back(x);
		}
		bool vis[n]= {false};
		int res = INT_MIN;
		for(int i =0;i<n;i++)
		{
		    int count =0;
		    if(!vis[i])
		    {
		        dfs(adj, vis , count, i);
		    }
		    res =max(res, count);
		}
            cout<<res<<endl;
		return 0;
	
	}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int A, B, M;
    cin >> A >> B >> M;
    int a[100005], b[100005], c[100005], x[100005], y[100005];
    REP(i, A)
        cin >> a[i];
    REP(i, B)
        cin >> b[i];
    REP(i, M)
        cin >> x[i] >> y[i] >> c[i];
    int price = 300000;
    REP(i, M)
        if(a[x[i]-1] + b[y[i]-1] - c[i] < price)
            price = a[x[i]-1] + b[y[i]-1] - c[i];
    sort(a, a + A);
    sort(b, b + B);
    if(a[0] + b[0] < price)
        price = a[0] + b[0];
    cout << price << endl;
    return 0;
}



Measured memory_bytes: 2176
x, y = list(map(int, input().split()))


if (4*x - y) % 2 != 0 or (4*x - y) < 0:
  print('No')
elif (y-2*x) % 2 != 0 or (y-2*x) < 0:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9176
#include <iostream>
using namespace std;
#define NUM 100
#define rep(i,a,n) for(i = a ; i < n; i++) 

void trace(int[],int);

int main(void) {

  int i, j, a, N;
  int T[NUM] = {};

  cin >> a;

  rep(i,0,a) {

    cin >> T[i];

  }

  trace(T,a);

  rep(i,1,a) {

    N = T[i];
    j = i - 1;

    while (j >= 0 && T[j] > N) {

      T[j + 1] = T[j];
      j--;

    }

    T[j + 1] = N;
    trace(T,a);

  }

  return 0;

}

void trace(int T[],int n) {

  int i;

  rep(i,0,n) {
    if(i > 0) {
      cout << " ";
    }

    cout << T[i];

  }

  cout << endl;

}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, x;
    ll sum = 0;
    cin >> n >> x;
    vector<int> a(n);
    rep (i, n) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum == x) {
        cout << n << endl;
        return 0;
    }
    int ans = 0;
    sort(a.begin(), a.end());
    rep (i, n) {
        x -= a[i];
        if (x < 0) {
            ans = i;
            break;
        }
    }
    if (x > 0) ans = n - 1;
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000



int main(){
	
	int N;
	long long x;
	cin>>N>>x;
	vector<long long> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	
	vector<vector<long long>> mini(N,vector<long long>(N,Inf));//mini[i][j] i番目要素から直前j個数のmin
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(j==0){
				mini[i][j] = a[i];
				continue;
			}
			else{
				int k = i-j;
				if(k<0)k+=N;
				mini[i][j] = min(mini[i][j-1],a[k]);
			}
		}
	}
	
	long long ans = Inf;
	
	for(int i=0;i<N;i++){
		long long temp = i*x;
		for(int j=0;j<N;j++){
			temp += mini[j][i];
		}
		ans = min(ans,temp);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

#define sz(s) (int)(s).size()
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 100000007

using namespace std;

typedef long long ll;
vector <ll> vll;
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}


int main()
{	
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c)
	{
		return cout << "Yes", 0;
	}
	if (a == c && c != b)
	{
		return cout << "Yes", 0;	
	}
	if (c == b && a != b)
	{
		return cout << "Yes", 0;
	}
	cout << "No";









	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let o = read::<String>().chars().collect::<Vec<_>>();
    let e = read::<String>().chars().collect::<Vec<_>>();
    let mut v = vec![];
    for i in 0..o.len() {
        v.push(o[i]);
        if i != e.len() {
            v.push(e[i]);
        }
    }
    let ans = v.into_iter().collect::<String>();
    println!("{}", ans);
}

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


Measured memory_bytes: 4352
N,X=map(int,input().split())
A=[int(x) for x in input().split()]
D=[]

def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)


for i in range(N):
  D.append(abs(A[i]-X))

ans=min(D)
for i in range(len(D)):
  ans=gcd(ans,D[i])
  
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll c[22];
ll a[22][22];

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

	ll n, m, x;cin >> n >> m >> x;
	REP(i, n){
		cin >> c[i];
		REP(j, m)cin >> a[i][j];
	}

	ll ans = INF;
	REP(mask, (1<<n)) {
		vector<ll> seica(m);
		ll cost = 0;
		REP(i, n){
			if(!(mask & (1<<i)))continue;
			REP(j, m)seica[j] += a[i][j];
			cost += c[i];
		}

		bool flag = true;
		REP(i, m)if(seica[i] < x)flag = false;
		if(flag)ans = min(ans, cost);
	}

	if(ans == INF)cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p )
{
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v )
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu ()
{
    cerr << endl;
}

template <typename T>
void faltu( T a[], int n )
{
    for(int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


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

void f()
{
    string s,t,p;
    cin>>s>>t;

    int s1=sz(s),t1=sz(t),mn=INT_MAX,cnt;

    for(int i=0; i<s1; i++)
    {
        p=s.substr(i,t1);
        if(sz(p)==t1)
        {
            cnt=0;
            for(int j=0; j<t1; j++)
            {
                if(t[j]!=p[j])
                {
                    cnt++;
                }
            }
            mn=min(mn,cnt);
        }
    }
    cout<<mn<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = pow(10, 9) + 7;
const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

vector<vector<ll>> G;
vector<bool> visited;
ll V0;
vector<ll> dp;
void dfs(ll V, ll cnt)
{
  if (visited.at(V))
  {
    if (V0 == V)
      chmin(dp.at(V), cnt);
    return;
  }
  visited.at(V) = true;

  for (auto nv : G.at(V))
  {
    dfs(nv, cnt + 1);
  }
}

ll V1;
ll K;
void dfsans(ll V, vector<ll> ans)
{
  if (visited.at(V))
  {
    if (V == V1 && ans.size() == K)
    {
      for (ll i = 0; i < K; i++)
      {
        cout << ans.at(i) + 1 << endl;
      }
      exit(0);
    }
    else
      return;
  }
  visited.at(V) = true;

  ans.push_back(V);

  for (auto nv : G.at(V))
  {
    dfsans(nv, ans);
  }
}

int main()
{
  ll N, M;
  cin >> N >> M;
  G = vector<vector<ll>>(N);
  for (ll i = 0; i < M; i++)
  {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    G.at(a).push_back(b);
  }

  dp = vector<ll>(N, INF);
  for (ll i = 0; i < N; i++)
  {
    visited = vector<bool>(N, false);
    V0 = i;
    dfs(i, 0);
  }

  K = INF;
  for (ll i = 0; i < N; i++)
  {
    if (chmin(K, dp.at(i)))
      V1 = i;
  }
  
  if (K == INF)
    FINALANS(-1);
  
  cout << K << endl;

  visited = vector<bool>(N, false);
  vector<ll> hoge(0);
  dfsans(V1, hoge);
}

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


 
int main() {
    long long int n,m,temp,i,l,cons1=0;
    string s;
    cin>>n>>m>>s;
    long long int t[s.length()]={0};
    temp=n;
    while(1)
    {
        l=m;
        if((temp-m)>0)
        {
            while(s[temp-l]!='0')
            {
                --l;
            }
            if(l==0)
            {
                break;
            }
            t[i++]=l;
            temp-=l;
            
        }
        else
        {
            t[i]=temp;
            break;
        }
        
    }
    if(l==0)
    cout<<-1;
    else
    {
    for(l=i;l>=0;--l)
    cout<<t[l]<<" ";
    }
    
    
 
   
        
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <queue>
using namespace std;
struct P{int x, y; P(){} P(int x_,int y_):x(x_),y(y_){}};
int main()
{
	const int dx[12] = {0, 0, 0, -3, -2, -1, 1, 2, 3, 0, 0, 0},
			  dy[12] = {-3, -2, -1, 0, 0, 0, 0, 0, 0, 1, 2, 3};
	int n;
	P s;
	cin >> n;
	for (int k = 0; k < n; ++k)
	{
		char f[8][9] = {""};
		for (int i = 0; i < 8; ++i) cin >> f[i];
		cin >> s.x >> s.y;
		queue<P> q; q.push(s);
		while (!q.empty())
		{
			P w(q.front().x, q.front().y); q.pop();
			f[w.y-1][w.x-1] = '0';
			for (int i = 0; i < 12; ++i)
			{
				P t(w.x+dx[i], w.y+dy[i]);
				if (1 <= t.x && t.x <= 8 && 1 <= t.y && t.y <= 8 && f[t.y-1][t.x-1] == '1') q.push(t);
			}
		}
		cout << "Data " << k+1 << ":" << endl;
		for (int i = 0; i < 8; ++i) cout << f[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
from heapq import heappush as hp, heappop as hpp
h = []
dp = [0]*n
for i in range(n):
    hp(h, a[i])
v = 0
for i in range(n, 2*n):
    hp(h, a[i])
    tmp = hpp(h)
    v += (a[i]-tmp)
    dp[i-n] = v
dp.insert(0,0)
h = []
dp2 = [0]*n
for i in range(2*n, 3*n):
    hp(h, -a[i])
v = 0
for i in range(2*n-1, n-1, -1):
    hp(h, -a[i])
    tmp = hpp(h)
    v += (a[i]+tmp)
    dp2[2*n-1-i] = v
dp2.insert(0,0)
ans = sum(a[:n]) - sum(a[2*n:]) + max((dp[i]-dp2[n-i]) for i in range(n+1))
print(ans)

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

int main()
{
    ios::sync_with_stdio(false);
    int a, b; 

    cin >> a >> b;

    if(a>=13){
        cout<<b<<endl;
        return 0;
    }
    else if(a>=6 and a<=12){
        cout<<b/2<<endl;
        return 0;
    }else{
        cout<<0<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    string S;
    cin >> S;
    long long int ans = 0;
    int key = S.size() - 1;

    for (int i = S.size() - 1; i >= 0; i--) {
        if (S[i] == 'B') {
            ans += key - i;
            key--;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 640
H,W=map(int, input().split())
A=[list(map(int, input().split())) for _ in range(H)]
ans=0
ANS=[]
for i in range(H):
    for j in range(W-1):
        if A[i][j]%2==1:
            ans+=1
            A[i][j]-=1
            A[i][j+1]+=1
            ANS.append([str(i+1), str(j+1), str(i+1), str(j+1+1)])
for i in range(W):
    b=[k[i] for k in A[0:H]]
    for j in range(H-1):
        if b[j]%2==1:
            ans+=1
            b[j]-=1
            b[j+1]+=1
            A[j][i]-=1
            A[j+1][i]+=1
            ANS.append([str(j+1), str(i+1), str(j+1+1), str(i+1)])
print(ans)
for i in range(len(ANS)):
    print(' '.join(ANS[i]))

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

signed main(){
    string s;cin>>s;
    int ans=700;
    for(auto c:s){
        ans+=100*(c=='o');
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.floor(n/4) + 1:
            if (f[1] + 1) % n == 0:
                f[1] = n
            else:
                f[1] = (f[1] + 1) % n
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
else:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n

Measured memory_bytes: 9296
import sys
from itertools import permutations
def input(): return sys.stdin.readline().strip()


def main():
    a, b, c = map(int, input().split())
    ans = 0
    for p, q, r in list(permutations([a, b, c])):
        ans = max(ans, 10 * p + q + r, p + 10 * q + r)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
//cout << std::fixed << std::setprecision(15) << y << endl;

int main(){
  ll N;  cin >> N;
  VL a(N); 
  rep(i,0,N){
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(ALL(a));

  ll ans = INF;  ll b;
  if(N % 2 == 0) b = (a[N/2]+a[N/2-1])/2;
  else b = a[(N-1)/2];
  rep(i,b-1,b+2){
    ll tmp = 0; 
    rep(j,0,N){
      tmp += abs(a[j] - i);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4820
def main():
    N = int(input())
    A = list(map(int, input().split()))
    r = []
    ma, mi = max(A), min(A)
    if ma * mi < 0:
        if abs(mi) > abs(ma):
            ma = mi
        mi = A.index(ma)
        for i, a in enumerate(A):
            if ma * a < 0:
                r.append((mi, i))
                A[i] += ma

    if min(A) >= 0:
        for i in range(1, N):
            if A[i] < A[i - 1]:
                A[i] += A[i - 1]
                r.append((i - 1, i))
    else:
        for i in reversed(range(N - 1)):
            if A[i] > A[i + 1]:
                A[i] += A[i + 1]
                r.append((i + 1, i))

    print(len(r))
    for rx, ry in r:
        print(rx + 1, ry + 1)

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    //cout.tie(NULL);
    string s;
    cin>>s;

    int cnt=0;
    int x=s[0]-'0';

    for(int i=1;i<(int)s.length();i++)
    {
        x^=1;

        if(x!=s[i]-'0')
                cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define db double
#define ld long db
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}

signed main()
{
	ri n=read(),k=read(),x=0;
	while(n){
		n/=k;++x;
	}cout<<x;
	return 0; 
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n, m;
    cin >> n >> m;

    vector<lint> x(m);
    rep(i, m){
        cin >> x[i];
    }
    SORT(x);

    vector<lint> diff(m - 1);
    rep(i, m - 1){
        diff[i] = x[i + 1] - x[i];
    }
    SORT(diff);

    lint ans = 0;
    rep(i, m - n){
        ans += diff[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	int n;
	cin >> n;
	vi a(n);
	trav(x, a) cin >> x;

	vector<ll> pre(n+1);
	rep(i,0,n) pre[i+1] = pre[i] + a[i];

	map<ll, int> cnt;

	trav(x, pre) ++cnt[x];

	ll ans = 0;

	trav(pa, cnt){
		ans += ll(pa.second) * (pa.second - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define int long long
#define fo(i, n) for(int i = 1; i <= (n); i ++)
#define out(x) cout << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
template<typename tp> inline void arr(tp *a, int n) {
  for(int i = 1; i <= n; i ++)
    cout << a[i] << " ";
  puts("");
}
const int SET = 1 << 16;
int n, f[SET], bt[SET], cnt[233], has[233333], mp[SET];
const int inf = 1e7;
inline int dfs(int st) {
  if(st == 0) return 0;
  if(mp[st] != -1) return mp[st];
  int ans = inf;
  for(int i = st; i; i = (i - 1) & st) if(f[i] == 0) {
//    cout << bt[i] - 1 + dfs(st ^ i) << " " << i << "\n";
    ans = min(ans, bt[i] - 1 + dfs(st ^ i));
  }
  return mp[st] = ans;
}

main(void) {
  read(n);
  for(int i = 1; i <= n - 1; i ++) {
    int x, y, w; read(x); read(y); read(w);
    ++ x; ++ y;
    has[x] ^= w; has[y] ^= w;
  }
  for(int i = 1; i <= n; i ++)
    cnt[has[i]] ++;
  int st = 0;
  int ans = 0;
  for(int i = 1; i < (1 << 4); i ++) if(cnt[i]) {
    ans += cnt[i] / 2;
    cnt[i] &= 1;
    if(cnt[i]) st |= 1 << (i - 1);
  }
  for(int i = 0; i < (1 << 15); i ++) {
    int now = 0;
    for(int k = 0; k < 15; k ++)
      if(i >> k & 1)
        now ^= (k + 1);
    f[i] = now;
    bt[i] = __builtin_popcount(i);
  }
//  cout << ans << "\n";
  memset(mp, -1, sizeof mp);
//  st = 1;
  int res = dfs(st);
  cout << res + ans << "\n";
}

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

int main(){
    int N;
    cin >> N;
    int AC=0, WA=0, TLE=0, RE=0;
    rep(i, N){
        string judge;
        cin >>  judge;
        if (judge == "AC") AC ++;
        else if (judge == "WA") WA++;
        else if (judge == "TLE") TLE++;
        else if (judge == "RE") RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3616
package main

import (
  "fmt"
)
func main(){
  var A,B,C,D int
  fmt.Scan(&A,&B,&C,&D)
  l := A+B
  r := C+D
  if r < l{
    fmt.Println("Left")
  }else if r == l{
    fmt.Println("Balanced")
  }else{
    fmt.Println("Right")
  }
}


Measured memory_bytes: 512
n = int(input())
wa = 0
for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        wa += i
print(wa)


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

int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  for (int i=1; i<n; i++) {
    int a;
    cin >> a;
    num[a-1]++;
  }
  for (int i=0; i<n; i++) {
    cout << num[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3968
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << ln;
    } else {
        cout << "No" << ln;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Node {

    int parent;
    int depth;
    String type;
    int[] childlen;

    Node(int[] c) {
        childlen = c;
        parent = -1;
    }

    static void setParents(Node[] tree, int n) {
        for(int i = 0; i < n; i++) {
            for(int id : tree[i].childlen) {
                tree[id].parent = i;
            }
        }
    }

    void setInfo(Node[] tree) {
        depth = 0;
        int tmp = parent;
        while(tmp >= 0) {
            depth++;
            tmp = tree[tmp].parent;
        }

        if(depth == 0) {
            type = "root";
        }else if(childlen.length == 0) {
            type = "leaf";
        }else {
            type = "internal node";
        }
    }

    void printInfo(int id) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < childlen.length; i++) {
            if(i != 0) sb.append(", ");
            sb.append(childlen[i]);
        }

        System.out.printf("node %d: parent = %d, depth = %d, %s, [%s]\n",
                id, parent, depth, type, sb.toString());
    }
    
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        Node[] tree = new Node[n];
        for(int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int k = sc.nextInt();
            int[] c = new int[k];
            for(int j = 0; j < k; j++) {
                c[j] = sc.nextInt();
            }
            tree[id] = new Node(c);
        }

        Node.setParents(tree, n);
        for(int i = 0; i < n; i++) {
            tree[i].setInfo(tree);
            tree[i].printInfo(i);
        }

        sc.close();
    }
}



Measured memory_bytes: 196512
N,M=map(int,input().split())
like = [0]*M

for _ in range(N):
    items = list(map(int,input().split()))
    for i in range(1,len(items)):
        like[items[i]-1] += 1

ans = 0
for i in range(M):
    if like[i] == N:
        ans += 1

print(ans)

Measured memory_bytes: 62624