akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

long *tree[100010];

int main(void) {

  long n,m,a,b;
  scanf("%ld %ld", &n, &m);
  long tree_s[n+1];
  for (long i = 1; i <= n; i++) {
    tree_s[i] = 0;
  }
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a] = realloc(tree[a], sizeof(long)*(tree_s[a]+1));
    tree[a][tree_s[a]] = b;
    tree_s[a]++;
    tree[b] = realloc(tree[b], sizeof(long)*(tree_s[b]+1));
    tree[b][tree_s[b]] = a;
    tree_s[b]++;
  }
  long visited[n+1],que[n];
  visited[1] = 1;
  for (long i = 2; i <= n; i++) {
    visited[i] = 0;
  }
  que[0] = 1;
  long head = 1,cur,next,start = 0,end = 0,tail = 0,count = 0;
  int flag;
  while (1) {
    flag = 0;
    for (long i = start; i <= end; i++) {
      cur = que[i];
      for (long j = 0; j < tree_s[cur]; j++) {
        next = tree[cur][j];
        if (visited[next] == 1) {
          continue;
        }
        visited[next] = 1;
        tail++;
        que[tail] = next;
        flag = 1;
      }
    }
    if (flag == 1) {
      start = end+1;
      end = tail;
    } else {
      if (tail == n-1) {
        break;
      }
      for (long i = head+1; i <= n; i++) {
        if (visited[i] == 0) {
          head = i;
          visited[i] = 1;
          tail++;
          que[tail] = i;
          start = tail;
          end = tail;
          count++;
          break;
        }
      }
    }
  }
  printf("%ld\n", count);

  return 0;
}

Measured memory_bytes: 7784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            var nab = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            if((nab[2]-nab[1]-1)%2 > 0)
            {
                Console.WriteLine("Alice");
            }
            else
            {
                Console.WriteLine("Borys");
            }



        }
    }
}


Measured memory_bytes: 13268
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

bool isp[100001];
bool B[100001];
int imos[100001];
int q,l,r;
int main()
{
	for(int i=2;i<100001;i++) isp[i]=1;
	cin>>q;
	for(int i=2;i<100001;i++){
		if(!isp[i]) continue;
		if(i*2-1<=100000) B[i*2-1]=1;
		for(int j=2*i;j<=100000;j+=i){
			isp[j]=0;
		}
	}
	for(int i=2;i<100001;i++){
		if(isp[i]&&B[i]) imos[i]=1;
	}
	rep1(i,100000) imos[i]+=imos[i-1];
	
	rep(i,q){
		cin>>l>>r;
		cout<<imos[r]-imos[l-1]<<endl;
	}
}

Measured memory_bytes: 1280
use proconio::marker::*;
use proconio::*;
use std::cmp::min;

const M: i64 = 1000000007;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    let mut ans: i64 = 0;
    let mut d = vec![0; n];
    let mut all: i64 = a.iter().sum();
    d[0] = all;

    for i in 1..a.len() {
        d[i] = (d[i - 1] - a[i - 1]).rem_euclid(M);
    }

    for i in 0..a.len() - 1 {
        ans = (ans + a[i] * d[i + 1]).rem_euclid(M);
    }

    println!("{}", ans);
}


Measured memory_bytes: 7136
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll h,w; char ar[1001][1001]; ll dp[1001][1001];
ll findans(ll i,ll j){
	if(i>=h||j>=w) return 0;
	if(i==h-1&&j==w-1) return 1;
	if(ar[i][j]=='#') return 0;
	if(dp[i][j]!=-1){
		return dp[i][j]%mod;
	}
	ll a,b;
	a=findans(i+1,j)%mod;
	b=findans(i,j+1)%mod;
	return dp[i][j]=(a+b)%mod;
}
int main(){

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

	ll i,j,k,l;
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>ar[i];
	}
	memset(dp,-1,sizeof(dp));
	ll an=findans(0,0)%mod;
	cout<<an;
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;
typedef pair<ll, string> PLS;

int N;

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

int main(){
	while (cin >> N&&N){
		vector<P> vp;
		vp.push_back(P(0, 0));
		REP(i, N - 1){
			int n, d;
			cin >> n >> d;
			vp.push_back(P(vp[n].first + dx[d], vp[n].second + dy[d]));
		}
		ll minx = INF, miny = INF, maxx = -INF, maxy = -INF;
		REP(i, vp.size()){
			minx = min(minx, vp[i].first);
			miny = min(miny, vp[i].second);
			maxx = max(maxx, vp[i].first);
			maxy = max(maxy, vp[i].second);
		}
		cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;
	}
}

Measured memory_bytes: 3100
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.D
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			long n = cin.NextLong();
			var p = new Dictionary<long, int>();
			long i = 2;
			long tmp = n;
            while (i * i <= n)
            {
				if(tmp % i == 0)
                {
					tmp /= i;
					if (p.ContainsKey(i)) p[i]++;
					else p.Add(i, 1);
                }
                else
                {
					i++;
                }
            }
			if (tmp != 1) p.Add(tmp, 1);
			int ans = 0;
            foreach (var e in p)
            {
				var x = e.Value;
				int j = 1;
                while (x >= j)
                {
					x -= j;
					ans++;
					j++;
                }
            }

            Console.WriteLine(ans);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 27868
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    long long a[n], b[n], c[n];
    int al=0, bl=0;
    int i,j;
    for(i=0;i<n;i++){
        cin >> j;
        if(j<0){
            b[bl]=-j;
            c[i]=-j;
            bl++;
        }else{
            a[al]=j;
            c[i]=j;
            al++;
        }
    }
    std::sort(a, a + al);
    std::sort(b, b + bl);
    long long sum=1;
    if((k==n)&&(bl%2==1)){
        for(i=0;i<al;i++){
            sum = (sum*a[i])%1000000007;
        }
        for(i=0;i<bl;i++){
            sum = (sum*b[i])%1000000007;
        }
        sum = (1000000007-sum)%1000000007;
    }else if((al==0)&&(k%2==1)){
        for(i=0;i<k;i++){
            sum = (sum*b[i])%1000000007;
        }
        sum = (1000000007-sum)%1000000007;
    }else{
        int pc = 0;
        if(k>bl){
            while(k>bl){
                sum = (sum*a[al-1])%1000000007;
                al--;
                k--;
            }
        }
        if(k%2==1){
            sum = (sum*a[al-1])%1000000007;
            al--;
            k--;
        }
        for(i=0;i<k;i++){
            if(al-pc*2-2<0)break;
            if(bl-k+pc*2+1>=bl)break;
            if(a[al-pc*2-1]*a[al-pc*2-2] < b[bl-k+pc*2]*b[bl-k+pc*2+1]){
                break;
            }
            pc++;
        }
        for(i=al-pc*2;i<al;i++){
            sum = (sum*a[i])%1000000007;
        }
        for(i=bl-k+pc*2;i<bl;i++){
            sum = (sum*b[i])%1000000007;
        }

    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 6772
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
//#define MXN 300000
#define N 100005
int main(){
    int n,L;
    scanf("%d %d",&n,&L);
    int a[100005];
    LL tot=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        tot+=a[i];
    }
    for(int i = 1;i<n;i++){
        if(a[i]+a[i+1]>=L){
            printf("Possible\n");
            for(int j=1;j<i;j++)
            printf("%d\n",j);
            for(int j=n-1;j>=i;j--)
            printf("%d\n",j);
            return 0;
        }
    }
    printf("Impossible\n");
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <utility>
#include <tuple>
#include <string>
#include <vector>
using namespace std;
int main(){
    int n, p, i;
    string s;
    cin >> n;
    vector< tuple<string, int, int> > shop;
    for(i=0;i<n;i++){
        cin >> s >> p;
        p *= -1;
        shop.push_back(make_tuple(s, p, i+1));
    }
    sort(shop.begin(), shop.end());
    for(auto t : shop){
        cout <<  get<2>(t) << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

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

    ll ret = 1, con = 1;
    FOR(i, 1, n) {
        if(a[i-1] >= a[i]) {
            con++;
        } else {
            con = 1;
        }
        chmax(ret, con);
    }
    cout << ret-1 << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll; 
typedef pair<int, int> P; 
const int mod = 1e9 + 7;
const int N = 2e6 + 5;
int n, m, a[N];
ll ans;
int  main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n, greater<int>());
	for (int i = m; i < n; i++)
		ans += a[i];
	printf("%lld\n", ans);
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
#define pir pair<int,int>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
#define rsort(x,y) sort(x,y),reverse(x,y)
#define fr first
#define se second
using namespace std;
typedef long long ll;
const int Maxn=2100000;
const int inf=0x3f3f3f3f;

signed main() {
    // freopen("test.in","r",stdin);
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int temp=0;
    while(b<=a) b<<=1,temp++;
    while(c<=b) c<<=1,temp++;
    scanf("%d",&a);
    if(a>=temp) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3656
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

void no() { cout << "No" << endl; exit(0); }

int N, A, B, C, D;
string S;

char ok[202020];

int main() {
    cin >> N >> A >> B >> C >> D >> S;
    --A; --B; --C; --D;

    if (D < C) {
        for (int i = B; i < D; ++i)
            if (S[i] == '#' && S[i+1] == '#') no();

        bool ok = false;
        for (int i = B; i <= D; ++i) {
            if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
                S[i] = '#';
                ok = true;
                break;
            }
        }
        if (!ok) no();

        for (int i = A; i < C; ++i)
            if (S[i] == '#' && S[i+1] == '#') no();
    } else {
        for (int i = A; i < C; ++i)
            if (S[i] == '#' && S[i+1] == '#') no();
        for (int i = B; i < D; ++i)
            if (S[i] == '#' && S[i+1] == '#') no();
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>                                                             
                                                                                
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  int H, W;                                                                     
  while (true) {                                                                
    cin >> H;                                                                   
    cin >> W;                                                                   
    if (H==0 && W==0) {                                                         
      break;                                                                    
    }                                                                           
    for (int i=0; i<H; i++) {                                                   
      for (int j=0; j<W; j++) {                                                 
        cout << "#";                                                            
      }                                                                         
      cout << endl;                                                             
    }                                                                           
    cout << endl;                                                               
  }                                                                             
}                                                                               
                                                                                
                                                                                
                                                                                
                                

Measured memory_bytes: 3096
#include <iostream>
#include <string>

using namespace std;

int main(){
    string S;
    cin >> S;

    if(S == "SUN"){
        cout << 7;
    }else if(S == "MON"){
        cout << 6;
    }else if(S == "TUE"){
        cout << 5;
    }else if(S == "WED"){
        cout << 4;
    }else if(S == "THU"){
        cout << 3;
    }else if(S == "FRI"){
        cout << 2;
    }else if(S == "SAT"){
        cout << 1;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
v = list(map(int,input().split()))
v.sort()
a = 0
for i in range(N-1):
    v.sort()
    a = (v[0]+v[1])/2
    v[0] = v[0]+2000
    v[1] = v[1]+2000
    v.append(a)
    
print(a)

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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>p(n);
  for(int i = 0;i < n;i++){
    cin >> p[i];
    p[i]--;
  }
  for(int i = 0;i < n-1;i++){
    if(p[i] == i){
      int a,b;
      a = p[i];
      b = p[i+1];
      p[i] = b;
      p[i+1] = a;
      ans++;
    }
  }
  if(p[n-1] == n-1) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A[111], B[111];

  std::cin >> N;

  for (int i = 0; i < N - 1; i ++)
    std::cin >> B[i];

  memset(A, 0x3e, sizeof(A));

  for (int i = 0; i < N - 1; i ++) {
    A[i    ] = std::min(A[i    ], B[i]);
    A[i + 1] = std::min(A[i + 1], B[i]);
  }

  std::cout << std::accumulate(A, A + N, 0LL) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define EPS 1e-10
#define EQ(a,b) (a - EPS < b && b < a + EPS)
int nijou(int a, int b){
    return (a - b)*(a - b);
}
int main(void){
    int N, D, ans = 0, i, j, k;
    cin >> N >> D;

    vector<vector<int> > X(N, vector<int>(D));
    for(i = 0; i < N; i++){
        for(j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }

    for(i = 0; i < N - 1; i++){
        for(j = i + 1; j < N; j++){
            double dist = 0;
            for(k = 0; k < D; k++){
                dist += nijou(X[i][k], X[j][k]);
            }
            dist = sqrt(dist);
            if (EQ(fmod(dist, 1), 0.0)) ans++;
        }
    }
    cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    ll k;
    cin >> k;
    const int n = 50;
    vector<ll> a(n, 49 + k/n);
    k %= n;
    rep(i, k) {
        a[i] += 50;
        rep(j, n) {
            if (i == j) continue;
            a[j]--;
        }
    }
    cout << n << endl;
    rep(i, n) cout << a[i] << (i == n-1 ? '\n' : ' ');
}


Measured memory_bytes: 3664
# https://atcoder.jp/contests/abc146/tasks/abc146_a



s = gets.chomp
if s=="SUN"
    puts 7
elsif s=="MON"
    puts 6
elsif s=="TUE"
    puts 5
elsif s=="WED"
    puts 4
elsif s=="THU"
    puts 3
elsif s=="FRI"
    puts 2
elsif s=="SAT"
    puts 1
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n;
class edge{
public:
	Int cost;
	size_t from, to;
	edge(Int c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
using edges = vector<edge>;
using graph = vector<edges>;
void readgraph(graph &g, size_t E, bool D, bool C, bool Z){ // E:num_of_edges, D:directed, C:costed, Z:already 0-indexed
	for(size_t i=0; i<E; ++i){
		edge e(1, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		if(!Z){
			--e.from;
			--e.to;
		}
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
void calc_distance(graph &g, vector<Int> &d, Int s){
	d.assign(g.size(), 1e8);
//	for(Int i=0; i<n; ++i)
//		cout << d[i] << " \n"[i+1==n];
	d[s] = 0;
	queue<Int> q;
	q.push(s);
	while(!q.empty()){
		Int p = q.front(); q.pop();
		for(auto e:g[p])
			if(d[e.to] == 1e8){
				d[e.to] = d[p]+1;
				q.push(e.to);
			}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	graph g(n);
	readgraph(g, n-1, false, false, false);
	vector<Int> d(n);
	calc_distance(g, d, 0);
	Int l=0;
	for(Int i=0; i<n; ++i)
		if(d[i] > d[l])
			l = i;
//	for(Int i=0; i<n; ++i)
//		cout << i << "  " << d[i] << "\n";
	calc_distance(g, d, l);
	Int r = 0;
	for(Int i=0; i<n; ++i)
		r = max(r, d[i]);
//	for(Int i=0; i<n; ++i)
//		cout << i << "  " << d[i] << "\n";
//	for(Int i=0; i<n; ++i)
//		for(Int j=0; j<g[i].size(); ++j)
//			cout << g[i][j].to << " \n"[j+1==g[i].size()];
//	cout << l << " " << r << "\n";
	if(r % 3 == 1) cout << "Second\n";
	else cout << "First\n";
}

Measured memory_bytes: 19884
i,j=map(int,input().split())
if j-i>=2019:
  print(0)
elif j%2019<i%2019:
  print(0)
else:
  min=2018
  for p in range(i,j):
    for q in range(p+1,j+1):
      if ((p%2019)*(q%2019))%2019<min:
        min=((p%2019)*(q%2019))%2019
  print(min)

Measured memory_bytes: 3064
n = int(input())
N = str(n) + ':'
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
print(N, *prime_factorize(n))


Measured memory_bytes: 5596
#include<stdio.h>
 
#define N 2000000
 
int arr[N];
int n;
 
void count(int A[], int k){
  int ca[k],i,j;
  i = k;
  for(; i>=0 ; i--) ca[i] = 0;
  for(j=1; j<=n; j++) ca[A[j]]++;
  for(i=1; i<k; i++) ca[i] += ca[i-1];
  for(j=n; j>=1; j--){
    arr[ca[A[j]]] = A[j];
    ca[A[j]]--;
  }
}
 
int main(int argc,char *argv[]){
  int k=0,i;
  int A[N];
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d",&A[i]);
  }
  k=A[1];
  for(i=2; i<=n; i++){
      if(k < A[i]) k = A[i];
  }
  count(A, k+1);
  for(i=1; i<n; i++) {
    printf("%d ",arr[i]);
  }
  printf("%d\n",arr[i]);
  return 0;
}

Measured memory_bytes: 16260
/* ITP1_7_D */
#include <stdio.h>

/* ????????????????????¢??° */
unsigned long get_maltiplication(short n, short m, short l, short mat1[n][m],
	short mat2[m][l], short current_n, short current_l);

int main(void)
{
	// ??????????¬????
	short n = 0, m = 0, l = 0;
	
	// ?¬?????????????
	scanf("%hd %hd %hd", &n, &m, &l);
	
	short matrix1[n][m];
	short matrix2[m][l];
	
	short ii, jj;
	
	// 1????????????????????\????????????
	for( ii = 0; ii < n; ii++ )
	{
		for( jj = 0; jj < m; jj++)
		{
			matrix1[ii][jj] = 0;
			scanf("%hd", &matrix1[ii][jj]);
		}
	}
	
	// 2????????????????????\????????????
	for( ii = 0; ii < m; ii++ )
	{
		for( jj = 0; jj < l; jj++ )
		{
			matrix2[ii][jj] = 0;
			scanf("%hd", &matrix2[ii][jj]);
		}
	}
	
	// ??????????´???¨???????????????
	unsigned long ans_matrix[n][l];
	for( ii = 0; ii < n; ii++ )
	{
		for( jj = 0; jj < l; jj++)
		{
			ans_matrix[ii][jj] = 0;
			ans_matrix[ii][jj] = get_maltiplication(n, m, l, matrix1, matrix2,
				ii, jj);
		}
	}
	
	// ???????????????
	for( ii = 0; ii < n; ii++ )
	{
		for( jj = 0; jj < l; jj++ )
		{
			printf("%ld", ans_matrix[ii][jj]);
			if( jj < l - 1 )
			{
				printf(" ");
			}
			else
			{
				printf("\n");
			}
		}
	}
	
	return 0;
}

/* ????????????????????¢??° */
unsigned long get_maltiplication(short n, short m, short l, short mat1[n][m],
	short mat2[m][l], short current_n, short current_l)
{
	unsigned long ret_multi = 0;
	short k = 0;
	for( k = 0; k < m; k++ )
	{
		ret_multi += (unsigned long)(mat1[current_n][k] * mat2[k][current_l]);
	}
	
	return ret_multi;
}

Measured memory_bytes: 720
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#define int long long
#define ll long long
using namespace std;
//#pragma endregion

signed main()
{
	int n;
	int k, d;
	int all = 0;
	int a;

	int box[110] = { 0 };

	//string str;

	cin >> n >> k;
	//cin >> d;
	//cin >> str;

	//cout << a;

	for (int i = 0; i < k; i++)
	{
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			cin >> a;
			box[a]++;
		}
	}

	for (int i = 1; i <= n; i++)
	{
		if (box[i] == 0)
		{
			all++;
		}
	}

	cout << all << "\n";

	/*if (str=="ABC")
	{
		cout << "ARC\n";
	}
	else
	{
		cout << "ABC\n";
	}*/
}

Measured memory_bytes: 3620
n, m = gets.chomp.split(' ').map{|i| i.to_i }
last_submits = []
ac = 0
pn = 0
pns = []
m.times{|i|
  pp, s = gets.chomp.split(' ')
  pp = pp.to_i
  if last_submits[pp].nil?
    if s[0] == 'A'
      last_submits[pp] = true
      ac += 1
      pn += pns[pp] unless pns[pp].nil?
    else
      pns[pp] = 0 if pns[pp].nil?
      pns[pp] += 1
    end
  end
}

puts "#{ac} #{pn}"


Measured memory_bytes: 3836
#Ai/Aj not integer
#5
#24 11 8 3 16
#のときは、24は8,3があるからダメ　16も8があるからダメ
N=int(input())
A=[int(i) for i in input().split()]
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)

Measured memory_bytes: 39548
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a;
	if (a == 25) {
		cout << "Christmas" << "\n";
	}
	else if (a == 24) {
		cout << "Christmas Eve" << "\n";
	}
	else if (a == 23) {
		cout << "Christmas Eve Eve" << "\n";
	}
	else if (a == 22) {
		cout << "Christmas Eve Eve Eve" << "\n";
	}
	
	std::cin >> e;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    while(true) {
        int N;
        std::cin >> N;
        if(N == 0) break;

        vector<int> A(N);
        REP(i, N) {
            std::cin >> A[i];
        }

        SORT(A);

        int ans = INF;
        for(int i = 0; i < N - 1; i++) {
            ans = min(ans, abs(A[i] - A[i + 1]));
        }

        std::cout << ans << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


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

	ll n, m, q;
	cin >> n >> m >> q;
	int a[510][510] = {0};
	rep(i, m) {
		ll l, r;
		cin >> l >> r;
		a[l][r]++;
	}
	/*rep(i, n+1) {
		rep(j, n+1)cout << a[i][j] << " ";
		cout << endl;
	}*/
	for (int i = n; i >= 1; i--)
	{
		for (int j = 1; j <= n; j++)
		{
			a[i][j] += a[i + 1][j];
			a[i][j] += a[i][j - 1];
			a[i][j] -= a[i + 1][j - 1];
		}
	}
	while (q--) {
		ll x, y;
		cin >> x >> y;
		cout << a[x][y] << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'


int32_t main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(nullptr), cout.tie(nullptr);
    
    int n; cin >> n;
    int cur = 0;
    while (cur < n) cur += 1000;
    cout << cur - n << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;

int expr(string &s, int &i);
int term(string &s, int &i);
int factor(string &s, int&i);
int num(string&s, int&i);

int expr(string&s, int&i) {
	int val = term(s, i);
	while(s[i] == '+' || s[i] == '-') {
		char op = s[i];
		++i;
		int val2 = term(s, i);
		if (op == '+') {
			val+=val2;
		}
		else {
			val-=val2;
		}
	}
	return val;
}

int term(string &s, int&i) {
	int val = factor(s, i);
	while (s[i] == '/' || s[i] == '*') {
		char op = s[i];
		++i;
		int val2 = factor(s, i);
		if (op == '/') {
			val /= val2;
		}
		else {
			val *= val2;
		}
	}
	return val;
}

int factor(string &s, int&i) {
	if (isdigit(s[i])) return num(s, i);
	else {
		++i;
		int val= expr(s, i);
		++i;
		return val;
	}
}
int num(string &s, int&i) {
	int a;
	if (isdigit(s[i])) {
		a = s[i] - '0';
		++i;
		while (isdigit(s[i])) {
			a = a * 10 + (s[i] - '0');
			++i;
		}
	}
	return a;
}
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		s = s.substr(0, s.size() - 1);
		int index = 0;
		int ans = expr(s, index);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			String[] str2 = str.split(" ");
			int[] x = new int[2];

			for (int i = 0; i < 2; i++) {
				x[i] = Integer.parseInt(str2[i]);
			}

			double ans = (x[0] * x[1]) / 3.305785;

			System.out.println(ans);

		} catch (IOException e) {
			System.out.println(e);
		}
	}

}

Measured memory_bytes: 24520
#include<stdio.h>

int main(){
    char kai[100];
    scanf("%s", kai);
    int size = 0;
    int roop;
    int change = 0;
    int i;
    while(kai[size] != '\0'){
        size++;
    }
    //printf("%d\n", size);
    roop = size / 2;

    for(i = 0; i < roop; i++){
        if(kai[i] != kai[size - i - 1]){
            change++;
            //printf("%c %c\n", kai[i], kai[size - i -1]);
        }
    }

    printf("%d\n", change);
    
    return 0;
}

Measured memory_bytes: 128
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
AA = [[-x, x] for x in A]
heapq.heapify(AA)
for i in range(M):
    x, y = heapq.heappop(AA)
    heapq.heappush(AA, [-(y//2), y//2])
AAA = [x[1] for x in AA]
print(sum(AAA))
    

Measured memory_bytes: 24776
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};



int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == 'A'){
        cout << "T" << endl;
    }
    else if(s[0] == 'T'){
        cout << "A" << endl;
    }
    else if(s[0] == 'G'){
        cout << "C" << endl;
    }
    else if(s[0] == 'C'){
        cout << "G" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<max(0,a-2*b);
	
	return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string a, b, c;
    cin >> a >> b >> c;

    constexpr int L = 2000;
    vector<bool> ab(2 * L + 1, true), bc(2 * L + 1, true), ca(2 * L + 1, true);
    rep(i, -L, L + 1) for (int j = max(-i, 0); i + j < (int)a.size() && j < (int)b.size(); ++j) {
        if (a[i + j] != '?' && b[j] != '?' && a[i + j] != b[j]) {
            ab[i + L] = false;
            break;
        }
    }
    rep(i, -L, L + 1) for (int j = max(-i, 0); i + j < (int)b.size() && j < (int)c.size(); ++j) {
        if (b[i + j] != '?' && c[j] != '?' && b[i + j] != c[j]) {
            bc[i + L] = false;
            break;
        }
    }
    rep(i, -L, L + 1) for (int j = max(-i, 0); i + j < (int)c.size() && j < (int)a.size(); ++j) {
        if (c[i + j] != '?' && a[j] != '?' && c[i + j] != a[j]) {
            ca[i + L] = false;
            break;
        }
    }

    int ans = INF;
    rep(j, -2 * L, 2 * L + 1) {
        if (-L <= j && j <= L && !ab[j + L]) continue;
        rep(k, -2 * L, 2 * L) {
            if ((-L <= k && k <= L && !ca[-k + L]) || (-L <= k - j && k - j <= L && !bc[k - j + L])) continue;
            ans = min(ans, max({ (int)a.size(), j + (int)b.size(), k + (int)c.size() }) - min({ 0, j, k }));
        }
    }
    write(ans);
}

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

#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
// namespace IO 
namespace IO
{
template <typename T>
void __RI(T &x)
{
    int ch = getchar(), neg = 1;
    x = 0;
    for (; !(isdigit(ch) || ch == '-' || ch == EOF); ch = getchar())
        ;
    if (unlikely(ch == EOF)) return;
    if (ch == '-') neg = -1;
    for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    x *= neg;
}
void R(int &x) { __RI(x); }
void R(int64_t &x) { __RI(x); }
void R(double &x) { scanf("%f", &x); }
void R(long double &x) { scanf("%f", &x); }
void R(char &x) { scanf("%c", &x); }
void R(char *x) { scanf("%s", x); }
void R(std::string &x) { std::cin >> x; }
template <typename T1, typename T2>
void R(std::pair<T1, T2> &x)
{
    R(x.first);
    R(x.second);
}
template <typename T>
void R(std::vector<T> &x)
{
    for (auto &i : x) { R(i); }
}
template <typename T>
void R(T &x)
{
    std::cin >> x;
}
template <typename T, typename... Args>
void R(T &x, Args &... args)
{
    R(x), R(args...);
}
char space = ' ';
template <typename T>
void __WI(T &x)
{
    if (unlikely(x == 0)) putchar('0');
    if (x < 0) putchar('-'), x = -x;
    char ch[ 64 ];
    int  pos = 0;
    while (x) ch[ pos++ ] = x % 10 + 48, x /= 10;
    while (pos) putchar(ch[ --pos ]);
}
void W() {}
void W(int &&x) { __WI(x); }
void W(int64_t &&x) { __WI(x); }
void W(double &&x) { std::cout << x; }
void W(long double &&x) { std::cout << x; }
void W(char &&x) { putchar(x); }
void W(std::string &&x) { printf("%s", x.c_str()); }
template <typename T1, typename T2>
void W(std::pair<T1, T2> &&x)
{
    W(x.first);
    W(space);
    W(x.second);
}
template <typename T>
void W(std::vector<T> &&x)
{
    for (auto &&i : x)
    {
        W(i);
        W(space);
    }
    W('\n');
}
template <typename T>
void W(T &&x)
{
    std::cout << x;
}
template <typename T, typename... Args>
void W(T &&x, Args &&... args)
{
    W(x), W(space), W(args...);
}
template <typename... Args>
void WL(Args &&... args)
{
    W(args...), W('\n');
}
}; // namespace IO

using namespace std;

#define REP(i, x, y) for (int i = x;i < y; i++)

const int8_t  INFC = 0x3f;
const int16_t INFS = 0x3f3f;
const int32_t INF  = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;
const int     MAXN = 2e5;
const int     MOD  = 1e9 + 7;

vector<int> G[ MAXN ];
int         f[ MAXN ][ 2 ];

int dfs(int x, int la)
{
    f[ x ][ 0 ] = f[ x ][ 1 ] = 1;
    for (int i = 0; i < G[ x ].size(); i++)
        if (la != G[ x ][ i ])
        {
            dfs(G[ x ][ i ], x);
            f[ x ][ 0 ] = 1LL * f[ x ][ 0 ] * (f[ G[ x ][ i ] ][ 0 ] + f[ G[ x ][ i ] ][ 1 ]) % MOD;
            f[ x ][ 1 ] = 1LL * f[ x ][ 1 ] * f[ G[ x ][ i ] ][ 0 ] % MOD;
        }
}

int main()
{
    ios::sync_with_stdio(0);
    int n;
    IO::R(n);
    for (int i = 0; i < n - 1; i++)
    {
        int x, y;
        IO::R(x,y);
        --x, --y;
        G[ x ].push_back(y);
        G[ y ].push_back(x);
    }
    dfs(0,-1);
    IO::WL((f[0][0]+f[0][1])%MOD);
    return 0;
}


Measured memory_bytes: 15872
n, m = map(int, input().split(" "))
a = [list(map(int, input().split(" "))) for i in range(m)]

a_connects = [[] for i in range(n)]
for x, y in a:
	a_connects[x-1].append(y-1)
	a_connects[y-1].append(x-1)

a_connect_sums = [len(connect) for connect in a_connects]
bridge_count = 0
while 1 in a_connect_sums:
	x = a_connect_sums.index(1)
	y = a_connects[x][0]

	a_connects[x].remove(y)
	a_connects[y].remove(x)

	a_connect_sums[x] -= 1
	a_connect_sums[y] -= 1

	bridge_count += 1

print(bridge_count)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main() {
  int n,i,f;
  while(cin >> n) {
      f=0;
      for (i=1; i<513; i*=2) if ((n & i) !=0) {
          if (f==1) cout << ' '; else f=1;
          cout << i ;
      }
      cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import sys
from heapq import heappush, heappop, heapify

input = sys.stdin.readline
N, M = map(int, input().split())
A = [int(i)*-1 for i in input().split()]
heapify(A)

for _ in range(M):
    tmp = heappop(A)*-1
    heappush(A, tmp//2*-1)


print(sum(A)*-1)


Measured memory_bytes: 68248
#include <bits/stdc++.h>
#define inf (long long)(1e18)
using namespace std;

struct Unionfind {
  // tree number
  vector<int> par;
  // constructor
  Unionfind(int n = 1) : par(n, -1) {}
  // search root
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return 0;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

struct line {
  long long a, b, c;
};

long long n, m;
map<long long, long long> mpx, mpy;
vector<line> r, c;
vector<long long> x, y;
vector<vector<long long>> memox, memoy;

long long solve();

int main() {
  cin >> n >> m;
  r.resize(m);
  c.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> c[i].a >> c[i].b >> c[i].c;
    x.push_back(c[i].c);
    y.push_back(c[i].a);
    y.push_back(c[i].b);
  }
  for (int i = 0; i < m; ++i) {
    cin >> r[i].c >> r[i].a >> r[i].b;
    y.push_back(r[i].c);
    x.push_back(r[i].a);
    x.push_back(r[i].b);
  }
  x.push_back(-inf);
  x.push_back(inf);
  x.push_back(0);
  y.push_back(-inf);
  y.push_back(inf);
  y.push_back(0);
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  for (int i = 0; i < x.size(); ++i) mpx[x[i]] = i;
  for (int i = 0; i < y.size(); ++i) mpy[y[i]] = i;
  long long res = solve();
  if (res < 0)
    cout << "INF" << endl;
  else
    cout << res << endl;
  return 0;
}

long long solve() {
  long long res = 0, lenx = x.size(), leny = y.size();
  memox.assign(leny + 1, vector<long long>(lenx + 1, 0));
  memoy.assign(leny + 1, vector<long long>(lenx + 1, 0));
  for (int i = 0; i < n; ++i) {
    auto l = c[i];
    ++memoy[mpy[l.a]][mpx[l.c]];
    --memoy[mpy[l.b]][mpx[l.c]];
  }
  for (int i = 1; i < leny; ++i)
    for (int j = 0; j < lenx; ++j) memoy[i][j] += memoy[i - 1][j];
  for (int i = 0; i < m; ++i) {
    auto l = r[i];
    ++memox[mpy[l.c]][mpx[l.a]];
    --memox[mpy[l.c]][mpx[l.b]];
  }
  for (int i = 0; i < leny; ++i)
    for (int j = 1; j < lenx; ++j) memox[i][j] += memox[i][j - 1];
  Unionfind uf(lenx * leny);
  for (int i = 0; i < leny; ++i)
    for (int j = 0; j < lenx; ++j) {
      if (memoy[i][j] <= 0 && j > 0) uf.uni(i * lenx + j, i * lenx + j - 1);
      if (memox[i][j] <= 0 && i > 0) uf.uni(i * lenx + j, (i - 1) * lenx + j);
    }
  int num = mpy[0] * lenx + mpx[0];
  for (int i = 0; i < leny - 1; ++i)
    for (int j = 0; j < lenx - 1; ++j)
      if (uf.issame(num, i * lenx + j)) {
        if (i == 0 || j == 0 || i == leny - 1 || j == lenx - 1) return -1;
        res += (y[i + 1] - y[i]) * (x[j + 1] - x[j]);
      }
  return res;
}

Measured memory_bytes: 180064