akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;


public class Main{
	

	 static List <Integer>[] Edge ;
	 static int []ans;
	 static boolean[]visit;
	 static Deque <Integer>que;
	 static int inf = 1000000000;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		Edge = new ArrayList [n];
		for(int i = 0 ; i < n ;i++) {
			Edge[i] = new ArrayList <Integer>();
		}
		
		for(int i = 0 ; i < m ;i++) {
			int a = Integer.parseInt(sc.next())-1;
			int b = Integer.parseInt(sc.next())-1;
			Edge[a].add(b);
			Edge[b].add(a);
		}
		
		que = new ArrayDeque<Integer>();
		visit = new boolean [n];
		ans = new int [n];
		Arrays.fill(ans, -1);
		ans[0] = 0;
		visit[0] = true;
		
		BFS(n,0);
		
		for(int i = 0 ; i < n ;i++) {
			if(ans[i] == -1) {
				System.out.println("No");
				return;
			}
		}
		
		System.out.println("Yes");
		
		for(int i = 1 ; i < n ;i++) {
			System.out.println(ans[i]);
		}
		
	

	}
	
	static void BFS(int n ,int st) {
		
		for(int num : Edge[st]) {
			if(!visit[num]) {
				visit[num] = true;
				ans[num] = st +1;
				que.addLast(num);
			}
		}
		
		if(que.size()== 0) {
			return;
		}
		BFS(n,que.poll());
	}
}



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

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v.at(i);
  map<int, int> Modd, Meven;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      if (Modd.count(v.at(i))) Modd[v.at(i)]++;
      else Modd[v.at(i)] = 1;
    }
    else {
      if (Meven.count(v.at(i))) Meven[v.at(i)]++;
      else Meven[v.at(i)] = 1;
    }
  }
  vector<pair<int, int>> odd, even;
  for (auto p : Modd) {
    odd.push_back(make_pair(p.second, p.first));
  }
  for (auto p : Meven) {
    even.push_back(make_pair(p.second, p.first));
  }
  sort(odd.begin(), odd.end(), greater<pair<int, int>>());
  sort(even.begin(), even.end(), greater<pair<int, int>>());
  if (odd.at(0).second != even.at(0).second) {
    cout << n - odd.at(0).first - even.at(0).first << endl;
  }
  else if (odd.size() == 1 || even.size() == 1) {
    if (odd.size() == 1 && even.size() == 1) cout << n/2 << endl;
    else if (odd.size() == 1) cout << n/2 - even.at(1).first << endl;
    else cout << n/2 - odd.at(1).first << endl;
  }
  else {
    int ans1 = n - odd.at(1).first - even.at(0).first;
    int ans2 = n - odd.at(0).first - even.at(1).first;
    cout << min(ans1, ans2) << endl;
  }
}


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

int main()
{
string s;
cin>>s;
ll c=0;
for(ll i=0;i<s.length()-1;i++)
{
    if(s[i]==s[i+1] and s[i]=='0')
    {
        s[i+1]='1';
        c++;
    }
    else if(s[i]==s[i+1] and s[i]=='1')
    {
        s[i+1]='0';
        c++;
    }
    
}
cout<<c;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main() {

	int n, s = 0;

	vector<int> a(20), b(20), c(20);

	cin >> n;

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

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

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

	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i] - 1) {
			s = s + c[a[i - 1] - 1];
		}
	}

	cout << s << endl;

	return 0;
}


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

int main() {
  int i,N;
  cin >> N;
  vector< pair<int,string> > A;
  for(i=0;i<N;i++) {
    string former;
    cin >> former;
    bool flag=false;
    int num;
    for(num=0;num<A.size();num++) {
      if(A[num].second==former) {
        flag=true;
        break;
      }
    }
    if(flag) {
      A[num].first++;
    } else {
      A.push_back(make_pair(1,former) );
    }
  }

  int M;
  cin >> M;
  for(i=0;i<M;i++) {
    string later;
    cin >> later;
    int num;
    for(num=0;num<A.size();num++) {
      if(A[num].second==later) {
        if(A[num].first>0) A[num].first--;
        break;
      }
    }
  }
    sort(A.begin(),A.end());
    cout << A[A.size()-1].first << endl;
}

Measured memory_bytes: 256
import numpy as np
#from numba import njit

#(N, K) = map(int, input().split())
#A = np.array(list(map(int, input().split())))
S = input()
T = input()

#@njit


count = 0
for i in range(0,len(S)):
    if S[i] != T[i]:
        count += 1


print(count)


Measured memory_bytes: 27240
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#include<string.h>

using namespace std;

int main(){
    string temp;
    vector<char> c(3);
    long long sum=0;

    //do{
        cin >> temp;
        //cout << c.at(0) << endl;
        //sum+=c.at(0)-'0';
    //}while();
    for(int i=0;i<strlen(temp.c_str());i++){
        sum+=temp[i]-'0';
    }

    if(sum%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return(0);
}


Measured memory_bytes: 3720
#include <iostream>
using namespace std;
int main(){
  string str;
  cin >> str;
  for(int i = 0 ; i < (int)str.size() ; i++ ){
    if('D' <= str[i] && str[i] <= 'Z' ){
      str[i]-=3;
      cout << str[i];
    }else {
      str[i]+=23;
      cout << str[i];
    }
  }
  cout << endl;
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/08  Problem: ABC 094 D / Link: http://abc094.contest.atcoder.jp/tasks/abc094_d  ----- */


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

	LL N; 
	cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	SORT(a);
	LL x = a.back();
	LL diff = LINF;
	LL y;
	FOR(i, 0, N-1) {
		if (diff > abs(x - 2*a[i])) {
			diff = abs(x - 2*a[i]);
			y = a[i];
		}
	}


	cout << x << " " << y << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 55
#define LL long long
#define int long long
using namespace std;
int n,d,x,alsz;
int co[N],fa[N],sz[N];
int w[N];
int bk[N*N*N*N];
inline void getans(int len,int cost,const int m=alsz*d){
	if(cost>x)return;
	for(int i=m;i>=len;--i)bk[i]=min(bk[i],bk[i-len]+cost);
}

inline void work1(int tal,const int m){
	memset(bk,0x3f,sizeof(int)*(m+1));
	bk[0]=0;
	for(int i=1;i<=n;++i){
		int al=tal;
		for(int j=0;(1<<j)<=al;++j){
			al-=1<<j;int len=(1<<j)*sz[i],cost=min(1ll+x,(1ll<<j)*co[i]);
			getans(len,cost,m);
		}
		int len=al*sz[i],cost=min(1ll+x,1ll*al*co[i]);
		getans(len,cost,m);
	}
}
int a[N];
inline bool cmp(const int &a,const int &b){
	return 1ll*sz[a]*co[b]>1ll*sz[b]*co[a];
}
inline void work2(){
	int m;
	if(d>n){d-=n;work1(n,m=alsz*n);}
	else {work1(d,m=alsz*d);d=0;}
	for(int i=1;i<=n;++i)a[i]=i;sort(a+1,a+n+1,cmp);
	int ans=0;
	for(int i=m,mi=x+1,j=1,sum=0,al=0;~i;--i){
		if(bk[i]>=mi||x-sum<bk[i])continue;
		mi=bk[i];
		while(a[j]>1&&x-sum-bk[i]>1ll*co[a[j]]*(a[j]==1?x:d)){
			al+=sz[a[j]]*d;
			sum+=co[a[j]]*d;
			++j;
		}
		ans=max(ans,(x-sum-bk[i])/co[a[j]]*sz[a[j]]+al+i);
	}
	cout<<ans<<endl;
}
main(){
	scanf("%lld%lld%lld",&n,&x,&d);
	scanf("%lld",&co[1]);
	for(int i=2;i<=n;++i)scanf("%lld%lld",&co[i],&fa[i]);
	for(int i=n;i;--i){
		++sz[i];
		sz[fa[i]]+=sz[i];co[fa[i]]+=co[i];
		co[fa[i]]=min(co[fa[i]],x+1);
		alsz+=sz[i];
	}
	work2();
	return 0;
}
/*
3 100 10
15
10 1
20 1

*/

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

int main ()
{
 	int n, r, ans;
  cin >> n >> r;
  if(n < 10)
  {
   	ans = 100 * (10 - n) + r; 
  }
  else
  {
    ans = r;
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n, INF);
    vector<ll> b(n - 1);
    REP(i, n - 1)
    {
        cin >> b[i];
        if (a[i] > b[i])
        {
            a[i] = b[i];
        }
        a[i + 1] = b[i];
    }
    cout << accumulate(ALL(a), 0) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long L[] = new long[N+1];
    L[0]=2;
    L[1]=1;
    for(int i=2;i<=N;i++){
      L[i]=L[i-1]+L[i-2];
    }
    System.out.println(L[N]);
  }
  

  
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005];
int main(){
	scanf("%d",&n);
	int mn = INF;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]); mn = min(mn,a[i]);
	}
	int cnt1 = 0,cnt2 = 0;
	for(int i=1;i<=n;i++){
		if(a[i] != mn && a[i] != mn+1){
			puts("No"); return 0;
		}
		if(a[i] == mn) cnt1++;
		else cnt2++;
	}
	int L,R;
	if(cnt2 == 0){
		if(mn == n-1 || n/2 >= mn){
			puts("Yes");
		}
		else{
			puts("No");
		}
		return 0;
	}
	else if(cnt2 == 1){
		puts("No"); return 0;
	}
	else{
		L = 1;
		R = cnt2/2;
	}
	if(cnt1+L <= mn+1 && mn+1 <= cnt1+R){
		puts("Yes");
	}
	else{
		puts("No");
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

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

    for(int i = 0; i <s.size(); i=i+2){
        cout << s[i];
    };

    cout << endl;

    return 0;
}

Measured memory_bytes: 512
n = int(input())
a_6 = [int(6**i) for i in range(1,10) if 6**i <= 10**5]
a_9 = [int(9**i) for i in range(1,10) if 9**i <= 10**5]
a = [1]
for i in a_6:
    a.append(i)
for i in a_9:
    a.append(i)
a.sort(reverse = True)
dp = [i for i in range(n+1)]
dp[0] = 0
for i in range(n+1):
    for j in a:
        if i+j <= n:
            dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[n])

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

int main(){
  int n, sum = 0;
  cin >> n;
  vector<int> vec(n);
  rep(i, n){
    cin >> vec[i];
    sum ^= vec[i];
  }
  rep(i, n){
    cout << (sum^vec[i]) << " ";
  }
}


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

#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000

vector<bool>prime(MAX, true);
vector<ll>fact(MAX);
vector<ll>factinv(MAX);

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a=(a * a) % MOD;
    }
    return res;
}

void getprime()
{
    for(ll i = 2;i < MAX; i++)
    {
        if(prime[i-1])
        {
            for(ll j = i*i; j < MAX; j += i)
                prime[j-1] = false;
        }
    }
}

void getfact()
{
    fact[0] = 1;
    factinv[0] = 1;
    
    for(ll i = 1; i < MAX; i++)
        fact[i] = (fact[i-1] * i)%MOD;
    
    for(ll i = 1; i < MAX; i++)
        factinv[i] = (factinv[i-1] * fastpower(i, MOD -2) )%MOD;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,n,m,q;
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
vector<int> to[100005] ;//隣接している頂点を管理
int n;

vector<int> dist;
void dfs(int v, int d=0, int p = -1){
	//今の頂点，今の距離，親
	dist[v] = d;
	for (int u:to[v]){
		if(u == p) continue;
		dfs(u,d+1,v);
	}
}
vector<int> calcDist(int s) {
	//dfsで書く
	dist = vector<int> (n);//distを長さnのベクターで持つ
	dfs(s);
	return dist;
}
int main()
{
	cin >> n;
	int s,t ;
	cin >> s >>t ;
	--s; --t;
	rep(i,n-1){
		int a,b; 
		cin >> a >>b; 
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<int> distS = calcDist(s); ; //sからの距離を持つ
	vector<int> distT = calcDist(t); ; //tからの距離を持つ
	int mx = 0;
	rep(i,n){
		if(distS[i] < distT[i]){
			mx = max(mx, distT[i]);
		}
	}
	int ans = mx - 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int N;
    cin >> N;
    int dig,sum;
    dig = log10(N);
    sum = 0;
    int a;
    for(int i = 0; i<= dig; i++){
       a = pow(10,i);
       sum += (N / a) % 10;
    }
    if( N % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll n,k;
    cin>>n>>k;
    ll x = n/k;

    ll p  = abs(n - x*k);
    ll q  = abs( n - (x+1)*k);

    cout<<min(p,q)<<endl;
}


Measured memory_bytes: 256
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

S = rs()

r = 0
ans = [0]*len(S)
for i, s in enumerate(S):
	if s == 'L':
		ans[i] += r//2
		ans[i-1] += r-r//2
		r = 0
	else:
		r += 1
l = 0
for i, s in enumerate(S[::-1]):
	if s == 'R':
		ans[~i] += l//2
		ans[~(i-1)] += l-l//2
		l = 0
	else:
		l += 1
print(*ans)


Measured memory_bytes: 80012
#include <stdio.h>
int main(void){
        int n,i,san,k;
        scanf("%d",&n);
        for(i=1;i<=n;i++){
                san=0;
                for(k=i;k>0;k/=10){
                        if(k%10==3){
                                san=1;
                                break;
                        }

                }
                if(i%3==0 || san==1)
                        printf(" %d",i);
        }
        puts("");
        return 0;
}


Measured memory_bytes: 2740
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
    string s,t;
    cin >> s >> t;
    for(int i=1;i<=s.size();i++)
    {
        rotate(s.begin(),s.begin()+1,s.end());
        if(s==t)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


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

int main() {
    string S; cin >> S;
    if (S.back() == 's') S += "es";
    else S += "s";
    cout << S << endl;
    return 0;
}

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

int w[100],v[100];
int n,W;
int dp[100][100000];
int knapsack(){
	memset(dp,0,sizeof(dp));
	dp[0][w[0]] = v[0];
	for(int i = 1;i < n;i++){
		int j;
		for(j = 0;j < w[i] && j <= W;j++){
			dp[i][j] = dp[i-1][j];
		}
		for(j = w[i];j <= W;j++){
			dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
		}
	}
	int ans = 0;
	for(int i = W;i >= 0;i--){
		if(dp[n-1][i] > ans) ans = dp[n-1][i];
	}
	return ans;
}

int solve(){
	int dp2[100][101][300];
	memset(dp2,0,sizeof(dp2));
	int w2[100];
	for(int i = 0;i < n;i++){
		w2[i] = w[i]-w[0];
	}
	dp2[0][1][w2[0]] = v[0];
	for(int i = 1;i < n;i++){
		for(int j = 1;j <= n;j++){
			int k;
			for(k = 0;k < w2[i];k++){
				dp2[i][j][k] = dp2[i-1][j][k];
			}
			for(k = w2[i];k < 300;k++){
				dp2[i][j][k] = max(dp2[i-1][j][k],dp2[i-1][j-1][k-w2[i]]+v[i]);
			}
		}
	}
	int ans = 0;
	for(int i = 0;i <= W/w[0];i++){
		for(int j = 0;j < 300;j++){
			if(i*w[0]+j > W) break;
			if(dp2[n-1][i][j] > ans) ans = dp2[n-1][i][j];
		}
	}
	return ans;
}

int main() {
	cin >> n >> W;
	for(int i = 0;i < n;i++){
		cin >> w[i] >> v[i];
	}
	if(w[0] > 300){
		cout << solve() << endl;
	}
	else{
		cout << knapsack() << endl;
	}
}


Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  vector<int> d(5);
  rep(i,5){ cin >> d[i]; }
  int last=0,los=0;
  rep(i,5){
    if(los<(10-d[i]%10) && d[i]%10!=0){ los = 10-d[i]%10; last=i; }
  }
  
  int ans=0;
  rep(i,5){
    if(i!=last){ 
      ans += ((d[i]+9)/10)*10;
    } else {
      ans += d[i];
    }    
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    //    bool ans = true;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        if (A % 2 == 0)
        {
            if (A % 3 == 0 || A % 5 == 0)
            {
                continue;
            }
            else
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main() {
    int n,w;
    cin >> n >> w;
    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
    for (int i = 0;i < n;++i) {
        int p,q;
        cin >> p >> q;
        for (int j = 0;j <= w;++j) dp[i+1][j] = dp[i][j];
        for (int j = 0;j <= w-p;++j) {
            if (dp[i+1][j+p] < dp[i][j]+q) dp[i+1][j+p] = dp[i][j]+q;
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}

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

int main(){
  int N, M;
  cin>>N>>M;
  if(N==M){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

typedef pair<double,double> P;

double d(P p1, P p2){
	return (p1.first-p2.first)*(p1.first-p2.first)+(p1.second-p2.second)*(p1.second-p2.second);
}
int main(){
	int n;
	cin >> n;
	while(n){
		P p[n];
		char c;
		for(int i = 0; i < n; i++){
			cin >> p[i].first >> c >> p[i].second;
		}
		sort(p, p+n);
		P* cp = p;
		int sum = 0;
		double prevT = 0;
		do{
			sum++;
			double minT = 7;
			P *nextP = p;
			for(int i = 0; i < n; i++){
				if(&p[i] != cp){
					double T = atan2(p[i].second-(*cp).second,p[i].first-(*cp).first)-prevT;
					if(T < 0){
						T += M_PI*2;
					}
					if(T == minT){
						if(d(*cp, p[i]) > d(*cp, *nextP)) nextP = &p[i];
					}else if(T < minT){
						minT = T;
						nextP = &p[i];
					}
				}
			}
			cp = nextP;
			prevT += minT;
		}while(cp != p);
		cout << n-sum-1 << endl;
		cin >> n;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  char X, Y;
  cin >> X >> Y;
  if(X < Y) cout << '<' << endl;
  else if(X > Y) cout << '>' << endl;
  else cout << '=' << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl
use strict;

my @r0 = split (/ /, <>);
my @r1 = split (/ /, <>);
my @r2 = split (/ /, <>);
my $num = <>;

my @matrix = (
  [@r0],
  [@r1],
  [@r2] 
);

my @bingo;
for (my $i = 0; $i < $num; $i++) {
  $bingo[$i] = <>;
}
chomp(@bingo);

#row check
my $row_match = 0;
for (my $k = 0;$k <= 2; $k++) {
  for (my $i = 0; $i <= $#bingo; $i++) {
    for (my $j = 0; $j <= 2; $j++) {
        if ($matrix[$k][$j] == $bingo[$i]) {
           $row_match++;
        }
    }
    if ($row_match == 3) {
      print "Yes";
      exit;
    } 
  }
  $row_match = 0;
}

#column check
my $col_match = 0;

for (my $j = 0; $j <= 2; $j++) {
  for (my $k = 0; $k <= 2; $k++) {
    for (my $i =0;$i <= $#bingo; $i++) {
      if ($matrix[$k][$j] == $bingo[$i]) {
        $col_match++;
      }
    }
    if ($col_match == 3) {
     print "Yes";
     exit;
    }
  }
  $col_match = 0;
}

my $daig_match = 0;
for (my $i =0;$i <= $#bingo; $i++) {
  if ($matrix[0][0] == $bingo[$i]) {
    $daig_match++;
  } if ($matrix[1][1] == $bingo[$i]) {
    $daig_match++;
  } if ($matrix[2][2] == $bingo[$i]) {
    $daig_match++;
  } 
  if ($daig_match == 3) {
    print "Yes";
    exit;
  }
}
$daig_match = 0;
for (my $i =0;$i <= $#bingo; $i++) {
  if ($matrix[0][2] == $bingo[$i]) {
    $daig_match++;
  } if ($matrix[1][1] == $bingo[$i]) {
    $daig_match++;
  } if ($matrix[2][0] == $bingo[$i]) {
    $daig_match++;
  } 
  if ($daig_match == 3) {
    print "Yes";
    exit;
  }
}
print "No";

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int r=0, i, l;
	string s;
	cin >> s;
	l=s.size();
	for (i=1; i<l; i++)
	{
		if (s[i]==s[i-1])
		{
			r++;
			if (s[i-1]=='0')
				s[i]='1';
			else
				s[i]='0';
		}
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 512
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

    vector<int> A(n);
    for(auto &x : A){
        cin >> x;
    }

    map<int, int> mp;
    for(auto &x : A){
        mp[x - 1]++;
        mp[x]++;
        mp[x + 1]++;
    }

    int ans = INT_MIN;
    for(auto x : mp){
        ans = max(ans, x.second);
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> A(N), B(N);

    for (auto &e : A) cin >> e;

    ll minv = accumulate(begin(A), end(A), 0ll);
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < N; j++) B[(j+1)%N] = min(A[(j+1)%N], A[j]);
        A = B;
        minv = min(minv, accumulate(begin(A), end(A), 0ll) + i * X);
    }
    cout << minv << endl;
    return (0);
}

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

using namespace std;

int main(void){

    int n;
    long long int ans = 0;
    cin >> n;
    vector<int> x(n);
    for(int i = 0;i < n;i++) cin >> x[i];
    double ave = 0;
    int tmp;
    for(int i = 0;i < n;i++){
        ave += x[i];
    }

    ave /= x.size();
    tmp = round(ave);

    for(int i = 0;i < n;i++){
        ans += (tmp-x[i])*(tmp-x[i]);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll N,K;

int main() {
        cin >> N >> K;
        if (K%2 == 1) {
                cout << (N/K)*(N/K)*(N/K) << endl;
        } else {
                cout << (N/K)*(N/K)*(N/K) + ((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K) << endl;
        }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        double total = 0;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            total += ((double)1/num);
        }
        System.out.println(1/total);
    }
}


Measured memory_bytes: 23764
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	int n = s.size();
	int res = 110;
	rep(i, 26)
	{
		char x = i + 'a';
		int tmp = 0;
		rep(j, n)
		{
			int cnt = 0;
			while (j < n && s[j] != x)
			{
				++cnt;
				++j;
			}
			tmp = max(tmp, cnt);
		}
		res = min(res, tmp);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,r,p,c;
    while(cin>>n>>r,n){
        vector<int> v(n,0);
        iota(v.rbegin(),v.rend(),1);
        for(int i=0;i<r;i++){
            cin>>p>>c;
            vector<int> t(c,0);
            for(int j=0;j<c;j++){
                t[j]=v[j+p-1];
            }
            for(int j=p-1;j>0;j--){
                v[c+j-1]=v[j-1];
            }
            for(int j=0;j<c;j++){
                v[j]=t[j];
            }
        }
        cout<<v[0]<<endl;
    }
}


Measured memory_bytes: 3100
def main():
    lst = list(map(int,input().split()))

    x= lst[2] - lst[0]
    y= lst[3] - lst[1]

    #print(lst[1]-y)
    #print(lst[3]+x)

    x3 = lst[2]-y
    y3 = lst[3]+x

    x4 = x3 - x
    y4 = y3 - y

    print(str(x3) +" "+ str(y3)+" "+str(x4)+" "+str(y4))


if __name__ == "__main__":
        main()


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


int main()
{
 int K;
 int S;
 int a=0;
 
 cin>>K>>S;
 for(int X=0;X<K+1;++X)
 {for(int Y=0;Y<K+1;++Y)
	 
	 {int Z=S-X-Y;
		if(Z<K+1 and Z>-1)
		{
		if(X+Y+Z==S){++a;}
		}
	 }
 }

cout<<a<<endl;
 }


Measured memory_bytes: 256
X = int(input())
if X == 0:
  print(0,0)
else:
  for i in range(-121,122):
    for j in range(-121,122):
      if i==j:
        continue
      else:
        if X%(i-j) == 0:
          if X == i**5 - j**5:
            print(i,j)
            exit()

Measured memory_bytes: 9188
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 100005;

int n, a[mxn];
ll mx[mxn], mn[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    cin >> n;
    ll cntLeaf = 0;
    for (int i = 0; i <= n; i++) {
        cin >> a[i], cntLeaf += a[i];
    }
    mx[0] = 1;
    for (int i = 0; i <= n; i++) {
        if (mx[i] < a[i]) return cout << "-1\n", 0;
        mx[i] -= a[i], mx[i+1] = min(cntLeaf, mx[i]<<1);
    }
    mx[n] = 0;
    for (int i = n; i >= 1; i--) {
        mx[i-1] = min(mx[i-1], mx[i]+a[i]);
    }
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += mx[i];
    }
    cout << ans+cntLeaf << '\n';
}

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

using namespace std;

int main()
{

    int N, Q;

    cin >> N >> Q;

    vector<char> m(N);
    for(int i = 0; i < N; i++){
	cin >> m.at(i);
    }

    vector<char> T(Q), D(Q);
    for(int i = 0; i < Q; i++){
	cin >> T.at(i) >> D.at(i);
    }
    /*
    char pt;
    int sum = 0;
    for(int i = 0; i < N; i++){
	pt = i; // 初期位置
	for(int j = 0; j < Q; j++){
	    if(T.at(j) == m.at(pt)){ // 呪文の対象のマスにいる
		if(D.at(j) == 'L'){
		    pt--;
		}else{
		    pt++;
		}
		if(pt < 0 || pt >= N){ // おちた
		    sum++;
		    break; // このゴーレムはおしまい
		}
	    }
	}
    }
    cout << (N-sum) << endl;
    */

    int ok_L = N, drop_L = 0, drop_R = N-1, ok_R = -1;
    bool f_L, f_R;
    int pt;
    int init = 0;
    for(;;){
	pt = init; // このトレースの初期位置
	f_L = false;
	f_R = false;
	for(int j = 0; j < Q; j++){
	    if(T.at(j) == m.at(pt)){ // 呪文の対象のマスにいる
		if(D.at(j) == 'L'){
		    pt--;
		}else{
		    pt++;
		}
		if(pt < 0){ // 左に落ちた
		    f_L = true;
		    drop_L = init;
		    break;
		}else if(pt >= N){ // 右に落ちた
		    f_R = true;
		    drop_R = init;
		    break;
		}
	    }
	}
	if(f_L){
	    if(init == N-1){ // 左に全部落ちる
		ok_L = N;
		drop_L = N-1;
	    }else{
		int n = (ok_L - init) / 2;
		n = (n == 0) ? 1 : n;
		init = init + n;
	    }
	}else{
	    ok_L = init;
	    if(init == 0){// 左に全部落ちるものはない
		ok_L = 0;
		drop_L = -1;
	    }else{
		int n = (init - drop_L) / 2;
		n = (n == 0) ? 1 : n;
		init = init - n;
	    }
	}
	if(ok_L - drop_L == 1){
	    break;
	}
    }

    init = N-1;
    for(;;){
	pt = init; // このトレースの初期位置
	f_L = false;
	f_R = false;
	for(int j = 0; j < Q; j++){
	    if(T.at(j) == m.at(pt)){ // 呪文の対象のマスにいる
		if(D.at(j) == 'L'){
		    pt--;
		}else{
		    pt++;
		}
		if(pt < 0){ // 左に落ちた
		    f_L = true;
		    drop_L = init;
		    break;
		}else if(pt >= N){ // 右に落ちた
		    f_R = true;
		    drop_R = init;
		    break;
		}
	    }
	}
	if(f_R){
	    if(init == 0){ // 右に全部落ちる
		ok_R = -1;
		drop_R = 0;
	    }else{
		int n = (init-ok_R) / 2;
		n = (n == 0) ? 1 : n;
		init = init - n;
	    }
	}else{
	    ok_R = init;
	    if(init == N-1){// 右に全部落ちるものはない
		ok_R = N-1;
		drop_R = N;
	    }else{
		int n = (drop_R-init) / 2;
		n = (n == 0) ? 1 : n;
		init = init + n;
	    }
	}
	if(drop_R - ok_R == 1){
	    break;
	}
    }
    if(ok_R >= 0 && ok_L <= N-1 && ok_R >= ok_L){
	cout << (ok_R-ok_L+1) << endl;
    }else{
	cout << 0 << endl;
    }
    

}



Measured memory_bytes: 896
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    vector<int> mass;

    cin>>n;

    for(int i=0;i<n;i++){
        int inp;
        cin>>inp;
        mass.push_back(inp);
    }
    for(int j=n-2;j>=0;j--){
        if(mass.at(j)>mass.at(j+1)){
            if(mass.at(j)-1>mass.at(j+1)){
                cout<<"No"<<endl;
                return 0;
            }
            mass.at(j)--;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

const int MAX = 100010;
vector<pil> G[MAX];
lint d[MAX];

void dfs(int v, int prev, lint td){
    d[v] = td;
    for(auto p: G[v])if(p.fi != prev){
        dfs(p.fi, v, td + p.se);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    rep(i, n-1){
        int a, b;
        lint c;
        scanf("%d%d%lld", &a, &b, &c);
        G[--a].push_back(pil(--b, c));
        G[b].push_back(pil(a, c));
    }
    
    int q, k;
    scanf("%d%d", &q, &k);
    --k;
    dfs(k, -1, 0);
    
    while(q--){
        int x, y;
        scanf("%d%d", &x, &y);
        printf("%lld\n", d[x-1] + d[y-1]);
    }
}

Measured memory_bytes: 14336
//By Don4ick 

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	ll A, B, C;
	cin >> A >> B >> C;
	if (!(A & 1) || !(B & 1) || !(C & 1))
	{
		cout << 0 << endl;
	}
	else
	{
		cout << min({A * B, B * C, A * C}) << endl;
	}

	return 0;
}



Measured memory_bytes: 256
n = int(input())
xlist = [int(x) for x in input().split()]
sxlist = sorted(xlist)
mid = sxlist[int(n/2)]
mid2 = sxlist[int(n/2)-1]
for i in range(n):
    if xlist[i] < mid:
        print(mid)
    else:
        print(mid2)

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

#define int             long long
#define	ll				long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

int lcm(int a, int b)
{
	return (a / gcd(a, b)) * b;
}

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	int n;
	cin>>n;
	vector<int>a(n+1,0);
	for(int i =1;i<=n;i++){
		for(int j=0;j<=n;j+=i)
		a[j]++;
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
		ans+=(i*(int)a[i]);
	cout<<ans<<endl;
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


Measured memory_bytes: 81384
from fractions import gcd

N, K = map(int, input().split())
A = [int(_) for _ in input().split()]

if N == 1:
    print("POSSIBLE" if K == A[0] else "IMPOSSIBLE")
else:
    GCD = gcd(A[0], A[1])
    
    for i in range(2, N):
        GCD = gcd(GCD, A[i])
    
    if K <= max(A) and K % GCD == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 16084
s = gets.chomp.chars

ans = 'Yes'
s.each_with_index do |ss, i|
  i += 1
  if i.odd? && ['R','U','D'].include?(ss) ||
    i.even? && ['L','U','D'].include?(ss)
  else
    ans = 'No'
  end
end
puts ans

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

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

    if(s[2] == s[3] and s[4] == s[5]) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    long m,a,r,c,h;
    m = a = r = c = h = 0;
    int[] P ={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
    int[] Q ={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
    int[] R ={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] S = new long[5];
    for (int i = 0; i < N; i++) {
      String name = sc.next();
      if (name.charAt(0) == 'M') m++;
      if (name.charAt(0) == 'A') a++;
      if (name.charAt(0) == 'R') r++;
      if (name.charAt(0) == 'C') c++;
      if (name.charAt(0) == 'H') h++;
    }
    S[0]=m; S[1]=a; S[2]=r; S[3]=c; S[4]=h;
    long res = 0;
    for (int d = 0; d < 10; d++) {
      res += S[P[d]] * S[Q[d]] * S[R[d]];
    }

    System.out.println(res);
  }
}


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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(m);

    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        s[i].resize(k);
        for(int j=0;j<k;j++){
            int tmp;
            cin>>tmp;
            s[i][j]= --tmp;
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;i++)
        cin>>p[i];

    int res=0;
    for(int i=0;i<(1<<n);i++){
        bool ok =true;
        for(int j=0;j<m;j++){
                    int cnt=0;
            for(int k=0;k<s[j].size();k++){
                if((i>>s[j][k])&1)
                    cnt++;
            }
        if((cnt%2)!=p[j])
            ok = false;
        }
        if(ok)
            res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<stdio.h> 
#include<math.h> 
int main()
{
	int i, j, n, x[100], y[100];
	double p, max;   
	
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", &x[i]);  
	}
	
	for(i=0; i<n; i++)
	{
		scanf("%d", &y[i]);
	}
	
	for(j=1; j<=3; j++)
	{
		p=0.0; 
		for(i=0; i<n; i++)
		{ 
			p += pow((abs(x[i]-y[i])), j);
		} 
		p = pow(p,1.0 / j);
		printf("%f\n", p); 
	}
	
	max = abs(x[0]-y[0]);
	
	for(i=1; i<n; i++)
	{
		if(max < abs(x[i]-y[i]))
		{
			max = abs(x[i]-y[i]); 
		}
	}
	
	printf("%f\n", max); 
	
	return 0; 
}

Measured memory_bytes: 696
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int n;
    cin >> n;
    vector<int> arr;
    while(n--){
        int t;
        cin >> t;
        arr.push_back(t);
    }
    sort(arr.begin(),arr.end(),greater<int>());
    int a = 0;
    int b = 0;
    rep(i,0,arr.size()){
        if(i%2 ==0){
            a += arr[i];
        }else{
            b += arr[i];
        }
    }
    cout << a-b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

int a,b;

scanf("%d\n",&a);
scanf("%d\n",&b);

if(a<b){

printf("a < b\n");

}else if(a>b){

printf("a > b\n");

}else if(a==b){

printf("a == b\n");

}

return 0;

}

Measured memory_bytes: 2696
row = gets.split
num, per_ms = [row[0].to_i, row[1].to_i]


queue = [];
(0..num - 1).each{
    name, ms = gets.split
    queue.push([name, ms.to_i])
}

time = 0
results = []
while queue.size > 0 do
    name, ms = queue.shift

    if ms > per_ms then
        time += per_ms
        queue.push([name, ms - per_ms])
    else
        time += ms
        results.push([name, time])
    end
end

results.each do |rl|
    puts "#{rl[0]} #{rl[1]}"
end


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

string shuffle(string str, int h) {
    string head = str.substr(0, h);
    string tail = str.substr(h, str.size() - h);
    return tail + head;
}

int main() {
    string cards;
    int m, h;

    while(1) {
        cin >> cards;
        if ( cards == "-" ) break;

        cin >> m;
        for (int i = 0; i < m; i++ ) {
            cin >> h;
            cards = shuffle(cards, h);
        }

        cout << cards << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int A, B, K;

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

  cin >> A >> B >> K;

  for (int i = A; i <= min(A + K - 1, B); i++) cout << i << endl;
  for (int i = max(A + K, B - K + 1); i <= B; i++) cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m; cin >> n >> m;
    ll s[m], c[m];
    rep(i, m){
        cin >> s[i] >> c[i];
    }

    rep(i, m){
        reps(j, i + 1, m){
            if(s[i] == s[j]){
                if(c[i] != c[j]){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    if(m == 0){
        if(n == 1){
            cout << 0 << endl;
            return 0;
        }
        if(n == 2){
            cout << 10 << endl;
            return 0;
        }
        if(n == 3){
            cout << 100 << endl;
            return 0;
        }
    }

    if(n == 2 || n == 3){
        rep(i, m){
            if(s[i] == 1 && c[i] == 0){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    ll ans[n];
    memset(ans, -1, sizeof(ans));

    rep(i, m){
        ans[s[i] - 1] = c[i];
    }

    rep(i, n){
        if(ans[i] == -1){
            if(i == 0){
                ans[i] = 1;
            }
            else{
                ans[i] = 0;
            }
        }
    }

    rep(i, n){
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    string S; cin >> S;
    ll ans = 0;

    ll res = S[0] - '0' - 1;
    res += 9 * (len(S) - 1);
    ans = max(ans, res);

    res = 0;
    rep(i, len(S)) res += S[i] - '0';
    ans = max(ans, res);

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N, A;
int main(void){
    cin >> N;
    float S;
    rep(i,N){
        cin >> A;
        S += 1.0/A;
    }
    printf("%.6f", 1.0/S);
    return 0;
}



Measured memory_bytes: 256
import math

X=int(input())
max=0
for i in range(int(math.sqrt(X))):
    num=i+1
    j=0
    while True:
        buf=pow(num,j)
        if buf>max:
            max=buf
        j=j+1
        if (buf==pow(num,j))or(pow(num,j)>X):
            break
print(max)

Measured memory_bytes: 38256