akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
//#define int long long
//#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    string s; cin >> s;
    int N = SZ(s);

    mat a(N, vec(27, N));
    IREP(i, N){
        a[i][s[i] - 'a'] = i;
        int now = i + 1, x = s[i] - 'a';
        while(now < N && x < 26){
            a[i][x + 1] = a[now][x];
            now = a[now][x] + 1;
            x++;
        }
        if(x == 26 && now < N){
            REP(y, s[i] - 'a'){
                a[i][y] = a[now][y];
            }
        }
    }
    mat next(19, vec(N + 1, N + 1));
    REP(i, N) next[0][i] = a[i][26] + 1;
    FOR(t, 1, 19) REP(i, N) if(next[t - 1][i] <= N) next[t][i] = next[t - 1][next[t - 1][i]];

    int Q; cin >> Q;
    v_bool ans(Q);
    REP(q, Q){
        int l, r; cin >> l >> r;
        l--;
        int now = l;
        IREP(t, 19) if(next[t][now] <= r) now = next[t][now];
        ans[q] = (now == r);
    }
    REP(q, Q) chOut(ans[q], "Yes", "No");

    return 0;
}


Measured memory_bytes: 117012
a = int(input())
s = list(input())

if (a%2 !=0):
  print('No')
  
elif (a == 2):
  if (s[0] == s[1]):
    print('Yes')
  else:
    print('No')
    
else:
  b = a/2
  i = 0
  k = 0
  for i in range(int(b-1)):
    if (s[i] == s[int((int(b)+i))]):
      k+=1
    else:
      break
    
  if(k==b-1):
    print('Yes')
  else:
    print('No')
    


Measured memory_bytes: 38256
l, r = map(int, input().split())
mod = 2019
if(r-l >= 2019):
    print(0)
else:
    ans = 10000000
    for i in range(l, r):
        for j in range(i+1, r+1):
            #print(lmod, ":", rmod)
            ans = min(ans, (i*j)%mod)
    print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

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

		if(b-a == c-b){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 21972
import numpy as np
A, B, H, M = map(int, input().split())
Pi = np.pi
thetaH = 2*Pi*H/12 + Pi/6*M/60
thetaM = 2*Pi*M/60

xH = A*np.sin(thetaH)
yH = A*np.cos(thetaH)

xM = B*np.sin(thetaM)
yM = B*np.cos(thetaM)

dd = np.sqrt((xH-xM)**2+(yH-yM)**2)

print(dd)

Measured memory_bytes: 27140
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

//-----CODE------//

void solve(void)
{ 
  int A,B,C;
  cin>>A>>B>>C;
  int MAX = max(A,max(B,C));
  int cnt = (MAX-A)/2 + (MAX-B)/2 + (MAX-C)/2;
  A +=(MAX-A)/2*2;
  B +=(MAX-B)/2*2;
  C +=(MAX-C)/2*2;
  // DEBUG(A,B,C);

  int R = 3*MAX - A - B -C;
  if(R == 0)
  {
    cout<<cnt;
  }
  else if ( R == 1)
  {
    cout<< cnt + 2<<endl;
  }
  else
  {
    cout<< cnt + 1<<endl;
  }
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;
map<ll,ll> mp;
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>m){
        mp.clear();

        ll ans=0;
        ll zr=0;
        ll sum=0;
        for(i=0;i<n;i++){
            cin>>x;
            sum=(sum+x)%m;
            if(sum==0) ++zr;
            else ++mp[sum];
        }
       
        ans+=zr ;
        if(zr>1) ans+=(((zr-1)*zr)/2);
        for(auto xx: mp){
            if(xx.s>1) ans+=(((xx.s-1)*xx.s)/2);
        }

        cout<<ans<<endl;
    }





}

Measured memory_bytes: 4224
// https://atcoder.jp/contests/abc147/tasks/abc147_f
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

const ll MOD = 1e9+7;

vector<ll> dp(200010);
vector<vector<ll>> edges(200010);

ll dfs(ll now,ll parent){
    ll tmp = 1;
    for (auto e : edges[now]) {
        if(e!=parent){
            tmp += dfs(e, now);
            tmp %= MOD;
        }
    }
    return dp[now]=tmp;
}

int main() {
    ll n;
    std::cin >> n;
    
    for (int i = 0; i < n-1; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    dfs(0,-1);
    
    ll ans = 0;
    
    for (int i = 0; i < n; i++) {
        ll tmp=1-1*modinv(modpow(2,n-1,MOD),MOD)%MOD+MOD;
        tmp += MOD;
        tmp %= MOD;
        if(edges[i].size()<2){
            continue;
        }
        for (auto e : edges[i]) {
            if(dp[i]>dp[e]){
                tmp -= 1*modinv(modpow(2,n-1-dp[e],MOD),MOD)    %MOD*(1-1*modinv(modpow(2,dp[e],MOD),MOD)%MOD    +MOD)%MOD;
                tmp += MOD;
            }else{
                tmp -= 1*modinv(modpow(2,n-1-(n-dp[i]),MOD),MOD)%MOD*(1-1*modinv(modpow(2,(n-dp[i]),MOD),MOD)%MOD+MOD)%MOD;
                tmp += MOD;
            }
            tmp %= MOD;
        }
        ans += tmp*modinv(2,MOD)%MOD;
        ans %= MOD;
    }
    
    std::cout << ans << std::endl;
}


Measured memory_bytes: 22016
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1), b(n);
    rep(i, n+1)cin >> a[i];
    rep(i, n)cin >> b[i];

    ll sum = 0;
    rep(i, n){
        ll x = min(a[i], b[i]);
        ll y = min(a[i+1], max(b[i] - a[i], (ll)0));
        sum += x+y;
        a[i] -= x;
        a[i+1] -= y;
    }

    cout << sum  << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll o=1e18;
  ll N; cin>>N;
  ll ans = 1;
  vector<ll> A(N, 0);
  rep(i, N){
    cin>>A[i];
    if (A[i] == 0){
      cout<<0<<endl;
      return 0;
    }
  }
  double check = 0;
  rep(i, N){
    ans *= A[i];
    check += (double)log10(A[i]);
    if (ans > 1000000000000000000 || ans < 0 || check > 18.00000000){
      cout << -1 << endl;
      return 0;
    }
  }
  cout <<ans << endl;
}


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

int n;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> n;
		if(n == 0) return 0;
		int w, h;
		cin >> w >> h;
		int a[w+1][h+1];
		for(int i=0; i<w+1; ++i)
			for(int j=0; j<h+1; ++j)
				a[i][j] = 0;
		for(int i=0; i<n; ++i){
			int x, y;
			cin >> x >> y;
			a[x][y] = 1;
		}
		int ans = 0;
		int s, t;
		cin >> s >> t;
		for(int i=1; i+s-1<=w; ++i)
			for(int j=1; j+t-1<=h; ++j){
				int tmp = 0;
				for(int k=0; k<s; ++k)
					for(int l=0; l<t; ++l)
						tmp += a[i+k][j+l];
				ans = max(ans, tmp);
			}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3124
#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)
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;

int main()
{
    int N, M;
    cin >> N >> M;
    int left, right, ans = 1;
    rep(i, M) {
        int l, r;
        cin >> l >> r;
        if (i == 0) {
            left = l;
            right = r;
        }
        else {
            if (left < l) {
                left = l;
            }
            if (right > r) {
                right = r;
            }
            if (right < l || left > r) {
                ans = 0;
            }
        }
    }

    cout << (right - left + 1) * ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int64_t *A;
int64_t *X;

int64_t valX(int a, int b) {
    if (a > 0) return X[b] ^ X[a-1];
    return X[b];
}

int64_t valA(int a, int b) {
    if (a > 0) return A[b] - A[a-1];
    return A[b];
}

int main() {
    int N, i;
    cin >> N;

    A = new int64_t[N];
    X = new int64_t[N];
    
    for (i=0;i<N;i++) {
        cin >> A[i];
        X[i] = A[i];

        if (i>0) {
            A[i] += A[i-1];
            X[i] ^= X[i-1];
        }
    }

    int64_t ans = 0;
    for (int s=0;s<N; s++) {
        int l = s, r=N-1, mid;
        while (1) {
            mid = l + (r-l+1)/2;
            if (valA(s, mid) == valX(s, mid)) {
                l = mid+1;
            } else {
                r = mid-1;
            }

            if (l > r) break;
        }

        ans += (r-s+1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
int gcd(int,int);
int main(){
  int x,y,z;
  scanf("%d%d", &x, &y);
  z = gcd(x,y);
  printf("%d\n", z);
  return 0;
}

int gcd(int x,int y){
  int min,min1,max,n;
  if( x > y){
    max = x;
    min = y;
  }
  else{
    max = y;
    min = x;
  }

  while(1){
    if( min == 0) break;
    min1 = min;
    min = max % min1;
    max = min1;
  }

  return max;
}



Measured memory_bytes: 2124
#include <iostream>
#include <string>

using namespace std;

class Dice {
public:
    int surface[6];

    void goNorth() {
        int temp = surface[0];
        surface[0] = surface[1];
        surface[1] = surface[5];
        surface[5] = surface[4];
        surface[4] = temp;
    }

    void goEast() {
        int temp = surface[0];
        surface[0] = surface[3];
        surface[3] = surface[5];
        surface[5] = surface[2];
        surface[2] = temp;
    }

    void goSouth() {
        int temp = surface[0];
        surface[0] = surface[4];
        surface[4] = surface[5];
        surface[5] = surface[1];
        surface[1] = temp;
    }

    void goWest() {
        int temp = surface[0];
        surface[0] = surface[2];
        surface[2] = surface[5];
        surface[5] = surface[3];
        surface[3] = temp;
    }

    void putAnswer() {
        cout << surface[0] << endl;
    }
};

int main() {
    Dice dice;

    for (int i = 0; i < 6; i++) {
        cin >> dice.surface[i];
    }

    string order;
    cin >> order;
    int times = order.size();
    for (int i = 0; i < times; i++) {
        char str = order[i];
        switch (str) {
            case 'N':
                dice.goNorth();
                break;
            case 'E':
                dice.goEast();
                break;
            case 'S':
                dice.goSouth();
                break;
            case 'W':
                dice.goWest();
                break;
        }
    }
    dice.putAnswer();
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var order = new List<int>();
            order.Add(1);
            for (int i = 1; Math.Pow(6, i) <= N; i++) order.Add((int)Math.Pow(6, i));
            for (int i = 1; Math.Pow(9, i) <= N; i++) order.Add((int)Math.Pow(9, i));
            order = order.Distinct().OrderBy(i => i).ToList();
            var cnt = Enumerable.Repeat(int.MaxValue, 100001).ToArray();
            cnt[0] = 0;
            for (int i = 0; i < N; i++)
            {
                foreach (var o in order)
                {
                    if (i + o <= N) cnt[i + o] = Math.Min(cnt[i + o], cnt[i] + 1);
                }
            }

            Console.WriteLine(cnt[N]);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 14816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,A,Hasu;
 cin >> N >> A;
  
  Hasu = N%500 ;
  
 if (Hasu <= A){
   cout << "Yes" << endl;
 }
  else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
w = input()
d = {}

for i in range(len(w)):
    if w[i] not in d:
        d[w[i]] = 1
    else:
        d[w[i]] += 1
        
for count in d.values():
    if count % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 3060
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
N=SR()

if N[-1:] == '3':
    print("bon")
elif N[-1:] == '0' or N[-1:] == '1' or N[-1:] == '6' or N[-1:] == '8':
    print("pon")
else:
    print("hon")


Measured memory_bytes: 10304
// Aizu Vol-5 0578: Signboard
// 2017.8.31 bal4u@uu

#include <stdio.h>
#include <string.h>

char s[30], k[110];

int match(char *d, int dw, char *p)
{
	char *dp, *de, *pp;
	char c;
	int k;

	c = *p, de = d + dw;
    while (*d) {
        if (*d == c) {
			for (k = 1; k < dw; k++) {
		        dp = d, pp = p;
				while (*pp && dp < de) {
					if (*pp != *dp) break;
					pp++, dp+=k;
				}
				if (!*pp) return 1;
			}
		}
		d++, dw--;
    }
	return 0;
}

int main()
{
	int n, ans;

	scanf("%d%s", &n, s);
	ans = 0;
	while (n-- > 0) {
		scanf("%s", k);
		if (match(k, strlen(k), s)) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
 
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 800;
		for (int i=0;i<N;i++) {
			long a = sc.nextLong();
			int temp=0;
			while (a%2==0) {
				a/=2;
				temp++;
			}
			if (temp<count) {
				count = temp;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7) || (a == 7 && b == 5 && c == 5)){
    cout << "YES\n";
  }
  else
  {
    cout << "NO\n";
  }
  return 0;
}

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

vector<int> dp(MAX);
signed main(void)
{
	int n;
	cin >> n;
	rep(x, MAX)
	{
		dp[x] = x;
		int p = 6;
		while (p < MAX)
		{
			if (x - p >= 0)
				dp[x] = min(dp[x], dp[x - p] + 1);
			p *= 6;
		}
		p = 9;
		while (p < MAX)
		{
			if (x - p >= 0)
				dp[x] = min(dp[x], dp[x - p] + 1);
			p *= 9;
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if( a + b == 3 ){
		cout << 3 << endl;
	}
	if( a + b == 4 ){
		cout << 2 << endl;
	}
	if( a + b == 5 ){
		cout << 1 << endl;
	}
}


Measured memory_bytes: 256
n,k = map(int,input().split())
A = list(map(int,input().split()))
from fractions import gcd
if max(A) < k:
    print("IMPOSSIBLE")
else:
    g = A[0]
    for a in A:
        g = gcd(a,g)
    if k%g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
const int N = 300;

char ch[N+5]; int f[N+5][N+5][N+5], k, n;

void work() {
    scanf("%s%d", ch+1, &k); n = strlen(ch+1);
    for (int i = 1; i <= n; i++) f[i][i][0] = 1;
    for (int l = 1; l <= n; l++)
	for (int i = 1; i+l <= n; i++)
	    for (int p = 0, j = i+l; p <= k; p++) {
		f[i][j][p] = max(f[i+1][j][p], f[i][j-1][p]);
		if (ch[i] == ch[j]) f[i][j][p] = max(f[i][j][p], f[i+1][j-1][p]+2);
		if (p) f[i][j][p] = max(f[i][j][p], f[i+1][j-1][p-1]+2);
	    }
    int ans = 0;
    for (int i = 0; i <= k; i++) ans = max(ans, f[1][n][i]);
    printf("%d\n", ans);
}
int main() {work(); return 0; }


Measured memory_bytes: 110464
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    k = int(input().rstrip('\n'))
    x = int(input().rstrip('\n'))
    y = int(input().rstrip('\n'))
    t = 0
    for i in range(n):
        if i + 1 > k:
            t += y
        else:
            t += x
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38480
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, k, a[1001];

void solve()
{
    cin >> n >> k;
    int ans=0;
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a,a+n);
    for (int i=0; i<k;i++) ans+=a[i];
    nout(ans);

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<limits.h>
#include<stdlib.h>
void chmin(int*,int);
void chmax(int*,int);
int main(void)
{
    int n;
    int h[100000];
    int dp[100000];

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    for(int i=0;i<=n;i++)dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=0;i<n-1;i++){
        /*if(dp[i+1]>dp[i]+abs(h[i+1]-h[i])){
            dp[i+1]=dp[i]+abs(h[i+1]-h[i]);
        }*/
        chmin(&dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        /*if(dp[i+2]>dp[i]+abs(h[i+2]-h[i])){
            dp[i+2]=dp[i]+abs(h[i+2]-h[i]);
        }*/
        chmin(&dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    printf("%d\n",dp[n-1]);
    return 0;
}
void chmin(int* x,int y){if(*x>y)*x=y;}
void chmax(int* x,int y){if(*x<y)*x=y;}

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

int main(){
  int N;
  cin >>N;
  int H[N];
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  int maxH=1;
  for (int i=0;i<N;i++){
    maxH=max(maxH,H[i]);
    if(maxH>H[i]+1){
      cout<<"No"<<endl;
      return 0;
    }
  }

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

  

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
 static void Main(string[] args)
 {
  int N = int.Parse(Console.ReadLine());
  List<int> l = new List<int>();
  for (int i = 0; i < N; i++) { l.Add(int.Parse(Console.ReadLine())); }
  l.Sort();
  int s = l.Sum() - l[l.Count - 1] / 2;
  Console.WriteLine(s.ToString());
 }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, k;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	vector<ll> monster(n);
	for (ll i = 0; i < n; i++)cin >> monster[i];
	sort(monster.begin(), monster.end(), greater<ll>());
	ll ans = 0;
	for (ll i= min(n, k); i < n; i++){
		ans += monster[i];
	}
	cout << ans;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

typedef long long LL;

const int MAXN = 3e5 + 10;

int n, l;
int x[MAXN], t[MAXN];

int main() {
	scanf("%d%d", &n, &l);
	for (int i = 1; i <= n; ++i) scanf("%d", &x[i]);
	LL cnt = 1;
	int L = 0, R = 0, LR = 0;
	for (int i = 1, t; i <= n; ++i) {
		scanf("%d", &t), cnt += t / (l << 1), t %= l << 1;
		if (!t) continue; ++cnt;
		int cl = t <= (l - x[i] << 1), cr = t <= (x[i] << 1);
		if (i == n) { cnt -= cl; break; }
		if (cr) LR += cl, ++R;
		else L += cl;
		while (R - L < (LR << 1)) LR ? --LR : --L;
	}
	printf("%lld\n", (cnt - L - LR) * (l << 1));
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;
long long n,a[100010],sum = 0,k,res = 0;
int main(){
    int i;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum%(n*(n+1)/2)){
        cout << "NO" << endl;
        return 0;
    }
    k = sum/(n*(n+1)/2);
    for(i=0;i<n;i++){
        if((a[(i+1)%n] - a[i] - k) > 0 || (a[(i+1)%n] - a[i] - k)%n){
            cout << "NO" << endl;
            return 0;
        }
        res += (k + a[i] - a[(i+1)%n])/n;
    }
    if(res==k){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main() {
  int N;
  
  cin >> N;
  
  vector<int> H(N);
  
  for(int i = 0;i < N;i++){
    cin >> H.at(i);
  }
  
  int count = 0;
  int countt = -1;
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N - i - 1;j++){
      if(H.at(i + j) >= H.at(i + j + 1)){
        count++;
      }else{
        break;
      }
    }
    if(count > countt){
      countt = count;
    }
    
    i += count;
    count = 0;
  }
  
  cout << countt << endl;
}

Measured memory_bytes: 640
#define M(m,x,y)m[256+(y)*(n+1)+(x)]
n,m[256*256],c[4][256*256];
i,x,y,l,L;
v[4]={1,1,0,-1},w[4]={0,1,1,1};
main(){
	for(;~scanf("%d\n",&n);){
		L=0;
		memset(c,0,sizeof(c));
		for(i=0;i<(n+1)*n;i++)
			m[256+i]=getchar();
		for(y=0;y<n;y++)
			for(x=0;x<n;x++)
				for(i=0;i<4;i++){
					l=M(c[i],x,y)=M(m,x,y)=='1'?M(c[i],x-v[i],y-w[i])+1:0;
					if(l>L)
						L=l;
				}
		n&&printf("%d\n",L);
	}
}

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

int main(){
	ll n;
	cin >> n;
	ll mult = 1;
	vector<long long> a(n);
	bool judge = true;
	for(auto& x: a){
		cin >> x;
		if(x == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	ll c = 1e18;
	rep(i,n){
		if(c/mult < a.at(i)){
			cout << -1 << endl;
			return 0;
		}
		mult *= a.at(i);
	}
	cout << mult << endl;
}


Measured memory_bytes: 4024
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = long.Parse(line[0]);
        var b = long.Parse(line[1]);
        var c = long.Parse(line[2]);
        var k = long.Parse(line[3]);
        Console.WriteLine(k % 2 == 0 ? a - b : b - a);
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

Measured memory_bytes: 512
import itertools
N = int(input())
cnt =[i for i in range(1,N+1)]
xy = [[int(x) for x in input().split()] for i in range(N)]
ans = 0
ansl = 0
cn = 0
for v in itertools.permutations(cnt):
  cn+=1
  for i in range(N-1):
    ans +=((xy[v[i+1]-1][0]-xy[v[i]-1][0])**2+(xy[v[i+1]-1][1]-xy[v[i]-1][1])**2)**0.5
print(ans/cn)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
const double PI = acos(-1) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define max 1000000007

using namespace std;
int n,m,y,x,a,b,h,e,l,o,i,j,sum=0;

int main()
{
	
	CIN;
	cin>>n;
	//pair<int,pair<int,int>>arr[n];
	int lala[100001]={0},arr[n];
	for0(i,n)
	while(n--)
	{
		cin>>arr[i];
		//arr[i].second.first=arr[i].first+1;
		lala[arr[i]-1]++;
		lala[arr[i]+1]++;
		lala[arr[i]]++;
	}
	for(int i=0;i<=100000;i++)
		if(sum<lala[i])sum=lala[i];
	cout<<sum<<nw;
	


}



Measured memory_bytes: 4012
#include <bits/stdc++.h>
#define MAXN 200005
using namespace std;
typedef long long ll;
ll a[55],ans;
int n;
int main() {    
	scanf("%d",&n);
    for(int i = 1 ; i <= n ; ++i) 
    	scanf("%lld",&a[i]); 
    while(1) {
    	int t = 1;
    	for(int i=2;i<=n;++i)
        	if(a[i]>a[t]) t=i;
    	if(a[t]<n) break;
    	ll k = (a[t]-(n -1)-1)/n + 1;
    	a[t]-= k*n;
    	ans += k;
    	for(int i = 1 ; i <= n ; ++i)
        	if(i != t) a[i] += k;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import kotlin.math.*

fun main() {
    println(solve())
}

val solve: () -> Any = solve@{
    val S = readInt()
    if (S < 3) return@solve 0

    val dp = MutableList(4) { 0 }
    dp[0] = 1

    //3(0,0) -> 4(1,0) or 3,3(2,1)

    for (s in 0 until S-3) {
        dp[1] = (dp[1] + dp[0]) % mod
        dp[3] = (dp[3] + dp[0]) % mod
        dp.removeAt(0)
        dp.add(0)
    }
    dp[0]
}

val mod: Int = 1_000_000_007


fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> T.alsoPrintln() = also { println(this) }

fun Boolean.toYesOrNo(yes: String = "Yes", no: String = "No") = if (this) yes else no

fun <E> List<E>.toPair() = this[0] to this[1]

fun <T> readPair(t: (String) -> T) = readPair(t, t)
fun <S, T> readPair(s: (String) -> S, t: (String) -> T) =
    readLine()!!.split(" ").let { Pair(s(it[0]), t(it[1])) }

fun Int.pow(n: Int) = this.toDouble().pow(n).toInt()

fun minAndMax(a: Int, b: Int) = if (a < b) a to b else b to a

fun <T> T.ifOrThis(bool: (T) -> Boolean, trans: (T) -> T) = if (bool(this)) trans(this) else this
fun <T> T.ifOrThis(bool: Boolean, trans: (T) -> T) = if (bool) trans(this) else this

Measured memory_bytes: 34564
import math

def main():

    X, Y = map(int, input().split())


    if (2*Y-X) % 3 != 0 or (2*X-Y)% 3 != 0:
        return 0
    if (2*Y-X) < 0 or (2*X-Y) < 0: return 0

    n = (2*Y-X) // 3
    m = (2*X-Y) // 3
    # print(n , m)

    if n == 0: return 1
    if m == 0: return 1

    mod = pow(10, 9) + 7

    p1 = 1
    for i in range(1, n+m+1):
        p1 *= i
        p1 %= mod

    p2 = 1
    for i in range(1, n+1):
        p2 *= i
        p2 %= mod

    p3 = 1
    for i in range(1, m+1):
        p3 *= i
        p3 %= mod

    p2 = powfast(p2, mod-2, mod)
    p3 = powfast(p3, mod-2, mod)
    return ((p1 * p2) % mod) * p3 % mod


def powfast(x, y, mod):
    if y == 0: return 1
    if x == 0: return 0
    if y % 2 == 0:
        return pow(powfast(x, y//2, mod), 2) % mod
    else:
        return (x * pow(powfast(x, y//2, mod), 2)) % mod


if __name__ == '__main__':
    print(main())

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

int main()
{
    int N;
    cin >> N;
    vector<int> B;
    for (int i = 0; i < N - 1; ++i)
    {
        int temp;
        cin >> temp;
        B.push_back(temp);
    }
    ll ans = 0;
    ans += B[0] + B[N - 2];
    for (int i = 0; i < N - 2; ++i)
    {
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
  string s;
  cin >> s;
  int cnt, ans = 0;

  for (char i = 'a'; i <= 'z'; i++) {
    cnt = count(s.begin(), s.end(), i);
    if (cnt % 2) ans = 1;
  }
  if (ans == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main()
{
	int N;
	int mod=1000000007;
	cin >> N ;
	vector<int> A(N);
	vector<long long> B(N+1,0);
	for(int i=0;i<N;i++)
	{
		cin >> A.at(i);
		B.at(i+1)=B.at(i)+A.at(i);
	}
	
	long ans=0;
	
	for(int i=0;i<N;i++)
	{
		long long sum = (B.at(N)-B.at(i+1))%mod;
		ans+=A.at(i)*sum;
		ans%=mod;
	}
	
	cout << ans << endl;
}

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

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

    if(a > b){
        s = b;
        b = a;
        a = s;
    }

    if (b > c)
    {
        s = c;
        c = b;
        b = s;
    }

    if (a > c){
        s = c;
        c = a;
        a = s;
    }

    if (a > b)
    {
        s = b;
        b = a;
        a = s;
    }

    cout<<a<<" "<<b<<" "<<c<<endl;
}


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

int main()
{
    char kigou[4];
    for(int i = 0; i < 4; i++) {
        scanf("%c",&kigou[i]);
    }

    int ans = 0;
    for(int i = 0; i < 4; i++) {
        if(kigou[i] == '+') {
            ans++;
        }
        else {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int getRightSide(Pair p) {
  if(p.first == 1 && p.second == 2) return 3;
  if(p.first == 1 && p.second == 3) return 5;
  if(p.first == 1 && p.second == 4) return 2;
  if(p.first == 1 && p.second == 5) return 4;
  if(p.first == 2 && p.second == 1) return 4;
  if(p.first == 2 && p.second == 3) return 1;
  if(p.first == 2 && p.second == 4) return 6;
  if(p.first == 2 && p.second == 6) return 3;
  if(p.first == 3 && p.second == 1) return 2;
  if(p.first == 3 && p.second == 2) return 6;
  if(p.first == 3 && p.second == 5) return 1;
  if(p.first == 3 && p.second == 6) return 5;
  if(p.first == 4 && p.second == 1) return 5;
  if(p.first == 4 && p.second == 2) return 1;
  if(p.first == 4 && p.second == 5) return 6;
  if(p.first == 4 && p.second == 6) return 2;
  if(p.first == 5 && p.second == 1) return 3;
  if(p.first == 5 && p.second == 3) return 6;
  if(p.first == 5 && p.second == 4) return 1;
  if(p.first == 5 && p.second == 6) return 4;
  if(p.first == 6 && p.second == 2) return 4;
  if(p.first == 6 && p.second == 3) return 2;
  if(p.first == 6 && p.second == 4) return 5;
  if(p.first == 6 && p.second == 5) return 3;
}

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

Pair rotate(Pair p, int d) {
  if(d == 0) return Pair(7-getRightSide(p), p.second);
  if(d == 1) return Pair(7-p.second, p.first);
  if(d == 2) return Pair(getRightSide(p), p.second);
  if(d == 3) return Pair(p.second, 7-p.first);
}

int getSide(Pair p, int d) {
  if(d == 0) return getRightSide(p);
  if(d == 1) return p.second;
  if(d == 2) return 7 - getRightSide(p);
  if(d == 3) return 7 - p.second;
}

const int MAXN = 102;
Pair G[MAXN][MAXN][MAXN];

int main() {
  for(int n; cin >> n && n;) {
    fill(G[0][0], G[MAXN][0], Pair(0,0));
    while(n--) {
      Pair p; cin >> p.first >> p.second;
      int x = MAXN/2, y = MAXN/2, z = MAXN-1;
      while(1) {
        if(z == 0) {
          G[z][y][x] = p;
          break;
        }
        if(G[z-1][y][x].first) {
          Pair v;
          for(int k = 0; k < 4; ++k) {
            if(getSide(p, k) >= 4 &&
               !G[z][y+dy[k]][x+dx[k]].first &&
               !G[z-1][y+dy[k]][x+dx[k]].first) {
              v = max(v, Pair(getSide(p, k), k));
            }
          }
          if(!v.first) {
            G[z][y][x] = p;
            break;
          }
          int k = v.second;
          p = rotate(p, k);
          x += dx[k];
          y += dy[k];
          --z;
        } else {
          --z;
        }
      }
    }
    vector<int> res(6);
    for(int y = 0; y < MAXN; ++y) {
      for(int x = 0; x < MAXN; ++x) {
        for(int z = MAXN-1; z >= 0; --z) {
          if(G[z][y][x].first) {
            res[G[z][y][x].first-1] += 1;
            break;
          }
        }
      }
    }
    for(int i = 0; i < res.size(); ++i) {
      if(i) cout << " ";
      cout << res[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 9484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	string s;
	cin >> s;
	
	int a, b, ans;

	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'A') {
			a = i;
			break;
		}
	}
	for (int i = s.size() -1 ; i >= 0; i--) {
		if (s.at(i) == 'Z') {
			b = i;
			break;
		}
	}
	ans = b - a + 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int A,B,C,X[105][105],Y[105][105],i,j,k;
long long t;
int main()
{
	scanf("%d%d%d",&A,&B,&C);
	for(i=0;i<A;i++)
		for(j=0;j<B;j++)
			scanf("%d",&X[i][j]);
	for(i=0;i<B;i++)
		for(j=0;j<C;j++)
			scanf("%d",&Y[i][j]);
	for(i=0;i<A;i++)
	{
		for(j=0;j<C;j++)
		{
			for(k=t=0;k<B;k++)
				t+=X[i][k]*Y[k][j];
			printf("%lld%s",t,j==C-1?"\n":" ");
		}
	}
	return 0;
}


Measured memory_bytes: 2104
N,X,Y = gets.split.map(&:to_i)

ans = Array.new(N-1,0)  # 距離
1.step(N) do |i|
  (i+1).step(N) do |j|
    a = j - i
    b = (X-i).abs + 1 + (j-Y).abs
    d = a < b ? a : b
    ans[d-1] += 1 if d > 0
  end
end
puts ans

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

template <class T>
struct RangeSum {
  vector<T> vec;
  RangeSum() {}
  RangeSum(vector<T> elems) : vec(elems) {
    for (int i = 1; i < vec.size(); i++) { vec[i] += vec[i - 1]; }
  }
  T sum(int l, int r) {
    if (l > r) return T(0);
    if (l == 0)
      return vec[r];
    else
      return vec[r] - vec[l - 1];
  }
};

void solve() {
  ll ans = 0ll;
  map<char, ll> m;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    m[s[0]]++;
  }
  ans += (m['M'] * m['A'] * m['R']);
  ans += (m['M'] * m['A'] * m['C']);
  ans += (m['M'] * m['A'] * m['H']);
  ans += (m['M'] * m['R'] * m['C']);
  ans += (m['M'] * m['R'] * m['H']);
  ans += (m['M'] * m['C'] * m['H']);
  ans += (m['A'] * m['R'] * m['C']);
  ans += (m['A'] * m['R'] * m['H']);
  ans += (m['A'] * m['C'] * m['H']);
  ans += (m['R'] * m['C'] * m['H']);
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();
  return 0;
}


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

int sosu[101];

void decom(int n){
	for(int i= 2;i * i <= n;i++){
		while(n % i == 0){
			sosu[i]++;
			n /= i;
		}
	}
	if (n != 1) sosu[n]++;
}
int shichigo(int n1, int n2, int n3){
	int res = 0;
	for(int i=1;i<=100;i++){
		if (n2 > 0){
			for(int j=i+1;j<=100;j++){
				if(n3 > 0){
					for(int k=j+1;k<=100;k++){
						if(sosu[i] >= n1 && sosu[j] >= n2 && sosu[k] >= n3) res++;
					}
				}
				else{
					if(sosu[i] >= n1 && sosu[j] >= n2) res++;
				}
			}
		}
		else{
			if(sosu[i] >= n1) res++;
		}
	}
	return res;
}

int main(){
	int N;
	cin >> N;
	for(int i = 1;i<= N;i++){
		decom(i);
	}
	int res = 0;
	res += shichigo(74,0,0);
	res += shichigo(2,24,0);
	res += shichigo(24,2,0);
	res += shichigo(4,14,0);
	res += shichigo(14,4,0);
	res += shichigo(2,4,4);
	res += shichigo(4,2,4);
	res += shichigo(4,4,2);
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	
	string s;
	cin>>s;

	int a=200000,z=-1;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A') a=min(a,i);
		if(s[i]=='Z') z=max(z,i);
	}
	
	cout<<z-a+1<<endl;
	
	return 0;
	
}
	

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
const int INF = 100000000;
typedef pair<ll,ll> P;
ll h,w;
std::vector<string> s;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll d[20][20];

int bfs(ll sx,ll sy){
  int max=0;
  queue<P> que;
  for (size_t i = 0; i < h; i++)
    for (size_t l = 0; l < w; l++)
      d[i][l] = INF;
  que.push(P(sx,sy));
  d[sx][sy] = 0;

  while (que.size()) {
    P p=que.front(); que.pop();
    for (size_t i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#' && d[nx][ny] == INF){
        que.push(P(nx,ny));
        d[nx][ny] = d[p.first][p.second]+1;
        if(max < d[nx][ny]){
          max = d[nx][ny];
        }
      }
    }
  }
  return max;
}

int main(){
  int ans=0;
  cin >> h >> w;
  s.resize(h);
  for (size_t i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (size_t sx = 0; sx < h; sx++) {
    for (size_t sy = 0; sy < w; sy++) {
      if(s[sx][sy] == '#'){
        continue;
      }
      int temp = bfs(sx,sy);
      if(ans < temp)ans = temp;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    ll a[N];
    for(ll i = 0; i < N; i++){
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a, a + N);
    ll sum[N + 1] = {};
    for(ll i = 0; i < N; i++) sum[i + 1] = a[i] + sum[i];
    ll ans = 1145148931919810;
    for(ll i = 0; i <= N; i++){
        ll b = a[i - (i == N)];
        ll kosu = i - (N - i);
        ans = min(ans, -sum[i] + (sum[N] - sum[i]) + b * kosu);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
from itertools import combinations_with_replacement

def main():
    N, M, Q = map(int, input().split())
    qs = [list(map(int,input().split())) for _ in range(Q)]
    seq = [i for i in range(1,M+1)]
    C = combinations_with_replacement(seq, N)
    max_score = 0

    for A in C:
        A = sorted(A)
        score = 0
        for q in qs:
            if A[q[1]-1] - A[q[0]-1] == q[2]:
                score += q[3]
        max_score = max(score, max_score)
    print(max_score)

if __name__ == '__main__':
    main()

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

int main(){
    
    int n;
    const int hei = -2;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    vector<string> hai;
    while((n != 1)){
        if(abs(n)%2 == 1){
            hai.push_back("1");
            if(n<0){
                n = n/hei + 1;
            }
            else{
                n = n/hei;
            }
        }
        else{
            hai.push_back("0");
            n = n/hei;
        }
    }
    hai.push_back("1");
    for(int i=(int)hai.size()-1; i>=0; i--){
        cout << hai.at(i);
    }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;   priority_queue<int, vector<int> ,greater<int> > pq;
  int a; for(int i=0;i<n;i++){cin>>a; pq.push(a);}
  int val=0;
  for(int i=0;i<k;i++){a=pq.top(); pq.pop(); val+=a;}
  cout<<val<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

long long cnt = 0;
int A[1000000];
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i-g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[], int n) {

    for (int h = 1; ;) {
        if (h > n)
            break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for (int i = G.size()-1; i >= 0; i--)
        insertionSort(A, n, G[i]);
}

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

    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);

    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;

    for (int i = G.size()-1; i >= 0; i--) {
        printf("%d", G[i]);
        printf(i == 0 ? "\n" : " ");
    }

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

    for(int i = 0; i < n; i++)
        printf("%d\n", A[i]);

    return 0;
}

Measured memory_bytes: 7160