akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
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; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string X; cin >> X;

    stack<char> st;
    for(auto c:X){
        if(st.empty()){
            st.push(c);
        }else{
            if(st.top()=='S' && c == 'T'){
                st.pop();
            }else{
                st.push(c);
            }
        }
    }
    res = st.size();
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 3724
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if(x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26096
#include<stdio.h>
int main(){
	int a[10],i,j,k,temp;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				temp=a[j];
				a[j]=a[i];
				a[i]=temp;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int right = 0;
    ll sum = 0;
    ll ans = 0;
    for (int left = 0; left < N; left++) {
        while (right < N && (sum ^ A[right]) == (sum + A[right])) {
            sum += A[right];
            right++;
        }
        ans += right - left;
        if (left == right) right++;
        else {
            sum -= A[left];
        }
    }

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

Measured memory_bytes: 1024
K = int(input())
k =9
i = 10
if K > 9:
    while True:
        # print(i)
        flag = True
        I  = list(map(int,list(str(i))))
        for l in range(len(I)-1):
            if abs(I[l]-I[l+1]) > 1:
                flag = False
                if I[l] < I[l+1]:
                    i = i -i%(10**(len(I)-l-1)) + 10**(len(I)-l-1) -1
                else:
                    i = i -i%(10**(len(I)-l-1)) + (I[l]-1)*10**(len(I)-l-2) -1
                break
        if flag == True:
            k +=1
        
        # print("k = {}".format(k))
        
        if k == K:
            break
        
        i+=1
    print(i)  
else:
    print(K)
  

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int X, K;
    cin >> K >> X;
    rep (i, (K - 1) * 2 + 1) {
        if (i != 0) cout << " ";
        cout << X - K + 1 + i;
    }   
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int H, A;
	
	scanf ("%d %d", &H, &A);
	
	if (H%A == 0){
		printf("%d", H/A);
	}
	
	else{
		printf("%d",(H/A)+1);
	}
		

return 0;	
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mk make_pair
using namespace std;
int main()
{
	string s;
	cin>>s;
	ll i,n;
	cin>>n;
	for(i=0;i<s.size();i+=n){
		cout<<s[i];
	}
}

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

int main()
{
    
    int n, m;
    cin >> n >> m;
    int digit = n;

    int s[m], c[m];
    for(int i=0; i<m; i++){
        cin >> s[i] >> c[i];
    }
    
    int start = std::pow(10.0, (float)(digit-1)); 
    int end = start*10;
    if(start == 1) start = 0;
    //cout << digit << "," << start << endl;

    int ans = 0;
    
    for(int i=start; i<end; i++){
        std::string str = std::to_string(i);
        
        bool ok = true;
        for(int j=0; j<m; j++){
            //cout << str << "," << str[s[j]-1] << "," << c[j] << endl;
            if(str[s[j]-1] != (char)((c[j])+'0')){
                ok = false;
                break;
            }
            //cout << "ok!" << endl;
        }
        if(ok == true){
        cout << i << endl;
        return 0;
        }
    }
    cout << "-1" << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    int right = 0;
    ll s = 0, x = 0;
    for (int left = 0; left < n; left++) {
        while (right < n && s + a[right] == (x ^ a[right])) {
            s += a[right];
            x ^= a[right];
            right++;
        }
        ans += right - left;
        if (right == left) {
            right++;
        } else {
            s -= a[left];
            x ^= a[left];
        }
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  cin>> N;
  for(int a= 1;a<=9;a++)for(int b= 1;b<=9; b++){
      if(a*b==N){
        cout<< "Yes"<< endl;
        return 0;
      }
  }
  cout<< "No"<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int h, w, i, j, m[52][52], around, count = 0, flag = 0;
  char s[50][51];

  scanf("%d %d", &h, &w);

  for (i = 0; i < 52; i++) {
    for (j = 0; j < 52; j++) {
      m[i][j] = 0;
    }
  }

  for (i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }

  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        m[i+1][j+1] = 1;
      }
    }
  }

  for (i = 1; i < h+1; i++) {
    for (j = 1; j < w+1; j++) {
      around = m[i-1][j] + m[i+1][j] + m[i][j-1] + m[i][j+1];
      if ((m[i][j] == 1) && (around == 0)) {
        count = 1;
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }

  if (count == 0) {
    printf("Yes\n");
  }else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main(){
  int T;
  string record;
  cin >> T;
  while(T--){
    cin >> record;
    map<int, char> train;
    int now = 0;
    for(int i = 0 ; i < record.size(); i+=3){
      train[now] = record[i];
      if(record[i+1] == '<') now--;
      else now++;
    }
    
    for(map<int, char>::iterator it = train.begin() ; it != train.end() ; it++){
      cout << it->second;
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int dp[10][11];
void init(){
    for (int i=0;i<10;++i) dp[0][i]=1;
    dp[0][10]=1;
    for (int i=1;i<10;++i){
        for (int j=0;j<10;++j){
            for (int k=j-1;k<=j+1;++k){
                if (k<0 || k>9) continue;
                dp[i][j]+=dp[i-1][k];
            }
        }
        for (int j=1;j<=10;++j) dp[i][10]+=dp[i-1][j];
    }
}
int digits[10];
void solve(int d,int x,int k){
    if (d<0) return;
    int l,r;
    if (x==10){
        if (dp[d][10]>=k) {solve(d-1,10,k); return;}
        k-=dp[d][10];
        l=1;
        r=9;
    } else {
        l=max(0,x-1);
        r=min(9,x+1);
    }
    for (int i=l;i<=r;++i){
        if (dp[d][i]>=k){
            digits[d]=i;
            solve(d-1,i,k);
            return;
        } else k-=dp[d][i];
    } 
}
int main(){
    init();
    //for (int i=0;i<10;++i) cout<<dp[i][10]<<' ';
    int n;
    cin>>n;

    memset(digits,0,sizeof(digits));
    solve(9,10,n+1);
    int st=9;
    while (st>0 && digits[st]==0) --st;
    for (int i=st;i>=0;--i) cout<<digits[i];
    cout<<endl;


    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=21;
const int MOD=1e9+7;

int n;
bool g[N][N];
int dp[N][1<<N];
void Add(int &x,int y)
{
	x+=y;
	if(x>=MOD) x-=MOD;
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
		scanf("%d",&g[i][j]);
	for(int i=0;i<n;i++)
		if(g[0][i]) dp[0][1<<i]=1;
	for(int i=1;i<n;i++)
	for(int mask=0;mask<(1<<n);mask++) if(dp[i-1][mask])
	for(int j=0;j<n;j++) if(g[i][j] && !(mask&(1<<j)))
		Add(dp[i][mask|(1<<j)],dp[i-1][mask]);
	printf("%lld",dp[n-1][(1<<n)-1]);
	
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

const int N = 1e6 + 10;
int a[N];

void solve()
{
   for(int i=1;i<=100;i++)
       for(int j=1;j<=100;j++)
       for(int k=1;k<=100;k++)
   {
       a[(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(i*k)]++;
   }
    
   int n;
    cin >> n;
    
   f(i,n) cout << a[i+1] << '\n'; 
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int d;
    cin >> d;

    if (d == 25) cout << "Christmas" << endl;
    if (d == 24) cout << "Christmas Eve" << endl;
    if (d == 23) cout << "Christmas Eve Eve" << endl;
    if (d == 22) cout << "Christmas Eve Eve Eve" << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let mut ps = vec![];
    for _ in 0..n {
        let x: i64 = sc.cin();
        let y: i64 = sc.cin();
        ps.push((x, y));
    }

    let mut ans: i64 = 4 * 1000000000000000000;

    for i in 0..n {
        for j in 0..n {
            if i == j { continue }
            if ps[i].0 >= ps[j].0 { continue }
            let x0 = ps[i].0;
            let x1 = ps[j].0;
            for k in 0..n {
                for l in 0..n {
                    if k == l { continue }
                    if ps[k].1 >= ps[l].1 { continue }
                    let y0 = ps[k].1;
                    let y1 = ps[l].1;

                    let mut count = 0;
                    for p in ps.iter() {
                        if x0 <= p.0 && p.0 <= x1 && y0 <= p.1 && p.1 <= y1 {
                            count += 1;
                        }
                    }
                    // trace!(((x0, x1), (y0, y1), count));
                    if count >= m {
                        ans = min(ans, (x1 - x0) * (y1 - y0));
                    }
                }}}}

    println!("{}", ans);

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


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

void Solve(){
 	string s;
 	cin>>s;
 	int n = s.size();
 	n--;
 	if(s[n] == '3') cout<<"bon\n";
 	else if(s[n] == '0' || s[n] == '1' || s[n] == '6' || s[n] == '8') cout<<"pon\n";
 	else cout<<"hon\n";
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin>>T;
	while(T--){
		Solve();
	}
}

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

using namespace std;

struct Panel {
    string name;
    int x1, y1, x2, y2;
    vector<Panel> child;
    
    Panel(){}    
    Panel(string name, int x1, int y1, int x2, int y2) :
        name(name), x1(x1), y1(y1), x2(x2), y2(y2) {}
};

string s;
int idx;

string get_name()
{
    string name;
    ++idx;
    while (s[idx] != '>') {
        name += s[idx];
        ++idx;
    }
    ++idx;
    return name;
}

int s2i(string &str)
{
    stringstream ss(str);
    int num;
    ss >> num;
    return num;
}

int get_val()
{
    string val;
    while (isdigit(s[idx])) {
        val += s[idx];
        ++idx;
    }
    return s2i(val);
}

void parse(Panel &p)
{
    while (s[idx] == '<' && s[idx+1] != '/') {
        string name = get_name();
        int x1 = get_val(); ++idx;
        int y1 = get_val(); ++idx;
        int x2 = get_val(); ++idx;
        int y2 = get_val();
        Panel panel(name, x1, y1, x2, y2);
        parse(panel);
        p.child.push_back(panel);
        while (s[idx] != '>') {
            idx++;
        }
        idx++;
    }    
}

bool get_panel(int x, int y, const Panel &p)
{
    for (int i = 0; i < (int)p.child.size(); i++) {
        Panel np = p.child[i];
        if (np.x1 <= x && x <= np.x2 && np.y1 <= y && y <= np.y2) {
            if (!get_panel(x, y, np)) {
                cout << np.name << " " << np.child.size() << endl;
            }
            return 1;
        }
    }
    return 0;
}

int main()
{
    int n, x, y;
    while (cin >> n >> s, n) {
        Panel p;
        p.name = "#"; p.x1 = p.y1 = -1; p.x2 = p.y2 = 10001;
        idx = 0;
        parse(p);
        for (int i = 0; i < n; i++) {
            cin >> x >> y;
            if (!get_panel(x, y, p)) {
                cout << "OUT OF MAIN PANEL 1" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int cnt  = 0;
    for(int i = 0; i < n - 1; i++){
        int minIndex = i;
        for(int j = i + 1; j < n; j++){
            if(a[j] < a[minIndex]){
                minIndex = j;
            }
        }
        if(minIndex != i){
            int new_a = a[minIndex];
            a[minIndex] = a[i];
            a[i] = new_a;
            cnt++;
        }
    }
    for(int i = 0; i < n; i++){
        cout << a[i];
        if(i == n - 1){
            cout << endl;
        } else {
            cout << " ";
        }
    }
    cout << cnt << endl;
    
}


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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using graph=vector<vector<int>>;
vector<int> col;
int N;
bool dfs(const graph &g,int x,int cur=0){
  col[x]=cur;
  for(auto nx:g[x]){
    if(col[nx]!=-1){
      if(col[nx]==col[x]) return false;
      continue;
    }
    if(!dfs(g,nx,1-cur)) return false;
  }
  return true;
}
int dist(const graph &g,int x){
  queue<int> q;
  vector<bool> seen(N,false);
  int d = 0;
  vector<int> dis(N);
  dis[x]=0;
  q.push(x);
  seen[x]=true;
  while(!q.empty()){
    int t = q.front();
    q.pop();
    for(auto nx:g[t]){
      if(seen[nx]) continue;
      seen[nx]=true;
      q.push(nx);
      dis[nx]=dis[t]+1;
    }
  }
  for(auto t:dis) chmax(d,t);
  return d;
}
      

int main() {
  cin>>N;
  vector<string> E(N);
  vector<vector<int>> g(N);
  col.assign(N,-1);
  for(int i = 0; i < N; i++) cin>>E[i];
  for(int i  =0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(E[i][j]=='1') {
        g[i].push_back(j);
        g[j].push_back(i);
      }
    }
  }
  if(!dfs(g,0))cout<<-1<<endl;
  else{
    int ans = 0;
    for(int i = 0; i < N; i++)chmax(ans,dist(g,i));
    cout<<ans+1<<endl;
  }
}

Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

//vint t(100005, -1);

struct node{
	int parent;
	vint child;
	int number;
};
vector<node> t(100005);
int n,m,u,v;
vvint a;
vint parent;
vint depth;

int dfs(int num, int par){
	parent[num] = par;
	int d = 0;
	rep(i, a[num].size()){
		if(a[num][i] == par)continue;
		chmax(d, 1+dfs(a[num][i], num));
	}
	depth[num] = d;
	return d;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	cin>>n>>u>>v;
	a =  vvint(n);
	parent = vint(n);
	depth = vint(n);
	rep(i, n-1){
		int c,d;cin>>c>>d;
		a[c-1].push_back(d-1);
		a[d-1].push_back(c-1);
	}

	dfs(v-1, -1);
	rep(i, n){
		debug("%d:%d %d\n", i, parent[i], depth[i]);
	}
	int dd = 0;
	int ddpos = u-1;
	while(parent[ddpos]!=-1){
		dd++;
		ddpos = parent[ddpos];
	}

	int esd = depth[u-1];
	int cou = 1;
	int now = u-1;
	rep(i, (dd - 1)/2){
		now = parent[now];
		chmax(esd, depth[now] - cou);
		cou++;
	}
	debug("eee %d %d\n", dd, esd);
	cout << dd+esd-1 << endl;

	return 0;
}


Measured memory_bytes: 20480
import itertools

n=int(input())

p=list(map(int,input().split()))

q=list(map(int,input().split()))

l=range(1,n+1)

a=0

b=0

cnt=0

for i in itertools.permutations(l,n):
  i=list(i)
  if i==p:
    a=cnt
  if i==q:
    b=cnt

  cnt+=1

print(abs(a-b))

Measured memory_bytes: 40300
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using ld = long double;
using ll = long long;

template<typename Head> void print(Head head) {std::cout << head << std::endl;}
template<typename Head, typename... Tail> void print(Head head, Tail... tail) {
  std::cout << head << " ";
  print(tail...);
}

ll H, W;

int main()
{
  std::cin >> H >> W;
  std::vector< std::string > grid(H, std::string(W, 'X'));
  for (ll y = 0; y < H; y++) {
    for (ll x = 0; x < W; x++) {
      std::cin >> grid[y][x];
    }
  }

  for (ll y = 0; y < H; y++) {
    print(grid[y]);
    print(grid[y]);
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.next();
        String b = scanner.next();
        String c = scanner.next();


        System.out.print(a.substring(0, 1) + b.substring(0, 1) + c.substring(0, 1));
    }
}


Measured memory_bytes: 20948
import math
s = input().rstrip().split(' ')
x0 = float(s[0])
y0 = float(s[1])
x1 = float(s[2])
y1 = float(s[3])
dis = math.sqrt((x1 - x0) ** 2 + (y1 - y0) ** 2)
print(dis)



Measured memory_bytes: 5648
#include <cstdio>

long long N, A, B;
long long res;

int main()
{
	scanf("%lld %lld %lld", &N, &A, &B);
	res = B*(N-1)+A - (A*(N-1)+B ) + 1;
	if(res < 0)
		res = 0;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
const long long INF = (1ull<<63) - 1;

struct P
{
	int x, y;
	P(int x=0, int y=0) : x(x), y(y) {}
	friend ostream &operator <<(ostream &os, const P &a) {
		return os << '(' << a.x << ',' << a.y << ')';
	}
	bool operator <(const P &r) const {
		if (x == r.x) return y < r.y;
		return x < r.x;
	}
};

int main() {
	int n, k;
	cin >> n >> k;
	vector<P> p(n);
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		p[i].x = x[i], p[i].y = y[i];
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	long long ans = INF;
	for (int ix = 0; ix < n; ix++) {
		int xl = x[ix];
		for (int jx = ix; jx < n; jx++) {
			int xr = x[jx];
			for (int iy = 0; iy < n; iy++) {
				int yl = y[iy];
				for (int jy = iy; jy < n; jy++) {
					int yr = y[jy];
					int s = 0;
					for (P &e : p) {
						if (e.x >= xl && e.x <= xr && e.y >= yl && e.y <= yr) s++;
					}
					if (s >= k) {
						long long now = (long long)(xr - xl) * (yr - yl);
						ans = min(ans, now);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int A,B,C;
	cin >> A >> B >> C;
	if(A==B) cout << C << endl;
	else if(B==C) cout << A << endl;
	else cout << B << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll a, b;
    cin >> a >> b;
    map<ll, ll> a_factors, b_factors;
    for(int i = 2; i <= sqrt(a); i++) {
        while(a % i == 0) {
            a_factors[i]++;
            a /= i;
        }
        if(a == 1) break;
    }
    if(a != 1) a_factors[a]++;

    for(int i = 2; i <= sqrt(b); i++) {
        while(b % i == 0) {
            b_factors[i]++;
            b /= i;
        }
        if(b == 1) break;
    }
    if(b != 1) b_factors[b]++;

    
    ll ans = 1;
    for(auto x : a_factors) {
        if(b_factors.count(x.first)) ans++; 
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define endl '\n'
const ll mod = 998244353;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll ans[n]={0};
    for(int i=1;i<n;i++){
        ans[i] = 1e16;
        for(int j=i-1;j>=max(ll(0),(i-k));j--){
            ans[i] = min(ans[i],ans[j]+abs(arr[i]-arr[j]));
        }
    }
    cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
 
using namespace std;
int main() {
    unsigned int n;
    int rmin = 1000000;
    int rmax = -1000000;
    long long sum = 0;
    cin >> n;
    for (unsigned int i = 0; i < n; ++i) {
                int x;
 	   cin >> x;
	 rmin = min(rmin, x);
	 rmax = max(rmax, x);
	 sum += x;
    }
    cout << rmin << " " << rmax << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3120
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
////@formatter:on
//endregion


int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    make(int, n);
    VVI dp(10, VI(10));
    for (int i = 1; i <= n; ++i) {
        int num = i;
        while (num >= 10) {
            num /= 10;
        }
        dp[num][i % 10]++;
    }
    int ans = 0;
    for (int i = 1; i < 10; ++i) {
        for(int j = 1; j < 10; ++j){
            ans += dp[i][j] * dp[j][i];
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define INF 0x3f3f3f3f
#define f1(n) for(int i=0 ; i<n ; i++)
#define f2(m) for(int j=0 ; j<m ; j++)
#define ll long long
typedef pair<int, int> iPair;
const double epsilon = 1e-7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  unordered_map<string, int> m;
  string s;
  string verdicts[] = {"AC", "WA", "TLE", "RE"};
  for (auto verdict: verdicts)
    m[verdict] = 0;
  f1(n) {
    cin >> s;
    m[s]++;
  }
  for (auto verdict: verdicts)
    cout << verdict << " x " << m[verdict] << endl;
  return 0;
}

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

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()

using namespace std;

const int MXN = (int)1e6 + 10;
const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 10;
const double EPS = (double)1e-9;
const double PI = (double)acos(-1.0);

llong a[MXN], b[MXN];
llong ans;
int n;

int main(){
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0);
  cin >> n;
  for(int i = 1; i <= n; ++i){
    cin >> a[i] >> b[i];
  }
  llong tmp, cur = 0LL;
  for(int i = n; i >= 1; --i){
    a[i] += cur;
    tmp = (a[i] + b[i] - 1LL) / b[i];
    b[i] *= tmp;
    ans += b[i] - a[i];
    cur += b[i] - a[i];
  }
  cout << ans << "\n";
  return 0;
}


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

string s="";
int ans = 0;

unsigned int find( unsigned int j,char c ){
  for(  ;j<s.length();++j )
    if( s[j]==c )
      return j;
  return j;
}

void solve( unsigned int i,unsigned int j,int sum){
  /*
  cout << "solve : i="<<i<<" j="<<j<< " sum="<<sum
       << " slen=" << s.length() <<  endl;
  */
  unsigned int jj;

  if( i<0 ) return;
  if( j>=s.length() ) return;
  
  //  cout << "switch : " << s[i] <<endl;

  // s[i] ðg¤ê
  switch( s[i] ){
  case 'i':case 'w': break;
  case '(': jj=find( j,')'); break;
  case ')': jj=find( j,'('); break;
  case '{': jj=find( j,'}'); break;
  case '}': jj=find( j,'{'); break;
  case '[': jj=find( j,']'); break;
  case ']': jj=find( j,'['); break;
  }
  //  cout << "jj="<<jj<<endl;
  if( jj<s.length() ){
    if( ans<sum+2 ) ans = sum+2;
    if( i!=0 )
      solve( i-1,jj+1,sum+2 );
  }
  // s[i] ðgíÈ¢ê
  if( i!=0 )
    solve( i-1,j,sum );
}


int main(){
  unsigned int st=0,en=0;

  cin>>s;
  //  cout << "s=" << s << " len=" << s.length() << endl;

  // w ðT·
  while( (st = s.find( "iwi",en ))!=string::npos){
    if( ans<3 ) ans=3;
    en=st+2;
    if( st!=0 )
      solve( st-1,en+1,3 );
  }

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

Measured memory_bytes: 0
import java.util.Scanner;

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

		if ((A <= 9) && (B <= 9)) {
			System.out.println(A * B);
		} else {
			System.out.println(-1);
		}

		sc.close();
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


const int mod = 1000000007;
int cost[101][2];

int fun(int x)
{
  int ans = 0;

  while(x%100 == 0)
  {
    x/=100;
    ans++;
  }
  return ans;
}
int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

    
    int d,n;
    cin >> d >> n;


    int k = 0;

   
    int ans = 0;

    int p  =0;
    while(ans < n)
    {
      p++;
      if(fun(p) == d)ans++;
    }
    cout << p;







    return 0; 
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 998244353;

ll check(ll N)
{
	ll ans = INF;
	for (ll i = 1; i * i <= N; i++)
	{
		if (N % i == 0)
		{
			ll target = N / i;
			ll temp = 0;
			while (target >= 1)
			{
				target /= 10;
				temp++;
			}
			ans = min(ans, temp);
		}
	}
	return ans;
}

int main()
{
	ll N;
	cin >> N;
	const auto& res = check(N);
	cout << res << endl;
	return 0;
}

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

#define ll long long



using namespace std;

const int N_MAX = 302;
const ll INF = 1000000000000001;

int n, k;

int h[N_MAX];

ll dp[N_MAX][N_MAX][N_MAX];

vector <pair <int, int> > v;

int pos[N_MAX];

ll aib1[N_MAX][N_MAX][N_MAX];
ll aib2[N_MAX][N_MAX][N_MAX];

void update1 (int i, int j, int pos, ll val)
{
    pos++;
    for(int x = pos; x <= n + 1; x += x & (-x))
        aib1[i][j][x] = min(aib1[i][j][x], val);
}
void update2 (int i, int j, int pos, ll val)
{
    pos++;
    for(int x = pos; x >= 1; x -= x & (-x))
        aib2[i][j][x] = min(aib2[i][j][x], val);
}

ll query1 (int i, int j, int pos)
{
    pos++;
    ll ans = INF;
    for(int x = pos; x >= 1; x -= x & (-x))
        ans = min(ans, aib1[i][j][x]);
    return ans;
}
ll query2 (int i, int j, int pos)
{
    pos++;
    ll ans = INF;
    for(int x = pos; x <= n + 1; x += x & (-x))
        ans = min(ans, aib2[i][j][x]);
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> h[i];
        v.push_back(make_pair(h[i], i));
    }
    sort(v.begin(), v.end());
    for(int i = 1; i <= n; i++)
        pos[v[i - 1].second] = i;
    for(int i = 0; i <= n + 1; i++)
        for(int j = 0; j <= k; j++)
            for(int x = 0; x <= n + 1; x++)
                aib1[i][j][x] = aib2[i][j][x] = INF;
    update1(0, 0, 0, 0);
    update2(0, 0, 0, 0);
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= k; j++)
        {
            for(int x = 0; x <= n; x++)
            {
                dp[i][j][x] = INF;
                if(j == 0 && x != i)
                    continue;
                if(j > 0)
                    dp[i][j][x] = dp[i][j - 1][x];
                if(x == i)
                {
                    dp[i][j][x] = min(dp[i][j][x], query1(i - 1, j, pos[x]));
                    dp[i][j][x] = min(dp[i][j][x], query2(i - 1, j, pos[x]) - h[x]);
                }
                else
                {
                    dp[i][j][x] = min(dp[i][j][x], query1(i - 1, j - 1, pos[x]));
                    dp[i][j][x] = min(dp[i][j][x], query2(i - 1, j - 1, pos[x]) - h[x]);
                }
                update1(i, j, pos[x], dp[i][j][x]);
                update2(i, j, pos[x], dp[i][j][x] + h[x]);
            }
        }
    }
    ll ans = INF;
    for(int i = 0; i <= n; i++)
        ans = min(ans, dp[n][k][i] + h[i]);
    cout << ans << "\n";
    return 0;
}


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

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        ntok();
        String s = spar();
        out.println(s.indexOf('7') != -1 ? "Yes" : "No");

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}


Measured memory_bytes: 32684
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, N);

  map<char, i64> cnt;
  rep(i, N) {
    var(string, s);
    ++cnt[s.front()];
  }

  i64 res = 0;
  string march = "MARCH";

  for (int i = 0; i < 5; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      for (int k = j + 1; k < 5; ++k) {
        i64 c1 = cnt[march[i]], c2 = cnt[march[j]], c3 = cnt[march[k]];
        res += c1 * c2 * c3;
      }
    }
  }

  outl(res);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back


using namespace std;


int main() {
  //cout << "Hello world";
  int n;
  cin >> n;
  int arr[n];
  unordered_map<ll, ll> m;
  ll summ = 0;

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

  //cout << summ << endl;

  int q;
  cin >> q;

  for(int i = 0; i < q; i++) {
    ll x, y;
    cin >> x >> y;

    summ -= m[x] * x;
    summ += m[x] * y;
    m[y] += m[x];
    m[x] = 0;
    cout << summ << endl;
  }
}


Measured memory_bytes: 7036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i = 1; i < n; ++i){
        if(s[i] == s[i - 1]){
            if(s[i] == '0') s[i] = '1';
            else s[i] = '0';
            ans++;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <fstream>

using namespace std;

template<class T> inline T cabs(const T &x) { return x > 0 ? x : (-x); }
template<class T> inline T gcd(const T &x, const T &y) { return (y == 0) ? x : gcd(y, x % y); }
template<class T> inline T sgn(const T &x) { return (x > 0) - (x < 0); }

#define dbg(x) cout << #x << " = " << (x) << endl
#define dbg2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define dbg3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl
#define dbg4(x,y,z,w) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #w << " = " << w << endl

#define out(x) cout << (x) << endl
#define out2(x,y) cout << (x) << " " << (y) << endl
#define out3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define out4(x,y,z,w) cout << (x) << " " << (y) << " " << (z) << " " << (w) << endl


int main()
{
    int N;
    cin >> N;
    int step = 0, sum = 0;
    do {
        step ++;
        sum += step;
    } while( sum < N );
    int skip = sum - N;
    step = 0, sum = 0;
    do {
        step ++;
        if( step == skip ) ;
        else {
            printf("%d\n", step);
            sum += step;
        }
    } while( sum < N );
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
using namespace std;

int main()
{
	long double aa, bb;
	cin >> aa >> bb;
	cout << (int64)(aa * bb) << endl;
	return 0;
}

Measured memory_bytes: 3728
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
import sys     
N = int(input())
if N == 1:
    print(0)
    sys.exit()

fact = factorization(N)
fact_num = []
fact_num2 = []
 

for i in range(len(fact)):
    fact_num.append(fact[i][0])
    fact_num2.append(fact[i][1])

cnt=0

for j in range(max(fact_num2)+1):
    for i in range(len(fact)):
        if N%fact_num[i]==0 and N%(fact_num[i]**(j+1))==0:
            N = N/(fact_num[i]**(j+1))
            cnt+=1

            if N==1:
                print(cnt)
                sys.exit()
print(cnt)

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

int n;long long k;
int ar[2001];
long long const mod = 1e9 + 7;

int getInvers()
{
	int ret = 0;
	for (int i = 2; i <= n; ++i) for (int j = i-1; j >= 1; --j)
	{
		if (ar[i] < ar[j]) ret++;
	}
	return ret;
}

int main()
{
	cin >> n >> k;

	for (int i = 1; i <= n; ++i)
		cin >> ar[i];

	long long a = getInvers();
	sort(ar+1 ,ar+n+1, greater<int>());
	long long b = getInvers();

	a = (k * a) % mod;
	b = (((k * (k-1) / 2) % mod) * b) % mod;

	cout << (a + b) % mod << '\n';
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll x;
    cin >> x;
    ll ans = 8 - (x-400)/200;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; i+j <= n; ++j) {
            string t = s.substr(i, j);
            int valid = 1;
            for (int k = 0; k < j; ++k) {
                if(t[k] != 'A' && t[k] != 'T' && t[k] != 'G' && t[k] != 'C') valid = 0;
            }
            if(valid) ans = max(ans, j);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a;
		ArrayList<String> list = new ArrayList<String>();
		
		//??\???????????´??°?????????????????????
		for (int i = 0; i < n; i++) {
			a=sc.nextInt();
			list.add(String.valueOf(a));
			list.add(" ");
		}
		//????????????????????????
		list.remove(list.size()-1);
		//???????????????
		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(list.size()-1-i));
		}
		//??????
		System.out.println();
	}
}

Measured memory_bytes: 19660