akhauriyash/Code-Regression huggingface dataset:
// Author       : Naresh Bharasagar
            // CF Handle    : Nareshhhh
            // Programme    : B.Tech Computer Science & Engineering
            // Organization : Indian Institute of Technology Guwahati

#include<bits/stdc++.h>
using namespace std;
typedef long long int loo;


#define loop(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define rep(r) for(auto i=1; i<=r; ++i)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define v(name,type,size) vector<type> name(size)
#define vloo vector<loo>
#define outa(a,n) loop(i,0,n) cout << a[i] << " ";
#define p0(a) cout << #a << endl
#define mod(a) a%1000000007
#define pb(l) push_back(l)
#define ppb pop_back()
#define ff first
#define ss second
#define input(a) for(auto &i: a) cin >> i;
#define prnt(v) for(auto it: v) cout << it << " ";
#define deb0(i) cout << "[i=" << i << "]" << endl;
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define INF 1000000000
#define M 1000000007

loo power(loo x, loo y, loo p) { 
    loo res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

bool sortbysec(const pair<loo,loo> &a, const pair<loo,loo> &b) { 
    return (a.second < b.second); 
}

string decToBin(loo n)
{
	string s = "0";
	if(n == 0) return s;
	s = "";
    while (n > 0)
    { 
        s += (n % 2) + '0';
        n = n / 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
 
loo binToDec(string s)
{
    loo ans = 0;
    reverse(s.begin(), s.end());
    loop(i, 0, s.size())
    {
    	ans += pow(2, i)*(s[i] - '0');
    }
    return ans;
}

int main() {
	fast_io

    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);

    loo n;
    cin >> n;
    string s[n];
    vector<pair<loo,string>> counts;
    unordered_map<string,loo> cnt;
    set<string> res;
    loo mx=0;
    loop(i,0,n) {
        cin >> s[i];
        res.insert(s[i]);
    }
    for(set<string>::iterator it=res.begin(); it!=res.end(); it++)
        cnt[*it]=0;
    loop(i,0,n) {
        cnt[s[i]]++;
        mx = max(mx,cnt[s[i]]);
    }
    for(set<string>::iterator it=res.begin(); it!=res.end(); it++){
        if(cnt[*it]==mx) cout << *it << endl;
    }

    return 0;
}

Measured memory_bytes: 33736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	if (S[0] == '9' || S[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    string w;
    cin>>w;
    
    //配列を作る
    int moji[26];
    bool flag=true;
    
    for(int i = 0; i < 26; i++)
    {
        //全部0にする
        moji[i]=0;
    }
    
    for(int i = 0; i < w.size(); i++)
    {
        //w[0]=aの時、moji[a-'a']=97-97-0,moji[0]の箱に++される
        moji[w[i]-'a']++;
    }
    
    for(int i = 0; i < 26 ; i++)
    {
        
        if (moji[i]%2!=0) {
            flag=false;
        }
        
    }
    
    if (flag) {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

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

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

    for (int i = 0; i < k; i++) {
        if (!(b > a)) {
            b *= 2;
        } else if (!(c > b)) {
            c *= 2;
        }
    }

    if (c > b && b > a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll a,b; cin >> a >> b;
  a--;
  if(a%2){
    a = ((a+1)/2)%2;
  }else{
    a ^= (a/2)%2;
  }
  if(b%2){
    b = ((b+1)/2)%2;
  }else{
    b ^= (b/2)%2;
  }
  cout << (a^b);
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9 + 7;
 
int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll res = 0;
  int cnt = 0;
 
  sort(a.begin(), a.end(), greater<int>());
 
  res += a[0];
  cnt++;
  if (cnt == n - 1) {
    cout << res << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    res += a[i];
    cnt++;
    if (cnt == n - 1) break;
    res += a[i];
    cnt++;
    if (cnt == n - 1) break;
  }
 
  cout << res << endl;
  return 0;
} 

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

const ll N = 1e5 + 5;
#define ff first
#define ss second
vector<pair<ll,ll>> g[N];

int color[N];

void dfs(int v,int p = 1){

	for(auto x : g[v]){
		ll u = x.ff;
		ll w = x.ss;
		if(u != p){
			if(w % 2){
				color[u] = !color[v];
			}else{
				color[u] = color[v];
			}
			dfs(u,v);
		}
	}

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	ll n,i,u,v,w;
	cin >> n;
	for(i = 1;i < n;i++){
		cin >> u >> v >> w;
		g[u].push_back({v,w});
		g[v].push_back({u,w});	
	}
	color[1] = 1;
	dfs(1);
	for(i = 1;i <= n;i++){
		cout << color[i] << '\n';
	}
}


Measured memory_bytes: 9856
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a = int(input())
    s = input()[:-1].decode()

    if a >= 3200:
        print(s)
    else:
        print('red')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
def main():
    N = int(input())
    H = list(map(int, input().split()))
    max_height = H[0]
    ans = 1

    for i in range(1, N):
        if H[i] >= max_height:
            ans += 1
            max_height = H[i]

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <functional>

using namespace std;

int main() {
    int ans = 0;
    string n;

    cin >> n;

    for(int i = 0;i < 3;i++){
        if(n[i] == '1'){
            ans++;
        }
    }

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


Measured memory_bytes: 256
using System;

namespace ABC100B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] ints = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int d = ints[0];
            int n = ints[1];
            if (n == 100)
            {
                if (d == 0)
                {
                    Console.WriteLine(101);
                    return;
                }
                if (d == 1)
                {
                    Console.WriteLine(10100);
                    return;
                }
                if (d == 2)
                {
                    Console.WriteLine(1010000);
                    return;
                }
            }
            Console.WriteLine(n * 1 * Math.Pow(100, d));
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
//9:19

int main(){
  int n = 0;
  int T = 0;
  int t[200000] = {};
  int i = 0;
  int flowing = 0;
  int maxflowing = 0;
  
  scanf("%d %d",&n,&T);
  for(i = 0;i < n;i++){
    scanf("%d",&t[i]);
  }
  
  for(i = 0;i < n-1;i++){
    if(t[i+1]-t[i]<=T){
      flowing += t[i+1] - t[i];
    }else{
      flowing += T;
    }
  }
  
  flowing += T;
  
  printf("%d",flowing);
  
  return 0;
}

Measured memory_bytes: 896
n = int(input())
a = list(map(int,input().split()))
x = []
y = []
for i in range(len(a)):
    if i%2==0:
        x.append(str(a[i]))
    else:
        y.append(str(a[i]))
if n%2==1:
    x = x[::-1]
    print(' '.join(x+y));exit()
else:
    y = y[::-1]
    print(' '.join(y+x));exit()

Measured memory_bytes: 104056
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

constexpr auto rate = 380000.;

int main()
{
	int N;
	cin >> N;
	vector<double> x(N);
	vector<string> u(N);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
		cin >> u[i];
	}
	double ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (u[i]=="JPY")
		{
			ans += x[i];
		}
		else
		{
			ans += rate * x[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <numeric>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<int,int> pii;
inline int in() {
    int n, c;
    while ((c = getchar()) < '0') if (c == EOF) return -1;
    n = c - '0';
    while ((c = getchar()) >= '0') n = n * 10 + c - '0';
    return n;
}
ll vec[3000];
int main(){
    int n = in();
    int sz = 0;
    while(n--){
        vec[sz++] = (ll)in();
        while(sz >= 3 and vec[sz-1] <= vec[sz-2] and vec[sz-3] <= vec[sz-2]){
            vec[sz-3] = vec[sz-1] + vec[sz-3] - vec[sz-2];
            sz-=2;
        }
    }
    ll ans = 0;
    int i = 0, j = sz-1;
    int k = 1;
    while(i<=j){
        if(vec[i] > vec[j]){
            ans += vec[i]*k;
            i++;
        }else{
            ans += vec[j]*k;
            j--;
        }
        k *= -1;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47636
/**
*    created: 10.05.2020 08:42:12
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int N;
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    int ans = 0;
    bool f,g;
    rep(i,N){
        if(i==0){
            f = true;
            continue;
        }
        if(f){
            if(a[i]>a[i-1]){
                g = 0;
                f = false;
            }else if(a[i]<a[i-1]){
                g = 1;
                f = false;
            }else{
                continue;
            }
        }else{
            if(g==0&&a[i]<a[i-1]){
                f = 1;
                ans++;
            }
            if(g==1&&a[i]>a[i-1]){
                f = 1;
                ans++;
            }
        }
    }
    ans++;
    cout << ans << endl;
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const ll INF = 1e15;
const int N = 303;
ll dp[N][N][N];
int arr[N];
int n , k;

ll solve(int idx , int lst , int op){
    if(op > k)return INF;
    if(idx == n)return 0;
    ll &ret = dp[idx][lst][op];
    if(~ret)return ret;
    ret = solve(idx + 1 , lst , op + 1);
    if(arr[idx] >= arr[lst]){
        ret = min(ret , solve(idx + 1 , idx , op) + arr[idx] - arr[lst]);
    }else{
        ret = min(ret , solve(idx + 1 , idx , op));
    }
    return ret;
}

int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    memset(dp,-1,sizeof dp);
    cin >> n >> k;
    if(k == n){
        cout << 0 << endl;
        return 0;
    }

    loop(i,n)cin >> arr[i];
    ll ans = INF;
    range(i,1,n){
        ans = min(ans , solve(i,i-1,i-1) + arr[i-1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 217600
fun main(args: Array<String>) {
    val (n, x0) = readLine()!!.split(" ").map(String::toInt)
    val x = readLine()!!.split(" ").map(String::toInt).map{abs(x0 - it)}.reduce{a, b -> gcd(a,b)}
    print(x)
}

tailrec fun gcd(a: Int, b: Int): Int {
    if(b == 0) return a
    return gcd(b, a % b)
}

fun abs(n: Int): Int {
    return if (n > 0) n else -n
}

Measured memory_bytes: 51844
#include <stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  if(N<10){
    printf("%d\n",N);
  }else if(N<100){
    printf("9\n");
  }else if(N<1000){
    printf("%d\n",10+N-100);
  }else if(N<10000){
    printf("909\n");
  }else if(N<100000){
    printf("%d\n",N-10000+910);
  }else if(N==100000){
    printf("90909\n");
  }
}

Measured memory_bytes: 128
cards = {
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n = int(input())
for i in range(n):
    icon,num = input().split()
    cards[icon][int(num)-1] = 1

for i in ['S','H','C','D']:
    for j in range(13):
        if cards[i][j] == 0:
            print('{} {}'.format(i,j+1))



Measured memory_bytes: 5600
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;
const int oo=(1<<30)-1;

pii A[2*N];
int vis[N];
int n,x,y,c,mnx=oo,mxx=-oo,mny=oo,mxy=-oo,tmp;
ll ans;

int main(){
	n=IN();
	For(i,1,n+1){
		x=IN(),y=IN();
		if (x>y) swap(x,y);
		A[++c]=mp(x,i);
		A[++c]=mp(y,i);
		mnx=min(mnx,x);
		mxx=max(mxx,x);
		mny=min(mny,y);
		mxy=max(mxy,y);
	}
	ans=1ll*(mxx-mnx)*(mxy-mny);
	sort(A+1,A+c+1);
	for (int i=1,j=0;i<=c;i++){
		while (j+1<=c&&tmp!=n){
			if (++vis[A[++j].se]==1) tmp++;
		}
		if (tmp==n){
			ans=min(ans,1ll*(mxy-mnx)*(A[j].fi-A[i].fi));
		}
		if (--vis[A[i].se]==0) tmp--;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii              pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define __              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#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 endl			"\n"
#define m(a)		    memset(a,0,sizeof(a))
#define all(x)                          begin(x), end(x)

void fastscan(int &x){
bool neg = false;register int c;
x = 0;c = getchar();
if(c=='-'){neg = true;c = getchar();}
for(; (c>47 && c<58); c=getchar()){x = x *10 + c - 48;}
if(neg){x *= -1;}}

void file(){
	#ifndef ONLINE_JUDGE
	freopen("in.txt" , "r" , stdin);
	freopen("out.txt" , "w" , stdout);
	#endif
}

int bs(int a[] , int s , int e, int x){
	if(s<=e){
		int m = (s+e)/2;
		if(a[m]==x)
			return m;
		else if(a[m] > x)
			return bs(a,s,m-1,x);
		else return bs(a,m+1,e,x);
	}
	return -1;
}

#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr5(v,w,x,y,z) cout<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define tr6(u,v,w,x,y,z) cout<<u<<" "<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;

#define deb(x) cout<<#x<<"="<<x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define deb3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl

#define sd(x) cin >> x;
#define sd2(x,y) cin >> x >> y;
#define sd3(x,y,z) cin >> x >> y >> z;
#define sd4(w,x,y,z) cin >> w >> x >> y >> z;

bool is_pal(string s) {return equal(all(s), s.rbegin());}

int mypow(int a, int b){        //(logn) fast exponentiation
    int res = 1;            // call int x = mypow(2,5);
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return (res%mod);
}	

int32_t main(){	
	__;
	file();
	int n; sd(n);
	if(n%1000){
		cout << 1000-(n%1000) << endl;
	}
	else{
		cout << 0 << endl;
	}
	return 0;
}






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

long long m, a, r, c, h;
long long D[5];

int P[10] = {0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
int Q[10] = {1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
int R[10] = {2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};


int main(){
    string s;
    int n;
    cin >> n;

    for(int i=0; i < n; i++){
        cin >> s;
        if(s[0] == 'M') m++;
        else if(s[0] == 'A') a++;
        else if(s[0] == 'R') r++;
        else if(s[0] == 'C') c++;
        else if(s[0] == 'H') h++;
    }
    D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;
    long long res = 0;
    for(int d=0; d < 10; d++) res += D[P[d]] * D[Q[d]] * D[R[d]];

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
/*
	1.根节点不一定为0
	2.找到根节点然后再依次赋值deep；
*/
struct Tree {
	int depth;
	int parent;
	int left, right,sibling;
	int child;
	int heigh;
};
Tree tree[100000];
int gethigh(int n) {
	if (tree[n].heigh != 0) return tree[n].heigh;
	int a=0, b=0;
	if (tree[n].left != -1) a = gethigh(tree[n].left)+1;
	if (tree[n].right != -1) b = gethigh(tree[n].right)+1;
	tree[n].heigh = max(a, b);
	return max(a, b);
}

int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		tree[i].parent = -1;
	}
	for (int i = 0; i < n; i++) {
		int pa,right, left;
		cin >>pa>> right >> left;
		tree[pa].left = left;
		tree[pa].right = right;
		if (left != -1) {
			tree[left].parent = pa;
			tree[left].sibling = right;
			tree[pa].child++;
		}
		if (right != -1) {
			tree[right].parent = pa;
			tree[right].sibling = left;
			tree[pa].child++;
		}
	}
	int k = 0;
	for (; k < n; k++) {
		if (tree[k].parent == -1) break;
	}
	queue<int>q;
	q.push(k);
	while (!q.empty())
	{
		int i = q.front();
		if (tree[i].left != -1) {
			q.push(tree[i].left);
			tree[tree[i].left].depth = tree[i].depth + 1;
		}
		if (tree[i].right != -1) {
			q.push(tree[i].right);
			tree[tree[i].right].depth = tree[i].depth + 1;
		}
		q.pop();
	}
	tree[k].sibling = -1;
	gethigh(k);
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << tree[i].parent << ", sibling = " << tree[i].sibling << ", degree = " << tree[i].child << ", ";
		cout << "depth = " << tree[i].depth << ", height = " << tree[i].heigh << ", ";
		if (i == k) cout << "root";
		else if (tree[i].child == 0) cout << "leaf";
		else cout << "internal node";
		cout << endl;
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, v, w;
    cin >> a >> v;
    cin >> b >> w;
    ll t;
    cin >> t;
    if(v <= w) {
        print("NO");
        return 0;
    }
    ll d = (v - w) * t;
    print((d >= llabs(b - a)) ? "YES" : "NO");
}

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

int main()
{
	int N;
	int s[1000], h[1000], L[1000], C[1000];
	while (cin >> N) {
		if (N == 0)
			break;
		for (int i = 0; i < N; i++) {
			cin >> s[i] >> h[i] >> L[i] >> C[i];
		}
		int P, Q, R, c;
		int a = 0;
		cin >> P >> Q >> R >> c;
		for (int i = 0; i < N; i++) {
			if ((h[i] <= P) && (L[i] <= Q) && (C[i] <= R) && ((h[i] * 4 + L[i] * 9 + C[i] * 4 )<= c)) {
				cout << s[i] << endl;
				a = 1;
			}
		}
		if (a == 0)
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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 (b<a) { a = b; return 1; } return 0; }

signed main(){
  int n;
  cin >> n;
  vector<P> A(n);
  rep(i,0,n){
    cin >> A[i].first >> A[i].second;
  }
  vector<P> B(n);
  rep(i,0,n){
    B[i].first = A[i].second;
    B[i].second = A[i].first;
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  double MIN = 0;
  double MAX = 0;
  int ans = 0;
  if(n % 2 == 0){
    MIN = (A[n/2].first + A[n/2-1].first);
    MAX = (B[n/2].first + B[n/2-1].first);
    ans = (MAX - MIN) + 1;
  }
  else{
    MIN = A[n/2].first;
    MAX = B[n/2].first;
    ans = MAX - MIN + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9468
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    int ans=1;
    REP(i,N){
        ans=min(ans*2,ans+K);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  char r,g,b;
  cin>>r>>g>>b;
  ll ans=(r-'0')*100+(g-'0')*10+(b-'0');
  if(ans%4==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define floop(i,a,b) for (int i=(a);i<(b);i++)
#define rloop(i,a,b) for (int i=(a);i>=(b);i--)
#define floopeq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
void dfs(int i,int j,int n,int m,vector<vector<char>>a,vector<vector<bool>>&vis)
{
    vis[i][j]=1;
    if(i<(n-1) && vis[i+1][j]==0 && (a[i+1][j]!='#'))
    {
        dfs(i+1,j,n,m,a,vis);
    }
    if(i>0 && vis[i-1][j]==0 &&(a[i-1][j]!='#'))
    {
        dfs(i-1,j,n,m,a,vis);
    }
    if(j<(m-1) && vis[i][j+1]==0 && (a[i][j+1]!='#'))
    {
        dfs(i,j+1,n,m,a,vis);
    }
    if(j>0 && vis[i][j-1]==0 && ((a[i][j-1]!='#')))
    {
        dfs(i,j-1,n,m,a,vis);
    }
}
void solve()
{
	string s;
	cin>>s;
	vector<char>p;
	for(auto x:s){
		if(x=='?')
		{
			p.pb('D');
		}
		else
			p.pb(x);
	}
	for(auto x:p){
		cout<<x;
	}
}
int main() 
{ 
    
    int t;
    t=1;
    while(t--){
    	solve();
    }
    return 0; 

} 


Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int ans[1000],i=0;
  char ch[1000];
  while(1){
    if(scanf("%s",ch)==EOF)break;
 
    if(ch[0]!='+'&&ch[0]!='-'&&ch[0]!='*')ans[i]=atoi(ch);
    else {
    if(ch[0]=='+')ans[i-2]+=ans[i-1];
    else if(ch[0]=='-')ans[i-2]-=ans[i-1];
    else if(ch[0]=='*')ans[i-2]*=ans[i-1];
    i-=2;
    }
    i++;
  }
    cout<<ans[0]<<endl;
    return 0;
}

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

using namespace std;

int main()
{
  int N, Q; cin >> N >> Q;
  string S; cin >> S;
  vector<int> l(Q), r(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> l[i] >> r[i];
    l[i]--, r[i]--;
  }

  vector<int> a(N, 0);
  for (int i = 0, counter = 0; i < N-1; ++i) {
    if (S[i] == 'A' and S[i+1] == 'C') {
      counter++;
    }
    a[i] = counter;
  }

  for (int i = 0; i < Q; ++i) {
    // printf("%d, %d\n", a[l[i]-1], a[r[i]-1]);
    cout << a[r[i]-1] - a[l[i]-1] << endl;
  }
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
 
int main() {
	int n;
	while(1){
	cin >> n;
	if(n==0)break;
	int min,max;
	int s,x;
	cin >>s;
	min=s;
	max=s;
	x=s;
		for(int i=0;i<n-1;i++){
		cin >>s;
		x=x+s;
		if(min >s) min=s;
		if(max <s) max=s;
 
		}
	x=x-max-min;
    x=x/(n-2);
	cout << x <<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
		if(a<b){
		printf("a < b\n");
		}
		if(a>b){
		printf("a > b\n");
		}
		if(a==b){
		printf("a == b\n");
		}
	return 0;
}

Measured memory_bytes: 1008
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  c=1
  h=I()
  ans=0

  while True:
    ans+=c
    if h==1:
      break

    h//=2
    c*=2

    # print(c,ans)

  return ans

# main()
print(main())


Measured memory_bytes: 6832
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL LOG[100005];
LL pw2[100005];

void add_edge(LL u,LL v){
	cout << u << ' ' << v << endl;
}

int main(){
	LL n; cin >> n;
	LOG[0] = -1; for(LL i = 1;i <= n;i ++) LOG[i] = LOG[i >> 1] + 1;
	for(LL i = 1;i <= n;i ++) pw2[i] = (1LL << LOG[i]);
	if(n == pw2[n]){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	add_edge(1,2); add_edge(2,3); add_edge(3,1 + n); add_edge(1 + n,2 + n); add_edge(2 + n,3 + n);
	for(LL i = 4;i + 1 <= n;i += 2){
		add_edge(i,1); add_edge(i + 1,1);
		add_edge(i + n,i + 1); add_edge(i + n + 1,i);
	}
	if(!(n & 1)){
		add_edge(pw2[n] + 1,n);
		add_edge(n - pw2[n],n + n);
	}
	return 0;
}

Measured memory_bytes: 3840
def solve(x, y):
    if x * y < 0:
        return abs(y + x) + 1
    if x == 0:
        return abs(y) + int(y < 0)
    if y == 0:
        return abs(x) + int(x > 0)
    if x < y:
        return y - x
    return x - y + 2


print(solve(*map(int, input().split())))


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    ll X; cin >> X;
    ll ans = 0;
    ans += 1000 * (X / 500);
    X %= 500;
    ans += 5 * (X / 5);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,k = LI()
    a = [None] + LI()
    explored = {1}
    lst = [1]
    lenth = 0
    start = 0
    junkan = []
    now = 1
    while lenth==0:
        nxt = a[now]
        if nxt in explored:
            index = lst.index(nxt)
            junkan = [lst[-1]] + lst[index:-1]
            start = index
            lenth = len(junkan)
        else:
            explored.add(nxt)
            lst.append(nxt)
        now = nxt
    ans = 0
    if k<start:
        ans = lst[k]
    else:
        r = (k-start+1)%lenth
        ans = junkan[r]

    print(ans)


main()            


Measured memory_bytes: 34024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N,K;
	cin>>N>>K;
	int ans=1;
	REP(i,N){
		ans=min(ans+K,ans*2);
	}
	cout<<ans<<endl;	
	return 0;
}
	
	

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

int A, B, C;
int dp[4][20000];
int X;

int main(){
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &X);
    int ans;
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<= C; k++){
                if(500*i + 100*j + 50*k == X) ans++;
            }
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no() { cout << "No" << endl;exit(0);}
void yes() { cout << "Yes" << endl;exit(0);}
void No() { cout << "NO" << endl;exit(0);}
void Yes() { cout << "YES" << endl;exit(0);}

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
  int n;
  cin>>n;
  if(n==3||n==5||n==7)
    cout << "YES" << endl;
    else
      cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <numeric>

using namespace std;

typedef long long ll;

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    ll m = 111111111111111;
    for(ll i = 0;i < n;i++){
        ll cnt = 0;
        while(a[i] % 2 == 0){
            a[i] /= 2;
            cnt++;
        }
        m = min(m,cnt);
    }
    cout << m << endl;
    return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 1e5+1;
int n, m;
long a[N];

int main()
{
  fastio;
  cin >> n >> m;
  for (int i = 1; i <= n; i++){
    cin >> a[i]; a[i] /= 2;
  }
  while (true){
    bool Check = a[1] % 2;
    for (int i = 1; i <= n; i++){
      if (a[i] % 2 != Check) return cout << 0, 0;
      if (Check == false) a[i] /= 2;
    }
    if (Check) break;
    else m /= 2;
  }
  long lcm = 1;
  for (int i = 1; i <= n; i++){
    lcm = lcm * a[i] / __gcd(lcm, a[i]);
    if (lcm > m) return cout << 0, 0;
  }
  cout << (m / lcm + 1) / 2;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;


int main(){
	llint n;
	cin >> n;
	vector<llint>a(n);
	int tmp = 1;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		if (a[i] % 2 == 1){
			tmp = 0;
		}
	}
	int cnt = 0;
	while (tmp){
		for (int i = 0; i < n; i++){
			a[i] /= 2;
		}
		cnt++;
		for (int i = 0; i < n; i++){
			if (a[i] % 2 == 1){
				tmp = 0;
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string a,b,c;
	cin>>n>>a>>b>>c;
	int co = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == c[i]  && a[i] == b[i]) co += 0;
		else if(a[i] == b[i]  && a[i] != c[i]) co += 1;
		else if(a[i] == c[i]  && a[i] != b[i]) co += 1;
		else if(b[i] == c[i]  && b[i] != a[i]) co += 1;
		else co += 2;
	}
	cout<<co<<"\n";
}


Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;




//#[proconio::fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        _c: i64,
        k: i64,
    }
    let ans;
    if k <= a {
        ans = k;
    } else if k <= a+b {
        ans = a;
    } else {
        ans = a - (k-(a+b));
    }

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



Measured memory_bytes: 2112
from math import ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
l = len(bin(K))-2 if K!=0 else 0
for i in range(l)[::-1]:
    cnt = 0
    for a in A:
        tmp = (a>>i)&1
        if not tmp:
            cnt += 1
    if ceil(N/2)<=cnt and ans+(2**i)<=K:
        ans += (2**i) 

s = 0
for a in A:
    s += a^ans
print(s)


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

int main()
{
    ll s; cin >> s;
    ll r1 = (ll)ceil(sqrt(s)); // = x2 = y3
    ll r2 = r1 * r1 - s;            // = x3
    cout << "0 0 " << r1 << " 1 " << r2 << " " << r1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define vi vector<int>
    #define all(v) v.begin(), v.end()
    #define ll long long int
    #define ff first
    #define ss second
    #define pb push_back
    using namespace std;
    int main()
    {
       int i,j,k,n,m,d,cnt=0;
       cin>>n;
       for(i=1;i<=n;i++)
       {
           cin>>j;
           if(i%2!=0 && j%2!=0){
               cnt++;
           }
       }
       cout<<cnt;
    }


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int cnt=1;
  int odd=1;
  for(int i=0;i<N;i++){
    cnt*=3;
    if(A[i]%2==0){odd*=2;}
  }
  cout<<cnt-odd<<endl;
  return 0;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

struct LowLink {
        vector<pair<int, int>> bridge;
        vector<int> articulation, ord, low;
        vector<bool> used;
        vector<vector<int>> g;
        int n, k = 0;
        LowLink(const vector<vector<int>> &g) : g(g) {
                n = g.size();
                ord.resize(n, 0);
                low.resize(n, 0);
                used.resize(n, false);
        }
        void dfs(int u, int prev) {
                used[u] = true;
                ord[u] = k ++;
                low[u] = ord[u];
                bool is_articulation = false;
                int cnt = 0;
                for (auto v : g[u]) if (v != prev) {
                        if (!used[v]) {
                                cnt ++;
                                dfs(v, u);
                                low[u] = min(low[u], low[v]);
                                if (low[v] > ord[u]) {
                                        bridge.emplace_back(min(u, v), max(u, v));
                                } 
                                if (prev != -1 && low[v] >= ord[u]) {
                                        is_articulation = true;
                                }
                        } else {
                                low[u] = min(low[u], ord[v]);
                        }
                }
                if (prev == -1 && cnt > 1) is_articulation = true;
                if (is_articulation) articulation.push_back(u);
        }
};

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<vector<int>> g(n);
        for (int i = 0; i < m; i ++) {
                int a, b;      
                scanf("%d%d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        LowLink ll(g);
        ll.dfs(0, -1);
        printf("%d\n", (int) ll.bridge.size());
        return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long result = 0;
		for(int i = 0; i < n; i++){
		    result += (long)(i+1)*(n-i);
		}
		for(int i = 0; i < n-1; i++){
		    int u = sc.nextInt()-1;
		    int v = sc.nextInt()-1;
		    int from = min(u, v);
		    int to = max(u, v);
		    result -= (long)(from+1)*(n-to);
		}
		
		// 計算
		//long result = 1;
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 48128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll N,A,B;cin>>N>>A>>B;
    cout<<min(N*A,B)<<endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPP(x,y,c) for(const auto& [x,y]:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	
	const int base = n / k;
	const int dis = n % k;

	ll ans = pow(base, 3);

	if (k % 2 == 0) {
		ll t = base;
		if (dis >= k / 2) { ++t; }
		ans += pow(t, 3);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
  {
  int N,d[N],S,i,j;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
    scanf("%d",&d[i]);
    }
  S=0;
  for(i=0;i<N;i++)
    {
    for(j=i;j<N;j++)
      {
       S=S+d[i]*d[j+1];
      }
    }
  printf("%d",S);
  return 0;
  }

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			string s = cin.Next();

			var conds = new Tuple<bool, bool>[] {
				new Tuple<bool, bool>(true, true),
				new Tuple<bool, bool>(true, false),
				new Tuple<bool, bool>(false, true),
				new Tuple<bool, bool>(false, false),
			};

			var sim = new bool[n + 1];
			foreach (var cond in conds) {
				sim[0] = cond.Item1;
				sim[1] = cond.Item2;
				for (int i = 2; i < n + 1; i++) {
					sim[i] = (sim[i - 1] ^ s[i - 1] == 'o') ? !sim[i - 2] : sim[i - 2];
				}

				bool prev = (sim[0] ^ s[0] == 'o') ? !sim[1] : sim[1];
				if (sim[0] == sim[n] && sim[n - 1] == prev) {
					var result = new char[n];
					for (int i = 0; i < n; i++) {
						result[i] = sim[i] ? 'S' : 'W';
					}

					Console.WriteLine(new string(result));
					return;
				}
			}

			Console.WriteLine(-1);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

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

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

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

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}

int main() {
    long int n, a, b;
    cin >> n >> a >> b;
    if (a+b == 0) {
        cout << 0 << endl;
    }else {
        long int k = n / (a+b);
        long int t = n - k*(a+b);
        if (0 <= t && t <= a) {
            cout << k*a + t << endl;
        }else {
            cout << (k+1)*a << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

int main(){
    ll X,Y,Z;
    cin >> X>> Y >> Z;
    cout << Z << ' ' << X << ' '<< Y << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int main(){
   ll N;
   int ai, i;
   cin >> N;
   vector<ll> count(N, 0);
   for(i=0;i<N-1;i++){
       cin >> ai;
       count.at(ai-1) += 1;
   }
   for(i=0;i<N;i++){
       cout << count.at(i) << endl;
   }

    return 0;
}


Measured memory_bytes: 4440