akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

vector<ll> E[200001];
ll V[200001];
ll ans[200001];
ll N,Q;
stack<ll> now;
ll store[2000001];

 
 
int main(){
    cin >> N >> Q;
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }
    
    for(int i=0;i<Q;i++){
        int p,x;
        cin >> p >> x;
        store[p-1] += x;
    }
    now.push(0);
    V[0] = store[0];
    while(!now.empty()){
        ll v = now.top();
        now.pop();
        ans[v] = 1;
        for(int i=0;i<E[v].size();i++){
            if(ans[E[v][i]]==0){
              now.push(E[v][i]);
              V[E[v][i]] = V[v] + store[E[v][i]];
            }
        }
    }
    for(int i=0;i<N;i++){
        cout << V[i] << " ";
    }
    
    
    
}


Measured memory_bytes: 21360
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,k;
    cin>>n>>k;
    int ans=1;
    REP(i,n){
        ans=min(ans*2,ans+k);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
int cnt[26];

int main(){
	int n; cin>>n;
	vector<string> s(n); rep(i, n) cin>>s[i];
	rep(i, n) cnt[s[i][0]-'A']++;
	ll res = 0;
	vector<int> a(5);
	a[0] = 'M';
	a[1] = 'A';
	a[2] = 'R';
	a[3] = 'C';
	a[4] = 'H';
	sort(all(a));
	do{
		ll r = 1;
		rep(i, 3){
			r *= cnt[a[i]-'A'];
		}
		res += r;
	}while(next_permutation(all(a)));
	cout<<res/12<<endl;
	return 0;
}


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

using namespace std;

int n;
typedef long long ll;
int a[100001];
ll sum[100001];
ll L;
int main() {
  cin >> n >> L;

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

  int k = -1;
  for(int i = 0; i < n - 1; i++) {
    if(a[i] + a[i+1] >= L) {
      k = i+1;
    }
  }

  if(k < 0) {
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  for(int i = 1; i < k; i++) cout << i << endl;
  for(int i = n-1; i > k; i--) cout << i << endl;
  cout << k << endl;
}
  
      

      
      
  


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, K;
int A[100010], B[100010];
ll ret;

int main() {
	cin >> N >> K;
	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	for (int i = 29; i >= 0; --i) {
		if ((K >> i) & 1) {
			ll t = 0;
			rep(j, N) if (A[j] < (1 << i)) {
				t += B[j];
			}
			ret = max(ret, t);
			K ^= (1 << i);

			rep(j, N) if ((A[j] >> i) & 1) {
				A[j] ^= (1 << i);
			}
		}
	}

	ll t = 0;
	rep(j, N) {
		if (A[j] == 0) {
			t += B[j];
		}
	}
	ret = max(ret, t);

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

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

      final int n = sc.nextInt();

      if (n % 10 == 7) {
         System.out.println("Yes");
      }
      else if ((n / 10) % 10 == 7) {
         System.out.println("Yes");
      }
      else if (n / 100 == 07){
         System.out.println("Yes");
      }
      else {
         System.out.println("No");
      }
   }
}

Measured memory_bytes: 35764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
unsigned long long c[100000];

int main() {
	long long x[5] = { 0,0,0,0,0 };
	int N;
	cin >> N;
	REP(i, N) {
		string s;
		cin >> s;
		if (s[0] == 'M')x[0]++;
		if (s[0] == 'A')x[1]++;
		if (s[0] == 'R')x[2]++;
		if (s[0] == 'C')x[3]++;
		if (s[0] == 'H')x[4]++;
	}
	long long ans = 0;
	REP(i, 3) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += (x[i] * x[j])*x[k];
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define reg register
typedef long long ll;
inline int read(){
	int x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';f=c=='-'?-1:1,c=getchar());
	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	return x*f;
}
const int MN=1e5+5;
struct edge{int t,nxt;}es[MN<<1]; 
int h[MN],cnt;
inline void ins(int s,int t){
	es[++cnt]=(edge){t,h[s]};h[s]=cnt;es[++cnt]=(edge){s,h[t]};h[t]=cnt;
}
int n,fa[MN],siz[MN],dep[MN]={-1};
inline void dfs(int st,int f){
	dep[st]=dep[f]+1;siz[st]=1;
	for(reg int i=h[st];i;i=es[i].nxt){
		if(es[i].t==f)continue;fa[es[i].t]=st;
		dfs(es[i].t,st);siz[st]+=siz[es[i].t];
	}
}
int main(){
	n=read();
	for(reg int i=1;i<n;i++)ins(read(),read());
	dfs(1,0);reg int pos=n;
	for(reg int i=1;i<=(dep[n]-1>>1);i++)pos=fa[pos];
	dfs(pos,0);reg int ans=siz[fa[pos]];
	if(ans>(n>>1))puts("Fennec");
	else puts("Snuke");
	return 0;
}

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

class Main{
  public static final int WHITE = 0;
  public static final int BLACK = 2;
  public static final int GRAY =1;
  public static final int INFTY = (int)Double.POSITIVE_INFINITY;
  static int n;
  static int M[][];
  static int d[];
  static StringBuilder bl = new StringBuilder();
  static Queue<Integer>  queue = new ArrayDeque<Integer>();
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    M = new int[n][n];
    d  = new int[n];
    int u,v,k;
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        M[i][j] = 0;
      }
    }

    for(int i =0; i<n; i++){
      u = sc.nextInt();
      k = sc.nextInt();
      for(int j = 0; j<k; j++){
        v = sc.nextInt();
        M[u-1][v-1] = 1;
      }
    }
    bfs(0);
  }

  static void bfs(int s){
    queue.add(s);
    for(int i = 0; i<n; i++){
      d[i] = -1;
    }
    d[s] = 0;
    int u;
    while(queue.peek() != null){
      u = queue.peek();
      queue.remove();
      for(int v = 0; v<n; v++){
        if(M[u][v] == 0)continue;
        if( d[v] != -1)continue;
        d[v] = d[u]+1;
        queue.add(v);
      }
    }

    for(int i = 0; i<n; i++){
      bl.append(i+1).append(" ").append(d[i]).append("\n");
    }
    System.out.print(bl);
  }

}


Measured memory_bytes: 27996
#include<stdio.h>


int main() {
	int n,i,cnt=1;
	scanf("%d",&n);

	for (i = 1; i <= 9; i++) {
		if (100 * i + 10 * i + i < n)cnt++;

	}

	printf("%d", 100*cnt+10*cnt+cnt);
	

		return 0;
	
}

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

int main()
{

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



    int ans = 0;
    int active = 0;

    for (int i = 0; i < N; i++){
        if( active >= h[i] ){
            active = h[i];
        }else{
            ans +=  h[i] - active;
            active = h[i];
        }
    }

    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++)
using namespace std;
using ll=long long;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> hp(n);
    rep(i, n) cin>>hp[i];
    sort(hp.begin(),hp.end());
    ll ans=0;
    if(n>=k){
        rep(i,n-k){
            ans+=hp[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    ll ans=0;
    ll cur=0;
    rp(i,n){
        ll a;
        cin >> a;
        if(a<cur){
            ans+=cur-a;
        }else if(a>cur){
            cur=a;
        }
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0;i < (long long int)(n);i++)
#define rep2(i, s, n) for (long long int i = s; i < (long long int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  lli N, M;
  lli ansa =0;
  lli answ =0;
  cin >> N >> M;//NとMの受け取り
  vector<int> S(N,0);//問題の状況の保持
  rep(i, M){
    lli p;
    string s;
    cin >> p >> s;
    if(S[p-1] == -1)
      continue;
    
    if(s == "WA"){
    S[p-1]++;
    }
    else{
    answ+=S[p-1];
      ansa++;
      S[p-1]=-1;
    }
  }
  
  cout << ansa <<" "<< answ << endl;
}


Measured memory_bytes: 640
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


HW = str(input()).split()
H = int(HW[0])
W = int(HW[1])
N = int(input())

Gr = [[0]*W for i in range(H)]

A = [int(x) for x in input().split()]

countH = 0
countW = 0

for i in range(N):
  for j in range(A[i]):
    Gr[countH][countW] = i+1
    countW += 1
    if(countW==W):
      countH += 1
      countW = 0

#print(Gr)

for i in range(H):
  if(i%2 == 0):
    L=[str(a) for a in Gr[i]]
    L=' '.join(L)
    print(L)
  else:
    L=[str(a) for a in reversed(Gr[i])]
    L=' '.join(L)
    print(L)




Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int n;
  cin>>n;
  map<string ,int> mp;
  rep(i,n){
    string s;
    cin>>s;
    mp[s]++;
  }
  cout<<mp.size()<<endl;
}

Measured memory_bytes: 19236
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N, K;
	cin >> N >> K;
	int ans = N - K + 1;
	cout << ans;
}

Measured memory_bytes: 256
use std::io;
use std::collections::HashSet;


fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let cs = factor(gcd(a, b));
    println!("{}", cs.len());

}

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


fn divide(n: usize) -> Option<usize> {
    for i in 2..(n as f64).sqrt().ceil() as usize + 1 {
        if n % i == 0 { return Some(i); }
    }
    None
}

fn factor(n: usize) -> HashSet<usize> {
    let mut x = n;
    let mut fs = HashSet::new();
    fs.insert(1);
    while let Some(f) = divide(x) {
        x /= f;
        fs.insert(f);
    }
    fs.insert(x);
    fs
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int N=2e5+5;
using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int mx=t.size();
    for(int i=0;i<=((int)s.size()-(int)t.size());i++)
    {
        int sum=0;
        for(int j=0;j<t.size();j++)
        {
            if(s[i+j]==t[j]) sum++;
        }
        mx=min(mx,(int)t.size()-sum);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define cin1(x) scanf("%d",&x)
#define cin2(x,y) scanf("%d %d",&x,&y)
#define cin3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define rr read()
#define ll long long
#define CloseIo ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+5];
	rep(i,0,n)
		cin>>a[i];
	sort(a,a+n);
	double ans=a[0];
	rep(i,1,n)
		ans=(a[i]+ans)/2;
	cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
L=lmp()
l=[0]*n
ans=[0]*n
for i in range(n-1):
    l[i]=L[i]^L[i+1]
l[n-1]=L[n-1]^L[0]

if n==2:
    print(L[1],L[0])
    exit()
abc=L[3]
for i in range(4,n):
    abc=abc^L[i]
ans[0]=abc^l[1]
for i in range(1,n):
    ans[i]=ans[i-1]^l[i-1]
print(*ans)

Measured memory_bytes: 35972
#include<iostream>
#include<vector>
#include<utility>

template< typename iterator >
void bubble_sort(iterator first, iterator last)
{
    using std::swap ;
    bool flag = 1 ;
    while(flag)
    {
        flag = 0 ;
        for(iterator iter = last-1 ; iter != first ; --iter)
        {
            if(*iter < *(iter-1))
            {
                swap(*iter, *(iter-1)) ;
                flag = 1 ;
            }
        }
    }
}

template< typename iterator >
void selection_sort(iterator first, iterator last)
{
    using std::swap ;
    for(iterator iter1 = first ; iter1 != last ; ++iter1)
    {
        iterator min_iter = iter1 ;
        for(iterator iter2 = iter1 ; iter2 != last ; ++iter2)
        {
            if(*min_iter > *iter2)
            {
                min_iter = iter2 ;
            }
        }
        swap(*iter1 , *min_iter) ;
    }
}

struct Card
{
    char suit , value ;
    bool operator < (const Card& right) const
    {
        return value < right.value ;
    }
    bool operator > ( const Card& right) const
    {
        return value > right.value ;
    }
} ;


int main()
{
    int N ; 
    std::cin >> N ; 
    std::vector<Card> vec(N) ;
    std::vector<Card> vec2(N) ;

    for(int i = 0 ; i < N ; ++i)
    {
        std::cin >> vec.at(i).suit >> vec.at(i).value ;
    }
    for( int i= 0 ; i < N ; ++i )
    {
        vec2.at(i) = vec.at(i) ;
    }

    bubble_sort(std::begin(vec), std::end(vec));
    selection_sort(std::begin(vec2), std::end(vec2)) ;

    for(int i = 0 ; i < N; ++i)
    {
        if(i == N-1)
        {
            std::cout << vec.at(i).suit <<vec2.at(i).value <<std::endl ;
        }
        else
        {
            std::cout << vec.at(i).suit << vec2.at(i).value << " ";
        }
        
    }
    std::cout <<"Stable" << std::endl ; 

    bool flag = 0 ;
    for(int i = 0 ; i < N ; ++i)
    {
        if(vec.at(i).suit != vec2.at(i).suit)
        {
            flag = 1 ;
        }
    }

    for(int i = 0 ; i < N; ++i)
    {
        if(i == N-1)
        {
            std::cout << vec2.at(i).suit <<vec.at(i).value <<std::endl ;
        }
        else
        {
            std::cout << vec2.at(i).suit << vec.at(i).value << " ";
        }
        
    }
    if(flag)
    {
        std::cout << "Not stable" << std::endl ;
    }
    else
    {
        std::cout << "Stable" << std::endl ;
    }
    

}



Measured memory_bytes: 3104
n, m, k = map(int, input().split())

def bin(a, b, p):
    res = 1
    while b > 0:
        if b & 1 > 0:
            res = res * a % p
        a = a * a % p
        b >>= 1

    return res

MOD = 998244353
N = 200000 + 50
f = [0 for i in range(N)]
invf = [0 for i in range(N)]

f[0] = invf[0] = 1
for i in range(1, N):
    f[i] = f[i-1] * i % MOD

invf[n] = bin(f[n], MOD-2, MOD)
for ri in range(1, N-1):
    i = n - ri
    invf[i] = invf[i+1] * (i+1) % MOD

def binom(n, m):
    if n < m or n < 0 or m < 0:
        return 0
    return f[n] * invf[m] % MOD * invf[n-m] % MOD

def g(n, m):
    return m * bin(m-1, n-1, MOD)

ans = 0
for i in range(0, k+1):
    # print(n-i, i, binom(n-1, i), bin(n-i, m, MOD), n-i, m)
    ans = (ans + binom(n-1, i) * g(n-i, m)) % MOD

print(ans)

Measured memory_bytes: 94404
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

bool isPrime(long long x) {
    if (x == 1) return true;
    for (long long i = 2; i*i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}
vector<int> get_divisors(long long n) {
    vector<int> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (i == n / i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    sort(ans.rbegin(), ans.rend());
    return ans;
}

bool is_sorted(vector<int> a) {
    int n = a.size();
    for (int i = 0; i < n - 1; i++) {
        if (a[i + 1] < a[i]) return false;
    }
    return true;
}

int mxN = 1e5;
int main() {
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0;
    }
    else {
        cout << 10;
    }

    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    HashMap<String, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      String s = sc.next();
      if (map.get(s) != null) {
        map.put(s, map.get(s) + 1);
      } else {
        map.put(s, 1);
      }
    }
    int M = sc.nextInt();
    for (int i = 0; i < M; i++) {
      String s = sc.next();
      if (map.get(s) != null) {
        map.put(s, map.get(s) - 1);
      }
    }
    int max = 0;
    Object[] keys = map.keySet().toArray();
    for (Object key : keys) {
      int tmp = map.get(key);
      if (max < tmp) {
        max = tmp;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <stdlib.h>
#include <algorithm>
using namespace std;
long long a[110000];
int n,k;
int cmp(void const*a,void const *b )
{
	int c=*(int*)a;
	int d=*(int*)b;
	return (c-d);
}
int main()
{
	
	scanf("%d",&n);
	
	for(int i=0; i<n; i++)
	{
		scanf("%d",&a[i]);
	}
	//qsort(a,n,sizeof(a[0]),cmp);
	sort(a,a+n);
	
	int ans=0;
	int i=0,tmp=0;	
	a[n]=-1;
	while(i<n)
	{
		if (a[i]==a[i+1]) tmp++;
		else //if (a[i]!=a[i-1]) 
		{
			tmp++;
			ans+=tmp%2;
			tmp=0;
		}
		i++;
	}
	printf("%d",ans);
//fclose(stdin);
 } 

Measured memory_bytes: 1024
#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 = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
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;

long long power(long long x, long long n){
    long long res = 1;
    x %= MOD;
    while(n > 0LL){
        if(n & 1LL){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}

long long moddiff(long long a, long long b){
    long long res = a - b;
    if(res < 0LL){
        long long t = (abs(res) - 1LL) / MOD + 1LL;
        res += MOD * t;
    }
    res %= MOD;
    return res;
}

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

    lint b, w;
    cin >> b >> w;

    lint n = b + w;

    vector<lint> fact(n + 1);
    fact[0] = 1;

    vector<lint> inv_fact(n + 1);
    inv_fact[0] = 1;

    lint inv2 = power(2, MOD - 2);
    vector<lint> pinv2(n + 1);
    pinv2[0] = 1;

    REP(i, 1, n + 1){
        fact[i] = i * fact[i - 1] % MOD;
        inv_fact[i] = power(fact[i], MOD - 2);
        pinv2[i] = pinv2[i - 1] * inv2 % MOD;
    }

    vector<lint> black(n), white(n);
    rep(i, n){
        if(i < b){
            black[i] = 0;
        }else{
            black[i] = (black[i - 1] + (((fact[i - 1] * inv_fact[b - 1] % MOD) * inv_fact[i - b] % MOD) * pinv2[i] % MOD)) % MOD;
        }
        if(i < w){
            white[i] = 0;
        }else{
            white[i] = (white[i - 1] + (((fact[i - 1] * inv_fact[w - 1] % MOD) * inv_fact[i - w] % MOD) * pinv2[i] % MOD)) % MOD;
        }
        lint ans = (moddiff(1, black[i]) + white[i] % MOD) * inv2 % MOD;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10112
from functools import reduce

N = int(input())
As = list(map(int,input().split()))

def gcd(x,y):
    l = max(x,y)
    s = min(x,y)
    while s != 0:
        l,r = s,l % s
        s = r
    return l

kai = reduce(gcd,As)

counter = 0
while kai % 2 == 0:
    kai //= 2
    counter += 1

print(counter)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
typedef pair<int, int> P;
typedef pair<P, int> PP;
int vx[4] = {1, 0, -1, 0};
int vy[4] = {0, 1, 0, -1};

int solve() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, 0, H) cin >> S[i];
  queue<PP> Q;
  rep(i, 0, H) rep(j, 0, W) {
    if(S[i][j] == '#') Q.push({{i, j}, 0});
  }
  int ans = 0;
  while(!Q.empty()) {
    PP p = Q.front(); Q.pop();
    int y = p.first.first;
    int x = p.first.second;
    int d = p.second;
    rep(i, 0, 4) {
      int ny = y + vy[i];
      int nx = x + vx[i];
      if(nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
      if(S[ny][nx] == '.') {
        S[ny][nx] = '1' + d;
        Q.push({{ny, nx}, d + 1});
        ans = max(ans, d + 1);
      }
    }
  }
  return ans;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 13328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n=0;
	long int k=0;
	long long int ans=0;
	cin>>n>>k;
	vector<long long int> H(n);
	for(long int i=0;i<n;i++)
	{
		cin>>H[i];
	} 
	sort(H.begin(),H.end());
	for(int i=0;i<n-k;i++)
	{
		ans+=H[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
N,K=list(map(int,input().split()))
h=[int(input()) for i in range(N)]

h.sort()

m="a"
for i in range(N-K+1):
	if m=="a" or m>h[i+K-1]-h[i]: m=h[i+K-1]-h[i]

print(m)

Measured memory_bytes: 7384
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	int H, A;
	cin >> H >> A;
	int ans = (H + (A - 1)) / A;
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int d = a * 100 + b * 10 + c;
	if(d % 4)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd

def main():
    A, B, C, D = map(int, input().split())
    nC = B//C - (A-1)//C
    nD = B//D - (A-1)//D
    CD = (C*D)//gcd(C, D)
    nCD = B//CD - (A-1)//CD
    cnt = nC + nD - nCD
    ans = B - A + 1 - cnt
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5048
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
  
const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e18; 
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n, p[N], t[N * 4];

void build (int v, int tl, int tr){
    if (tl == tr) t[v] = p[tl];
    else {
        int tm = tl + tr >> 1;
        build ((v << 1), tl, tm);
        build ((v << 1) + 1, tm + 1, tr);
        t[v] = max(t[(v << 1)], t[(v << 1) + 1]);
    }
}

int get (int v, int tl, int tr, int l, int r){
    if (tl > r || tr < l) return 0;
    if (l <= tl && tr <= r) return t[v];
    int tm = tl + tr >> 1;
    return max(get((v << 1), tl, tm, l, r), get((v << 1) + 1, tm + 1, tr, l, r));
}

int findPRE (int l, int r, int k){
    int lf = l, rg = r;
    while (rg - lf > 1){
        int mid = lf + rg >> 1;
        if (get(1, 1, n, mid, r) > k) lf = mid;
        else rg = mid;
    }
    if (get(1, 1, n, rg, r) > k) return rg;
    else if (get(1, 1, n, lf, r) > k) return lf;
    return 0;
}

int findSUFF (int l, int r, int k){
    int lf = l, rg = r;
    while (rg - lf > 1){
        int mid = lf + rg >> 1;
        if (get(1, 1, n, l, mid) > k) rg = mid;
        else lf = mid;
    }
    if (get(1, 1, n, l, lf) > k) return lf;
    else if (get(1, 1, n, l, rg) > k) return rg;
    return (n + 1);
}

int main (){
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i) scanf ("%d", p + i);
    build (1, 1, n);
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        int p1 = findPRE(1, i - 1, p[i]);
        int p2 = findPRE(1, p1 - 1, p[i]);
        int s1 = findSUFF(i + 1, n, p[i]);
        int s2 = findSUFF(s1 + 1, n, p[i]);
        ll kol = 0;
        kol += 1ll * (p1 - p2) * (s1 - i);
        kol += 1ll * (s2 - s1) * (i - p1);
        ans += kol * 1ll * p[i];
    }
    return !printf ("%lld\n", ans);
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
148
)");
#define cin input
#endif

int main()
{
	int x;
	cin >> x;
	int init = x;
	int sum = 0;
	while(x%10!=0)
	{
		sum += x%10;
		x /= 10;
	}

	cout << (init%sum==0 ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
n,m = list(map(int, input().split()))
l=[list(map(int, input().split())) for _ in range(m)]
ans=[]
if n==1:
    ans.append('0')
ans+=[str(i) for i in range(10**(n-1),10**n)]

for s,c in l:
    ans = [k for k in ans if k[s-1]==str(c)]

if ans:
    print(ans[0])
else:
    print(-1)

Measured memory_bytes: 3064
def f(X):
    return sum([A^X for A in As])

N, K = map(int, input().split())
As = list(map(int, input().split()))

maxDgt = 40
Bs = [list(map(int, bin(A)[2:].zfill(maxDgt)))[::-1] for A in As]

XBest = 0
d = 1
for Cs in zip(*Bs):
    if sum(Cs) < N/2:
        XBest += d
    d *= 2

ans = f(0)
for i in range(maxDgt):
    if (K+1) & (1<<i) == 0: continue
    X = ((K+1)>>(i+1)<<(i+1)) + (XBest&((1<<i)-1))
    ans = max(ans, f(X))

print(ans)


Measured memory_bytes: 55684
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  if(n<105)puts("0");
  else if(n<135)puts("1");
  else if(n<165)puts("2");
  else if(n<189)puts("3");
  else if(n<195)puts("4");
  else puts("5");
  return 0;
}

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

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

    long long height_max = 0;

    long long ans = 0;

    for(int i=0; i<n; i++){
        ans += height_max < a[i] ? 0 : height_max-a[i];
        height_max = max(height_max, a[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{
    priority_queue<pair<long long int,int> > q;

    int n,m;
    cin>>n>>m;
    long long int k;
    int l;
    pair<long long int,int> p;
    for(int i=0;i<n;i++){
        cin>>k;
        p.first=k;
        p.second=1;
        q.push(p);
    }
    for(int i=0;i<m;i++){
        cin>>l>>k;
        p.first=k;
        p.second=l;
        q.push(p);
    }
    long long int ans=0;
    m=n;
    while(m>0){
        k=q.top().first;
        l=q.top().second;
        q.pop();
        if(m<l){
            ans=ans+k*m;
            m=0;
        }
        else{
            m=m-l;
            ans=ans+k*l;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N),B(N+1);
  for(int i=0;i<N;i++){cin >> A[i];}
  B[0]=0;
  for(int i=1;i<=N;i++){B[i]=(B[i-1]+A[i-1])%M;}
  sort(B.begin(),B.end());
  long long ans=0; long long count=0;
  for(int i=0;i<N;i++){
    if(B[i]==B[i+1]){count++;}
    else{ans+=count*(count+1)/2; count=0;}
  }
  ans+=count*(count+1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,K,s[2010][2010],t[2010][2010];int x,y;char c;
int black(int x1,int y1,int x2,int y2)
{return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];}
int white(int x1,int y1,int x2,int y2)
{return t[x2][y2]-t[x1-1][y2]-t[x2][y1-1]+t[x1-1][y1-1];}
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)
	{   
		scanf("%d%d%s",&x,&y,&c);
		x%=2*K;y%=2*K;x++;y++;
		if(c=='B') s[x][y]++;else t[x][y]++;
	}
	for(int i=1;i<=2*K;i++) for(int j=1;j<=2*K;j++)
	s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1],t[i][j]+=t[i-1][j]+t[i][j-1]-t[i-1][j-1];
	int ans=0,now;
	for(int x=0;x<K;x++) for(int y=0;y<K;y++)
	now=black(1,1,x,y)+black(x+1,y+1,x+K,y+K)+black(1,y+K+1,x,2*K)+black(x+K+1,1,2*K,y)+black(x+K+1,y+K+1,2*K,2*K)+white(1,y+1,x,y+K)+white(x+1,1,x+K,y)+white(x+1,y+K+1,x+K,2*K)+white(x+K+1,y+1,2*K,y+K),ans=max(ans,max(now,n-now));
	printf("%d",ans);	
	return 0;
}


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



int main(){
    int N,ans;
    ans = 0;
    cin >> N;
    for(int i = 1; i <= N; i++){
        if ((int)(log10(i) + 1) % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, O = 1;
  cin >> N;
  for (ll i = 2; i <= N; i++) {
    O *= i;
    O %= 1000000007;
  }
  cout << O << endl;
}

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

int f(int n){
  int ans = 1;
  for(int i = 2; i < n; i++){
    if(n % i == 0) ans++;
  }
  ans++;
  return ans;
}

int main(void){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i += 2){
    if(f(i) == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[][] magic = new int[n][2];
		for(int i = 0; i < n; i++){
			magic[i][0] = sc.nextInt();//攻撃力
			magic[i][1] = sc.nextInt();//消費MP
		}
		long[] dp = new long[h + 10001];
		for(int i = 1; i < h + 1; i++){
			int i2 = i + 10000;
			dp[i2] = Long.MAX_VALUE;
			for(int k = 0; k < n; k++){
				dp[i2] = Math.min(dp[i2], dp[i2 - magic[k][0]] + magic[k][1]);
			}
		}
		System.out.println(dp[10000 + h]);
	}
}


Measured memory_bytes: 25652
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n); for(long long i=p;i<n;++i)
#define rofn(i,p,n); for(long long i=p;i>n;--i)
#define pb push_back
#define vi vector
#define ump unordered_map
ll val = 0;
vi<ll> adj[2000003];
ll vis[2000003];
void dfs(int i){
	vis[i] = 1;
	val++;
	for(auto x:adj[i]){
		if(!vis[x]){
			dfs(x);
		}
	}
	return ;
}
void solve(){
	ll n,m;
	cin >> n >> m;
	map<pair<ll,ll>,ll> mp;
	forn(i,0,m){
		ll a,b;
		cin >> a >> b;
		pair<ll,ll> x,y;
		x = make_pair(a,b);
		y = make_pair(b,a);
		if(mp.find(x)==mp.end()&&mp.find(y)==mp.end()){
			adj[a].pb(b);
			adj[b].pb(a);
			mp.insert(make_pair(x,1));
			//mp.insert(make_pair(y,1));
		}
	}
	memset(vis,0,sizeof(vis));
	ll ans = INT_MIN;
	forn(i,0,n){
		val = 0;
		if(vis[i]==0){
			dfs(i);
		}
		ans = max(ans,val);
	}
	cout<<ans;
}
 
int main()
{
	fast;
	//int test;
	//cin >> test;
	//while(test--){
		solve();
	//}
}

Measured memory_bytes: 91112
#include<stdio.h>
int main(void){
	int n=0;
	scanf("%d",&n);
	int a;
	int ans=30;
	int tmp=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		for(tmp=0;;tmp++){
			if(a%2 != 0){
				break;
			}
			a/=2;
		}
		if(tmp < ans){
			ans = tmp;
		} 
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int n ;
int arr[MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	if(n >= 30)
		cout<<"Yes\n" ;
	else
		cout<<"No\n" ;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef long long ll;
 
const ll MOD = 1000000007LL;
int N;
 
map<ll,int> prime_factor(ll n) {
  map<ll,int> res;
  for(ll i=2;i*i<=n;i++) {
    while(n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if(n != 1)res[n] = 1;
  return res;
}
 
 
void compute() {
  map<ll,int> pf;
  REP(i,1,N+1) {
    map<ll,int> tmp = prime_factor(i);
    for(auto v : tmp) {
      pf[v.first] += v.second;
    }
  }
  pf[1] = 0;
  ll ans = 1;
  for(auto v : pf) {
    ans *= (ll)( (ll)v.second + 1LL );
    ans %= MOD;
  }
  cout << ans << endl;
}
 
int main() {
  cin >> N;
  compute();
  return 0;
}

Measured memory_bytes: 256
icase=0
if icase==0:
    n=int(input())
    t=[0]*n
    a=[0]*n

    for i in range(n):
        t[i],a[i]=map(int,input().split())
elif icase==1:
    n=5
    t=[3,48,31,231,3]
    a=[10,17,199,23,2]
    ans=6930

ti=t[0]
ai=a[0]
dt=1
for i in range(n-1):
    if ti/t[i+1]>ai/a[i+1]:
        ii=max((ti-dt)//t[i+1]+1,1)
        ti=ii*t[i+1]
        ai=ii*a[i+1]
    else:
        ii=max((ai-dt)//a[i+1]+1,1)
        ti=ii*t[i+1]
        ai=ii*a[i+1]

print(ai+ti)
         


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

int main(void){
    int p,q,r;
    cin >> p >> q >> r;
    int a = p+q;
    int b = r+q;
    int c = p+r;
    cout << min({a,b,c}) << endl;
}

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


void solve()
{
	int n;
	cin >> n;
	ll ans=0;
	for(int i=1;i<=n;++i)
	{
		if(n%i==0)
		{
			ans+=(n/i-1);
		}
		else
		{
			ans+=n/i;
		}
		
	}
	cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    // int t;
    // cin >> t;
    // while (t--)
    // {
    //     solve();
    // }
    
   solve();
    return 0;
    
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.rbegin(), A.rend());

  int64_t answer = A[0];
  queue<int> q;
  q.push(A[1]);
  q.push(A[1]);

  for (int i = 2; i < N; i++) {
    int64_t now = q.front();
    q.pop();
    answer += now;
    q.push(A[i]);
    q.push(A[i]);
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 4836
#print(3.0/2)
#print(3.0%2)
inp=map(int,input().split())
X,K,D=map(abs,inp)

goal=X-K*D
y1=X%D
y2=y1-D

if y1<=goal:
    print(int(goal))
else:
    if y1<=abs(y2):
        L=(X-y1)/D
    else:
        L=(X-y2)/D
    if (K-L)%2==0:
        print(int(min(y1,abs(y2))))
    else:
        print(int(max(y1,abs(y2))))


Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s;cin>>s;
  rep(i,3){
    if(s[i]=='1'){
      s[i]='9';
    }else{
      s[i]='1';
    }
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
S = raw_input()
print S.count("ABC")

Measured memory_bytes: 4268
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
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); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int a,b,t,ans = 0;
	cin >> a >> b;
	t = a;
	while(t <= b){
		ans++;
		t *= 2;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define f(a,b) for(ll i = a; i < b; i++)
#define fr(a,b) for(ll j = a; j >= b; j--)
#define fi(a,b) for(ll j = a; j < b; j++)
#define fii(a,b) for(ll k = a; k < b; k++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pl pair<ll,ll>
#define vll vector<ll>
#define pll vector< pair<ll,ll> >
#define ld long double


void sieve(int n)
{

    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {
              for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
ll modpow(ll a,ll b){
    ll rs=1;
    a%=mod;
    while(b>0){
        if(b&1)rs=(rs*a)%mod;

        b=b>>1;
        a=(a*a)%mod;
    }
    return rs;
}


int main()
{

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

int t=1;
//cin>>t;

while(t--){

   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   a--;
   ll gc=__gcd(c,d);
   ll lcm=(c*d)/gc;
   ll ans1=(a/c)+(a/d)-(a/lcm);
    ll ans2=(b/c)+(b/d)-(b/(lcm));
    ll ans3=ans2-ans1;
    cout<<b-a-ans3;

}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}
 
 signed main() {
    int K; cin >> K;
    int rec[60], ans[60];
    int div = K / 50, md = K % 50;
    int n=50;
    for(int i=0;i<n;i++){
        rec[i]=div+(i<md);
    }
 
    for(int i=0;i<n;i++){
        int S = 0;
        for(int j=0;j<n;j++) {
            if(i != j) S += rec[j];
        }
        ans[i] = 50 * (rec[i] + 1) - S - 1;
    }
    
    cout << 50 << endl;
    rep(i,0,50) cout << (i ? " " : "") << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
 
 
int main(){
  string S;
  cin >> S;
  rep(i,3){
    cout << S.at(i);
  }
}

Measured memory_bytes: 3624