akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    ll n;
    cin >> n;
    vll goal(3);
    rep(i, 3){
        cin >> goal[i];
    }
    vll l(n);
    rep(i, n){
        cin >> l[i];
    }
    // 3 -> not used
    vll state(n);
    auto calc_MP = [&](){
        ll ret = 0;
        vll len(4, 0);
        vll cnt(4, 0);
        rep(j, n){
            len[state[j]] += l[j];
        }
        rep(i, 3){
            cnt[i] = count(ALL(state), i);
            if(cnt[i] == 0) return INF;
            ret += 10 * (cnt[i] - 1);
            ret += abs(len[i] - goal[i]);
        }
        return ret;
    };
    ll state_num = powint(4, n);
    ll ans = INF;
    rep(i, state_num){
        rep(k, n){
            state[k] = (i / powint(4, k)) % 4;
        }
        chmin(ans, calc_MP());
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int INF = 1e9;
int main()
{
	int x, y;	cin >> x >> y;

	int start = x * 2;

	if (y >= x * 2 && y <= (x * 4) && y % 2 == 0)
		cout << "Yes\n";
	else 
		cout << "No\n";

}

//  3 2 1 3 1 3

//  3 5 6 



// 4 2
//  2 2 		4 2 			4 4			
// 2 2 2  		2 2 4			2 4 4		4 4 4

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
void output(int array[3][10]){
    for(int j = 0;j<3;j++){
        for(int i = 0;i<10;i++){
           cout<<" "<<array[j][i];
        }
        cout<<""<<endl;        
    }
}

int main(){
    int n,b,f,r,number;
    cin>>n;
    int A1[3][10] = {0};
    int A2[3][10] = {0};
    int A3[3][10] = {0};
    int A4[3][10] = {0};
    for(int i = 0;i<n;i++){
       cin>>b>>f>>r>>number;
       switch (b)
       {
       case 1:
           A1[f-1][r - 1] += number;
           break;
       case 2:
           A2[f-1][r - 1] += number;
           break;
       case 3:
           A3[f-1][r - 1] += number;
           break;
       case 4:
           A4[f-1][r - 1] += number;
           break;
       default:
           break;
       }
    }
    output(A1);
    cout<<"####################"<<endl;
    output(A2);
    cout<<"####################"<<endl;
    output(A3);
    cout<<"####################"<<endl;
    output(A4);   
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int N = 2e5+5;

ll ans;
int a[N];
map<int, int> mp, mpp;

int main()
{
	map<int, int>::iterator it;
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		int x; cin >> x;
		mp[x]++; a[i] = x;
	}
	for (it = mp.begin(); it != mp.end(); it++)
	{
		ans += (ll)(it->se)*(it->se-1)/2;
	}
	for (int i = 0; i < n; i++)
	{
		ll res = ans, cs = mp[a[i]];
		res -= (cs-1)*cs/2;
		cs--; res += (cs-1)*cs/2;
		cout << res << endl; 
	}
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define maxm 
#define mod 
#define maxn 

int main()
{
	int n;
	ll y;
	
	scanf("%d", &n);
	ll x = 1;
	while (n--) {
		scanf("%lld", &y);
		x = x / __gcd(x, y) * y;
	}
	printf("%lld\n", x);
}

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

int main() {
	int M,D;
	int d_ten = 0,d_one = 0,count = 0;
	cin >> M >> D;
	rep(i,D+1){
		d_ten = i / 10;
      	d_one = i % 10;
      	rep(j,M+1){
          if(d_one >= 2 && d_ten >= 2 && j == d_ten*d_one){
            count++;
          }
        }
	}
  	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<P> A;
    rep(i,N){
        ll x,l; cin>>x>>l;
        A.emplace_back(x+l,x-l); //ato,mae
    }
    SORT(A);
    ll sai=-INF2;
    ll ans=0;
    rep(i,N){
        if(A[i].second<sai) continue;
        ++ans;
        sai=A[i].first;
    }

    cout<< ans <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" << endl;
    }else if (a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    return 0; 
}



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

#define INF INT_MAX
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int n,q;

bool isRange(int a){
	return 0 <= a && a < n; 
}

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

	cin >> n >> q;

	string s;
	cin >> s;

	vector<pair<char,char>> td;
	int t,d;
	for(int i=0;i < q;i++){
		char t,d;
		cin >> t >> d;
		td.push_back(make_pair(t,d));
	}

	int l = -1;
	int r = n;
	for(int i = td.size()-1;i >= 0;i--){
		char t = td[i].first, d = td[i].second;
		// cout << t << " " << d << " " << s[l+1] << " " << s[r-1] << endl;
		if(isRange(l+1) && s[l+1] == t && d == 'L'){
			l++;
		}else if(isRange(l) && s[l] == t && d == 'R'){
			l--;
		}
		if(isRange(r-1) && s[r-1] == t && d == 'R'){
			r--;
		}else if(isRange(r) && s[r] == t && d == 'L'){
			r++;
		}
	}
	// cout << l << " " << r << endl;
	cout << n-(l+1)-(n-r) << endl;
   
	return 0;
}


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

int x,y;
int s[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};

int main()
{
    scanf("%d%d",&x,&y);
    if(s[x] == s[y])
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


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

int main()
{
char str[205];
int len;
int i;
int en;
int even;

i=0;
for(;;)
{
 scanf("%c",&str[i]);
 if ( ((str[i]-'a')<0) | ((str[i]-'a')>('z'-'a')) ) break;
 i++;
}

len = i;
en=len-1;
even=1;
if(en%2==0)
{
 for(i=0;i<en/2;i++) if(str[i]!=str[i+en/2]) even=0;
}else{
 en--;
 even=0;
}

if(even!=1)
{
 for(;;)
 {
  even=1;
  for(i=0;i<en/2;i++) if(str[i]!=str[i+en/2]) even=0;
  if(even==1) break;
  en=en-2;
 }
}

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

return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;


struct Node{
    ll key;
    struct Node *left, *right, *parent;
};
Node *root,*NIL;

void preorder(Node * node){
  if(node == NIL){
    return;
  }
  cout << " " << node->key;
  preorder(node->left);
  preorder(node->right);

}
void inorder(Node * node){
  if(node == NIL){
    return;
  }
  inorder(node->left);
  cout << " " << node->key;
  inorder(node->right);
}
void print(){
  inorder(root);
  cout << endl;
  preorder(root);
  cout << endl;
}

bool find(Node* node,ll k){
  if(node == NIL){
    return false;
  }
  if(node->key == k){
    return true;
  }else if(node->key > k){
    return find(node->left,k);
  }else{
    return find(node->right,k);
  }
}

void insert(ll k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}
int main(){
  ll n;
  cin >> n;
  string str;
  rep(i,n){
    cin >> str;
    if(str == "insert") {
      cin >> t1;
      insert(t1);
    }else if(str == "find"){
      cin >> t1;
      if(find(root,t1)){
        cout << "yes" << endl;
      }else{
        cout << "no" << endl;
      }
    }else{
      print();
    }
  }
}


Measured memory_bytes: 21820
#include<bits/stdc++.h>
using namespace std;
const int mod1=1e9+7,mod2=1e9+9;
int n;
long long row1[500][500],col1[500][500],row2[500][500],col2[500][500];
char s[500][500];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)row1[i][j]=(row1[i][j]*30+(s[i][(j+k)%n]-'a'+1))%mod1,row2[i][j]=(row2[i][j]*30+(s[i][(j+k)%n]-'a'+1))%mod2;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)col1[i][j]=(col1[i][j]*30+(s[(j+k)%n][i]-'a'+1))%mod1,col2[i][j]=(col2[i][j]*30+(s[(j+k)%n][i]-'a'+1))%mod2;
	int ans=0;
	for(int a=0;a<n;a++)
		for(int b=0;b<n;b++)
		{
			bool f=1;
			for(int i=0;i<n;i++)
				if(row1[(i+a)%n][b]!=col1[(i+b)%n][a]||row2[(i+a)%n][b]!=col2[(i+b)%n][a]){f=0;break;}
			ans+=f;
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6784
#include <cstdio>
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll N, M, C;
vector<ll> B;
vector<vector<ll>> A;

void input() {
    cin >> N >> M >> C;
    B.resize(M);
    for (auto& b : B)
        cin >> b;
    A.resize(N, vector<ll>(M));
    for (auto& al : A)
        for (auto& a : al)
            cin >> a;
}

void solve() {
    ll ans = 0;
    for (auto& al : A) {
        ll sum = C;
        for (ll i = 0; i < M; i++)
            sum += al[i] * B[i];
        if (sum > 0)
            ans++;
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 888
n=int(input())
s=[input() for i in range(n)]
# print(s)
jisyo=[[0]*26 for i in range(n)]
# print(jisyo)
for i in range(n):
    for j in range(len(s[i])):
        jisyo[i][ord(s[i][j])-ord("a")]+=1
# print(jisyo)
ans=[51]*26
for i in range(26):
    for j in range(n):
        ans[i]=min(ans[i],jisyo[j][i])
# print(ans)

answer=""
for i in range(26):
    for j in range(ans[i]):
        answer+=chr(i+ord("a"))
print(answer)

Measured memory_bytes: 39920
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M; cin>>N>>M;
  map<long long,int> V;
  for(int i=0;i<N;i++){
    long long a; cin>>a;
    V[a]++;
  }
  for(int i=0;i<M;i++){
    long long b,c; cin>>b>>c;
    V[c]+=b;
  }
  int rem=N;
  long long ans=0;
  for (auto itr=V.rbegin(); itr!=V.rend();itr++){
    ans+= itr->first*min(itr->second,rem);
    rem-=itr->second;
    if(rem<=0) break;
  }
  cout << ans << "\n";
}

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

int main() {
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  
  //角度をそれぞれ得る
  long double Hrad = H * 30 + M * 0.5;
  long double Mrad = M * 6;
  long double Gap = Hrad - Mrad;
  
  //円周率
  long double pi = 2.0 * asin(1.0);
  
  //距離
  long double Dis = 0;
  
  //あとは余弦定理。
  if (Gap > 180){
    Gap = 360 - Gap;
    Gap /= 180;
    Gap *= pi;
    Dis = A * A + B * B - (2 * A * B * cos(Gap));
    Dis = sqrt(Dis);
  } else if (Gap < 180){
    Gap /= 180;
    Gap *= pi;
    Dis = A * A + B * B - (2 * A * B * cos(Gap));
    Dis = sqrt(Dis);
  } else if (Gap == 180){
    Dis = A + B;
  } 
  
  cout << fixed << setprecision(10) << Dis << endl;
}


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity() ? std::numeric_limits<T>::infinty() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n, m; cin >> n >> m;
	vpii sv(n); cin >> sv;
	sort(sv.begin(), sv.end(), [] (pii l, pii r) { return tie(l.second, l.first) < tie(r.second, r.first); });
	vi c(m); cin >> c;
	sort(c.begin(), c.end());
	vi lomo(n);
	for (int i = 0; i < n; i++)
		lomo[i] = distance(c.begin(), lower_bound(c.begin(), c.end(), sv[i].first));
	int z = m - 1, ans = 0;
	for (int i = n - 1; i >= 0; i--) if (lomo[i] <= z) ans++, z--;
	cout << ans << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

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

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M;
	vector<pair<int,int>> in;
	vector<int> dp;
	
	cin>>N>>M;
	
	in.resize(M);
	dp.resize(1<<N, INF);
	
	for(int i = 0; i < M; i++){
		int a, b;
		
		cin>>a>>b;
		
		in[i].first = a;
		
		for(int j = 0; j < b; j++){
			int c;
			cin>>c;
			in[i].second |= (1<<(c-1));
		}
	}
	
	dp[0] = 0;
	
	for(int i = 0; i < (1<<N); i++){
		for(int j = 0; j < M; j++){
			dp[i|in[j].second] = min(dp[i|in[j].second], dp[i] + in[j].first);
		}
	}
	
	cout<<(dp[(1<<N)-1]==INF?-1:dp[(1<<N)-1])<<endl;
	
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
D = [0] * len(S)
for i, _ in enumerate(S):
  if i + len(T) > len(S):
    D[i] = len(T)
    continue
  for j, t in enumerate(T):
    D[i] += 1 if S[i + j] != t else 0
print(min(D))

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int a,b,m;cin>>a>>b>>m;
    vector<int> rei,den,c;
    int p;
    rep(i,a){
        cin>>p;
        rei.push_back(p);
    }
    rep(i,b){
        cin>>p;
        den.push_back(p);
    }
    int x,y;
    rep(i,m){
        cin>>x>>y>>p;
        c.push_back(rei[x-1]+den[y-1]-p);
    }
    sort(rei.begin(),rei.end());
    sort(den.begin(),den.end());
    sort(c.begin(),c.end());
    cout<<min(rei[0]+den[0],c[0])<<endl;
    return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
map<char,int> mp[10010];
int main(){
	int n,i,j;
	cin>>n;
	getchar();
	for(i=1;i<=n;i++){
		string s;
		getline(cin,s);
		for(j=0;j<s.size();j++){
			mp[i][s[j]]++;
		}
	}
	string ans;
	for(char k='a';k<='z';k++){
		int t=0x3f3f3f;
		for(i=1;i<=n;i++){
			t=min(t,mp[i][k]);
		}
		if(t>0){
			for(j=1;j<=t;j++){
				ans+=k;
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    cout << (n-1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
static const int N=10000;

int n;
vector< vector< pair<int,int> > > adj(N,vector< pair<int,int> >());
vi d(N,inf);

void dijkstra();

int main(){
	int k,u,v,c,i,j;
	cin>>n;
	loop(i,0,n){
		cin>>u>>k;
		loop(j,0,k){
			cin>>v>>c;
			adj[u].push_back(make_pair(c,v));
		}
	}
	dijkstra();
	loop(i,0,n){
		cout<<i<<" "<<((d[i]==inf)? -1:d[i])<<endl;
	}
}

void dijkstra(){
	priority_queue< pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > pq;
	int i;
	vi color(n,WHITE);
	
	d[0]=0;
	pq.push(make_pair(0,0));
	color[0]=GRAY;
	
	while(!pq.empty()){
		pair<int,int> f=pq.top();
		pq.pop();
		int u=f.second;
		color[u]=BLACK;
		if(d[u]<f.first){
			continue;
		}
		loop(i,0,adj[u].size()){
			int v=adj[u][i].second;
			if(color[v]==BLACK){
				continue;
			}
			if(d[v]>d[u]+adj[u][i].first){
				d[v]=d[u]+adj[u][i].first;
				pq.push(make_pair(d[v],v));
				color[v]=GRAY;
			}
		}
	}
}
	

Measured memory_bytes: 7992
N, K = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))
h_sorted = sorted(h)
ans = False
for i in range(N - K + 1):
    if ans is not False:
        ans = min(ans, h_sorted[K + i - 1] - h_sorted[i])
    else:
        ans = h_sorted[K + i - 1] - h_sorted[i]
print(ans)

Measured memory_bytes: 8280
import java.util.Scanner;

class Main{
	public static void main (String args[]){
		Scanner Scanner = new Scanner(System.in);
		String  X = Scanner.nextLine();
		int champion = 0;
		int chalenger;
		for(int i = 0; i < X.length()-2; i++){
			if(i==0) {
              champion = Math.abs(Integer.parseInt(X.substring(i, i + 3)) - 753);
            }else{
              chalenger = Math.abs(Integer.parseInt(X.substring(i, i + 3)) - 753);
              if(champion > chalenger)  champion = chalenger;
            }
        }
		System.out.println(Integer.toString(champion));
	}

}

Measured memory_bytes: 25172
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int N, A[112345];
LL guhehe;
int ans;

int main()
{
	in >> N;
	rep(i, N) { in >> A[i]; }

	std::sort(A, A + N);
	rep(i, N - 1)
	{
		guhehe += A[i];
		if (guhehe * 2 < A[i + 1])
		{
			ans = i + 1;
		}
	}
	ans = N - ans;

	out << ans << std::endl;
	return 0;
}

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

long long minCount( const long long a, const long long m )
{
	long long ret = 0, p = 1;
	do{
		++ret;
		p = ( p * a ) % m;
	}while( p != 1 );

	return ret;
}

long long lcm( const long long x, const long long y )
{
	long long p, q, tmp;
	p = x;
	q = y;
	while( ( tmp = p % q ) != 0 ){
		p = q;
		q = tmp;
	}
	return x / q * y;
}

int main()
{
	long long a[3], m[3];
	while( ( cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2] )
		&& !( !a[0] && !a[1] && !a[2] && !m[0] && !m[1] && !m[2] ) ){

		long long x, y, z;

		x = minCount( a[0], m[0] );
		y = minCount( a[1], m[1] );
		z = minCount( a[2], m[2] );

		cout << lcm( lcm( x, y ), z ) << endl;
	}
	return 0;
}

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

using namespace std;

const int MAXN = 100;
const int MAXW = 1E5;
pair<int, int> item[MAXN + 1];
long long dp[MAXW + 1][MAXN + 1];

int main()
{
    int n, w;
    cin >> n >> w;
    for (int i = 1; i <= n; i++)
        cin >> item[i].first >> item[i].second;
    for (int i = 1; i <= w; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            dp[i][j] = dp[i][j - 1];
            if (i - item[j].first >= 0)
            {
                dp[i][j] = max(dp[i][j], dp[i - item[j].first][j - 1] + item[j].second);
            }
        }
    }
    cout << dp[w][n] << endl;
    return 0;
}


Measured memory_bytes: 79232
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = NewScanner(os.Stdin, 1000000)

func main() {
	N := sc.readInt()
	M := sc.readInt()
	if N >= M {
		fmt.Println(0)
		return
	}
	var X []int
	for i := 0; i < M; i++ {
		X = append(X, sc.readInt())
	}
	sort.Ints(X)
	var diff []int
	var diffSum int
	for i := 0; i < M-1; i++ {
		diff = append(diff, X[i+1]-X[i])
		diffSum += X[i+1] - X[i]
	}
	sort.Ints(diff)
	for i := 0; i < N-1; i++ {
		diffSum -= diff[M-2-i]
	}
	fmt.Println(diffSum)
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func sliceMin(s []int) int {
	result := math.MaxInt64
	for _, v := range s {
		if v < result {
			result = v
		}
	}
	return result
}

func sliceMax(s []int) int {
	result := math.MinInt64
	for _, v := range s {
		if v > result {
			result = v
		}
	}
	return result
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


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


#define ll long long


int main()
{

   string s;

   int n;

   cin >> n >> s;

   string s1 = s.substr(0,n/2);

   //cout << s1 << endl;

   string s2 = s.substr((n/2),n);


   //cout << s2 << endl;

  // cout << s << endl;


     if(n%2)
     {
         cout << "No" << endl;
         return 0;
     }
   if(s1==s2)
   {
       cout << "Yes" << endl;
   }
   else
   {
       cout << "No" << endl;
   }



    return 0;
}



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

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

using namespace std;

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

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


int main()
{
	string s;	
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy";
	if (s == "Cloudy")
		cout << "Rainy";
	if (s == "Rainy")
		cout << "Sunny";








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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l; cin >> n >> l;
  vector<string> S(n); rep(i, n) cin >> S[i];
  sort(all(S));
  rep(i, n) cout << S[i];
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0;i < n;i++) a[i] = sc.nextInt();
			int min,max,x;
			min = max = a[0];
		for(int i = 0;i < n;i++) {
			if(max < a[i]) {
				max = a[i];
			}
			if(min > a[i]) {
				min = a[i];
			}
		}
		x = max - min;
		System.out.println(x);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

int main(){
  int n, k; cin >> n >> k;
  ll ans = 0;
  COMinit();
  for(int i = 0; i <= min(n-1,k); i++) {
    ans += COM(n, i)*COM(n-1, n-i-1)%MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11904
#include<stdio.h>

int main(){
int N,x,Y=0,TA=0,HA=0;
bool A[202]={},B[202]={};
bool f=true;
int cnt=0;
bool syu=false;
int S=0;

for(int i=0;i<201;i++)
{A[i]=false;B[i]=false;}
while(1){
scanf("%d",&N);if(N==0)break;
for(int i=0;i<N;i++)
{scanf("%d",&x);A[x]=true;}
for(int i=1;i<=2*N;i++)
{if(A[i]==false){B[i]=true;}}
S=2*N;
while(1)
{

for(int i=1;i<=2*N;i++)
{
if(A[i]==true&&i>Y){A[i]=false;S--;Y=i;
break;}
else if(i==2*N&&A[i]==false){f=false;Y=0;}
}
for(int i=1;i<=2*N;i++){
if(A[i]==false)syu=true;
else if(A[i]==true){syu=false;break;}
}
if(syu==true)break;

for(int i=1;i<=2*N;i++)
{
if(B[i]==true&&i>Y){B[i]=false;S--;Y=i;
break;}
else if(i==2*N&&B[i]==false){f=true;Y=0;}
}
for(int i=1;i<=2*N;i++){
if(B[i]==false)syu=true;
else if(B[i]==true){syu=false;break;}
}
if(syu==true)break;

}

if(f==true)TA+=S;
else if(f==false)HA+=S;

printf("%d\n%d\n",TA,HA);


for(int i=0;i<202;i++)
{A[i]=false;B[i]=false;}
TA=0;HA=0;f=true;Y=0;


//else if(f==false)HA+=S;

//if(f==true)TA+=S;
//else if(f==false)HA+=S;
}
//printf("%d\n%d\n",TA,HA);

return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18

#define nax 100005


void solve(){
	
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0){
		cout<<1<<endl;
		return;
	}
	if(b==0){
		cout<<2<<endl;
		return;
	}
	if(c==0){
		cout<<3<<endl;
		return;
	}
	if(d==0){
		cout<<4<<endl;
		return;
	}
	if(e==0){
		cout<<5<<endl;
		return;
	}

	

}
signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
import sys
n=int(input())
A=[]
def kyuudou(n):
    sum=0
    for i in range(n//4):
        hit=int(input())
        sum+=hit
    A.append(sum)
    ni=int(input())
    if ni==0:
        sys.exit
    else:   
        kyuudou(ni)
kyuudou(n)
for j in range(len(A)):
    print(A[j])

        
    
    


Measured memory_bytes: 5604
import sys
N = int(input())
turn = 0
x, y = 0, 0
for i in range(N):
    a = list(map(int, input().split()))
    if a[0]%2 == 0 and (a[1]+a[2])%2 == 1:
        print("No")
        sys.exit()
    if a[0]%2 == 1 and (a[1]+a[2])%2 == 0:
        print("No")
        sys.exit()
    if (a[0] - turn) < abs(x - a[1]) + abs(y - a[2]):
        print("No")
        sys.exit()
print('Yes')

Measured memory_bytes: 3064
# ABC168 A ∴ (Therefore)

n = int(input())

_tmp = n%10

p_list = [0,1,6,8]
h_list = [2,4,5,7,9]
b_list = [3]

if _tmp in p_list:
    print("pon")
elif _tmp in h_list:
    print("hon")
elif _tmp in b_list:
    print("bon")

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

int main(){
	string s;
	ll k;
	cin>>s>>k;
	rep(i,k){
		if(s[i]!='1'){
			puts(s[i]);
			return 0;
		}
	}
	puts(1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 1000000007;
// const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;


const int MAX_n = 1000;
int n, l[MAX_n], r[MAX_n];
int ans;

signed main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> l[i]>>r[i];
        ans+=r[i]-l[i]+1;
    }
    cout<< ans<< endl;


    return 0;
}

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

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

    int p1, p2, p3;
    cin >> p1 >> p2 >> p3;
    int res = 0;
    if((p1 < p2 && p2 < p3) || (p1 > p2 && p2 > p3)) res++;
    
    for (int i = 3; i < n; ++i){
        p1 = p2;
        p2 = p3;
        cin >> p3;
        if((p1 < p2 && p2 < p3) || (p1 > p2 && p2 > p3)) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[105];
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int m;
    cin>>m;
    int ans;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        ans=sum;
        ans=ans-a[x]+y;
        cout<<ans<<endl;
    }
    return 0;
}

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

b = {}
for i in range(N):
  s = str(input())
  if b.get(s) is None:
    b[s] = 1
  else:
    b[s] += 1
    
r = {}
M = int(input())
for i in range(M):
  s = str(input())
  if r.get(s) is None:
    r[s] = 1
  else:
    r[s] += 1

ans = -999999
for st in b:
  if r.get(st) is None:
    ans = max(ans, b[st])
  else:
    ans = max(ans, b[st] - r[st])
if ans >= 0:
  print(ans)
else:
  print(0)

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

int main() {
  string C[2];
  cin >> C[0] >> C[1];

  bool isMatch = C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0];

  cout << (isMatch ? "YES" : "NO") << endl;
}

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

int main()
{
	int n, x, l, co=0;
    int cnt = 1;

    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> l;
        co += l;
        if (co <= x)    cnt++;
        
    }
    cout << cnt << endl;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
typedef long long ll;
const int N=3003,A=200003,M=1e9+7;
inline int Pow(int a,int m){int s=1;for(;m;m>>=1)m&1?s=(ll)s*a%M:0,a=(ll)a*a%M;return s;}
struct point{int x,y;}a[N];
bool Cmp(const point&a,const point&b){return a.x==b.x?a.y<b.y:a.x<b.x;}
int h,w,n,g[N],f[A],invf[A],ans;
inline int C(int n,int m){return(ll)f[n]*invf[m]%M*invf[n-m]%M;}
signed main(){
	scanf("%d%d%d",&h,&w,&n);
	f[0]=1;
	for(int i=1;i<=h+w;i++)f[i]=(ll)f[i-1]*i%M;
	invf[h+w]=Pow(f[h+w],M-2);
	for(int i=h+w;i>=1;i--)invf[i-1]=(ll)invf[i]*i%M;
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y);
	std::sort(a+1,a+1+n,Cmp);
	for(int i=1;i<=n;i++){
	  g[i]=C(a[i].x+a[i].y-2,a[i].x-1);
	  for(int j=1;j<i;j++)if(a[j].x<=a[i].x&&a[j].y<=a[i].y)
		g[i]=(g[i]-(ll)g[j]*C(a[i].x+a[i].y-a[j].x-a[j].y,a[i].x-a[j].x)%M+M)%M;
	  ans=(ans+(ll)g[i]*C(h+w-a[i].x-a[i].y,h-a[i].x))%M;
	}
	printf("%d",(C(h+w-2,h-1)-ans+M)%M);
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var l = new List<Tuple<string,int,int>>();
            for(var i = 1; i <= n; i++){
                var _ = Console.ReadLine().Split();
                var s = _[0];
                var p = int.Parse(_[1]);
                l.Add(Tuple.Create(s, p, i));
            }

            var o = l.OrderBy(t => t.Item1).ThenByDescending(t => t.Item2);
            foreach(var t in o){
                Console.WriteLine(t.Item3);
            }
        }
    }
}


Measured memory_bytes: 11604
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

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

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

public class UnionFind
{
    private int[] Par;
    private int[] Rank;

    public UnionFind(int n)
    {
        Par = (new int[n]).Select((i, index) => index).ToArray();
        Rank = new int[n];
    }

    public int Root(int a)
    {
        if (Par[a] == a) return a;
        else return Root(Par[a]);
    }

    public bool Same(int a, int b)
    {
        return Root(a) == Root(b);
    }

    public void Union(int a, int b)
    {
        a = Root(a);
        b = Root(b);
        if (a != b)
        {
            if (Rank[a] < Rank[b])
            {
                Par[a] = b;
            }
            else
            {
                Par[b] = a;
                if (Rank[a] == Rank[b])
                {
                    Rank[a]++;
                }
            }
        }
    }
}

class Magatro
{
    private int N, M;
    private int[] A, B;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        A = new int[M];
        B = new int[M];
        for (int i = 0; i < M; i++)
        {
            A[i] = sc.NextInt()-1;
            B[i] = sc.NextInt()-1;
        }
    }

    private bool isBridge(int n)
    {
        var uf = new UnionFind(N);
        for (int i = 0; i < M; i++)
        {
            if (i == n) continue;
            uf.Union(A[i], B[i]);
        }
        return !uf.Same(A[n], B[n]);
    }

    public void Solve()
    {
        Scan();
        int cnt = 0;
        for(int i=0;i<M;i++)
        {
            if (isBridge(i))
            {
                cnt++;
            }
        }
        Console.WriteLine(cnt);
    }

    static public void Main()
    {
        new Magatro().Solve();

    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int number,w;
long long dp[100100];
int main(){
	cin>>number>>w;
	for(int i=1;i<=number;i++){
		int weight,value;
		cin>>weight>>value;
		for(int j=w-weight;j>=0;j--)
			dp[j+weight]=max(dp[j+weight],dp[j]+value);
	}
	cout<<dp[w]<<endl;
	return 0;
}

Measured memory_bytes: 1024
S = input()
ans = "Yes"
for i in range(0,len(S),2):
	if not(S[i] == "R" or S[i] == "U" or S[i] == "D"):
		ans = "No"
		break
	if(i < len(S)-1):
		if not(S[i+1] == "L" or S[i+1] == "U" or S[i+1] == "D"):
			ans = "No"
			break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int mod = 1e9 + 7;
int n, m;
int a[maxn], b[maxn], deg[maxn];
inline int read() {
	int x; scanf("%d", &x); return x;
}
int main() {
	#ifdef LOCAL
		freopen("1.in", "r", stdin);
	#endif
	n = read(), m = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	sort(a + 1, a + 1 + n);
	int ans = 0;
	for (int i = 1; i <= m; ++i) ans += a[i];
	cout << ans << endl; 
	return 0; 
}	

Measured memory_bytes: 3780
# -*- encoding : UTF-8 -*-
n, d = list(map(int, input().split()))

def distance(j_list, i_list):
 n = len(j_list)
# print([i_list, j_list])
 dist2 = 0
 
 for k in range(n):
   dist2 = dist2 + (j_list[k] - i_list[k])**2
   
 dist = dist2 ** 0.5
 return dist

nd_list = []
for i in range(n) :
  n_i = list(map(int, input().split()))
  nd_list.append(n_i)

count = 0

for i in range(n-1) :
  for j in range(i+1,n):
   dist = distance(nd_list[j], nd_list[i])
   dist_int = int(dist)
   if (dist - dist_int) == 0 :
     count = count + 1

print(count)


Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  ll x;
  for (int i = 0; i < N; i++) {
    cin >> x;
    ans += min(2 * x, 2 * (K - x));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
n = int(input())
a = list(map(int, input().split()))
q = int(input())
A = [0]*1000000

for i in a:
    A[i] += 1
    
ans = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    ans = ans+((c-b)*(A[b]))
    print(ans)
    A[c] += A[b]
    A[b] = 0


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    int a[101];
    rep(i, 101) a[i] = 0;

    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            a[i * j] = 1;
        }
    }
    if (a[n] == 1)
        OP("Yes");
    else
        OP("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<pair<long long, long long>> vec;
long long a;
int main() {
	long long n;
	cin >> n;
	for (long long i = 0; i < n; i++) {
		cin >> a;
		vec.emplace_back(make_pair(a, i + 1));
	}
	sort(vec.begin(), vec.end());
	set<long long> st;
	st.insert(0);
	st.insert(n + 1);
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long x = vec[i].first;
		long long y = vec[i].second;
		auto itr = st.set::lower_bound(y);
		auto itr1 = itr--;
		ans += x * (y - *itr1) * (*itr - y);
		st.insert(y);
	}
	cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)cout<<k;
    else if(k<=a+b)cout<<a;
    else cout<<a-(k-a-b);
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  string s;
  cin >> s;
  ll res = 1;
  string os = "";
  os += s[0];
  for(int i = 1;i < s.size();i++){
    if(os.size() != 1){
      res++;
      os = s[i];
    }else{
      if(s[i] != os[0]){
        res++;
        os = s[i];
      }else{
        res++;
        if(i+1 < s.size()){
          os = s[i]+s[i+1];
          i++;
        }else{
          res--;
        }
      }
    }
  }
  cout << res << endl;

  
  


  

  return 0;
}

Measured memory_bytes: 640
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

v_2n = Counter(v[0::2])
v_2n1 = Counter(v[1::2])

if v_2n.most_common(1)[0][0] == v_2n1.most_common(1)[0][0]:
    if len(v_2n)==1 and len(v_2n1)==1:
        cnt = n // 2
    elif v_2n.most_common(2)[-1][1] >= v_2n1.most_common(2)[-1][1]:
        cnt = n - v_2n.most_common(2)[-1][1] - v_2n1.most_common(1)[0][1]
    else:
        cnt = n - v_2n.most_common(1)[-1][1] - v_2n1.most_common(2)[-1][1]
else:
    cnt = n - v_2n.most_common(1)[0][1] - v_2n1.most_common(1)[0][1]
print(cnt)

Measured memory_bytes: 101904
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)[:x]
q = sorted(list(map(int, input().split())), reverse=True)[:y]
r = sorted(list(map(int, input().split())), reverse=True)

p.extend(q)
ans = sorted(p)

for i in range(x + y):
  if (len(r) == i) or (ans[i] > r[i]):
    break
  else:
    ans[i] = r[i]

print(sum(ans))


Measured memory_bytes: 105444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		}
		System.out.println(count);
		kb.close();
	}

}


Measured memory_bytes: 35784
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef pair<int, int> ii;

long long count_P_in_nfact(long long n , long long p) {
    long long res = 0;
    while (n) {
        n /= p;
        res += n;
    }
    return res;
}
long long count_5_in_nfact(long long n , long long p) {
    long long res = 0;
    while (n) {
        n /= p;
        res += n / 2;
    }
    return res;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    long long n;
    cin >> n;

    if (n & 1) {
        cout << 0 << '\n';
        return 0;
    }

    cout << min(count_5_in_nfact(n, 5), count_P_in_nfact(n, 2)) << '\n';


    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func main() {
	A, B, C, K := 0, 0, 0, 0
	fmt.Scanf("%d %d %d", &A, &B, &C)
	fmt.Scan(&K)
	fmt.Println(maxTrio(A, B, C)*(int(math.Pow(2.0, float64(K)))-1) + A + B + C)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func maxTrio(a, b, c int) int {
	return max(max(a, b), c)
}


Measured memory_bytes: 512