akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int A = nextInt();
		int B = nextInt();
		String S = nextString();
		String[] p =  S.split("-");
		String ans = "No";
		if(p.length==2&&p[0].length()==A&&p[1].length()==B){
			ans="Yes";
		}
		System.out.println(ans);
	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

bool cmp(char a,char b){
	return a>b;
}

int main()
{
	string s,t;
	
	cin>>s>>t;
	
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	
	if(s<t)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
#include <stdlib.h>

int main(){
    int N,x;
    scanf("%d",&N);
    for (int i=0; i<N; i++) {
        scanf("%d",&x);
        if (x%2==0) {
            if (x%3!=0 && x%5!=0) {
                printf("DENIED\n");
                return 0;
            }
        }
    }
    printf("APPROVED\n");
    return 0;
}


Measured memory_bytes: 128
i = false

while true
  cost = gets.to_i/10 #????°????0????¬±??¶??????
  break if cost==0

  puts "" if i
  i = true
  
  m1,m5,m10,m50 = gets.split(" ").map{|s| s.to_i}

  n = m1+5*m5+10*m10+50*m50 #?????????n = m1+m5+m10+m50??¨??????????????§?????????????????????????????£???????????°???????????????????????¨????????£????????????????????????????????¨??¨10???????????¨?????????????????°???????????????????????¨??????????????§????????????????????????????????????

  for i in 0..m1
    for j in 0..m5
      for k in 0..m10
        for l in 0..m50
          change = i + j*5 + k*10 + l*50 - cost
          if change >= 0
            mm1 = m1-i+change%5
            mm5 = m5-j+(change%10)/5
            mm10 = m10-k+(change%50)/10
            mm50 = m50-l+(change/50)

            nn = mm1+mm5+mm10+mm50
            a1,a5,a10,a50,n = i,j,k,l,nn if n>nn

          end
        end
      end
    end
  end

  puts "10 #{a1}" if a1!=0
  puts "50 #{a5}" if a5!=0
  puts "100 #{a10}" if a10!=0
  puts "500 #{a50}" if a50!=0
end

Measured memory_bytes: 8744
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int m = sc.nextInt();
    int d = sc.nextInt();
    int cnt = 0;
    for(int i = 1;i <= m;i++){
      for(int j = 22;j <= d;j++){
        int x = j/10;
        int y = j%10;
        if(x>=2&&y>=2&&x*y==i)cnt++;
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 22612
n = int(raw_input())
for i in range(n):
  left, right = [], []
  arr = map(int, raw_input().split(' '))
  for a in arr:
    if len(left) == 0 or left[len(left)-1] < a:
      left.append(a)
    elif len(right) == 0 or right[len(right)-1] < a:
      right.append(a)
    else:
      break

  if len(arr) == len(left) + len(right):
    print 'YES'
  else:
    print 'NO'

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    map<pair<string, string>, int> left;
    
    for(int mask = 0; mask < 1<<n; mask++){
        string a, b;
        for(int i=0; i<n; i++){
            if(mask&(1<<i)){
                a += s[i];
            }else{
                b += s[i];
            }
        }
        left[{a,b}]++;
    }
    long long ans = 0;
    for(int mask = 0; mask < 1<<n; mask++){
        string a, b;
        for(int i=0; i<n; i++){
            if(mask&(1<<i)){
                a += s[2*n-1-i];
            }else{
                b += s[2*n-1-i];
            }
        }
        ans += left[{a,b}];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 91904
import heapq

N,M=input().split()
N,M=int(N),int(M)
A=input().split()
A=[-int(n) for n in A]

heapq.heapify(A)

for i in range(M):
    a=((-1*heapq.heappop(A))//2)*(-1)
    heapq.heappush(A,a)
sum=0
for i in range(N):
    sum+=A[i]
print(-sum)


Measured memory_bytes: 14180
#include <cstdio>
#include <cmath>
#include <cstring>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 5;
pii sx[N];
int ex[N];
int ans[N];
int x[N], d[N];
int n, l, t;

void solve() {
    ll c = 0;
    for (int i=0; i<n; ++i) {
        int dir = d[i] == 2 ? -1 : 1;
        ll pos = (ll)x[i] + dir * t;
        c += (pos > 0 ? pos/l : (pos-l+1)/l);
        ex[i] = (pos%l+l) % l;
    }
    c = (c%n+n) % n;
    sort(sx, sx+n);
    sort(ex, ex+n);
    for (int i=0; i<n; ++i) {
        ans[sx[i].second] = ex[(i+c)%n];
    }
    for (int i=0; i<n; ++i) {
        printf("%d\n", ans[i]);
    }
}

int main() {
    scanf("%d%d%d", &n, &l, &t);
    for (int i=0; i<n; ++i) {
        scanf("%d%d", &x[i], &d[i]);
        sx[i] = pii(x[i], i);
    }
    solve();
    return 0;
}


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

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll table[200010];
ll A[200010];

int main(){
    string S;
    cin >> S;
    ll N = S.size();
    reverse(ALL(S));
    table[0] = 1;
    FOR(i,1,200010){
        table[i] = (table[i-1] * 10) % 2019;
    }
    rep(i,N){
        A[i+1] = ((S[i] - '0') * table[i] + A[i]) % 2019;
    }
    map<ll,ll> mp;
    ll ans = 0;
    rep(i,N+1){
        if(i != 0){
            if(S[i-1] != '0'){
                ans += mp[A[i]];
            }
        }else{
            ans += mp[A[i]];
        }
        mp[A[i]]++;
    }
    cout << ans << endl;
}


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

using namespace std;

int main(void){
    string line;
    int count[26];
    for (int i = 0; i < 26; i++) {
        count[i] = 0;
    }
    for (; getline(cin, line); ) {
        for (int i = 0; i < line.length(); i++) {
            if (isupper(line[i])) {
                count[line[i] - 'A']++;
            } else if (islower(line[i])) {
                count[line[i] - 'a']++;
            }
        }
    }
    for (int i = 0; i < 26; i++) {
        cout << (char)(i+'a') << " : " << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007

ll findgcd(ll n,ll m){
    return __gcd(n,m);
}
ll findlcm(ll n,ll m){
    return (n*m)/findgcd(n,m);
}

int main(){
    int n;
    cin>>n;
    if(n==1) cout<<0;
    else cout<<1;

return 0;
}

Measured memory_bytes: 3628
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
 
data_list = list(map(int,input().split(" ")))
ans = Base_10_to_n(data_list[0], data_list[1])
print(len(ans))

Measured memory_bytes: 3060
function main(input) {
  let [n,m,x] = input[0].trim().split(" ").map(i => parseInt(i));

  let a = [];
  let c = [];

  for(let i=0;i<n;i++){
    a[i] = input[i+1].trim().split(" ").map(i => parseInt(i));
    c[i] = a[i].shift();
  }

  let pattern = [];

  function getPattern(pat,position){
    if(position===0){
      pattern.push(pat)
    }else{
      let a = [...pat];
      let b = [...pat];
      a.push(0);
      b.push(1);
      getPattern(a,position-1);
      getPattern(b,position-1);
    }
  }
  getPattern([],n)

  let min = (10**5) * 13;
  for(let i of pattern){
    let sum = [];
    let c_sum = 0;
    for(let j=0;j<m;j++){
      sum[j]=0;
    }
    for(let j in i){
      if(i[j]===1){
        for(let k=0;k<m;k++){
          sum[k]+=a[j][k];
        }
        c_sum+=c[j];
      }
    }
    let judge=true;
    for(let j in sum){
      if(sum[j]<x){
        judge=false;
        break;
      }
    }
    if(judge && (min>c_sum)){
      min = c_sum;
    }
  }

  console.log((min===((10**5)*13))?-1:min);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 36876
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e3 + 5, M = 1e5 + 5;

int n, m, a[N], b[N];
ll dp[N][N][3], MOD(1e9 + 7);

ll solve(int i, int j, int men){
    if(i == n || j == m)return 0;
    ll &ret = dp[i][j][men];
    if(~ret)return ret;
    ret = 0;
    if(men == 0){
        ret = (ret + solve(i, j, men + 1)) % MOD;
        ret = (ret + solve(i, j + 1, men)) % MOD;
    }
    else if(men == 1){
        ret = (ret + solve(i, j, men + 1)) % MOD;
        ret = (ret + solve(i + 1, j, men)) % MOD;
    }
    else if(men == 2 && a[i] == b[j])
        ret = (ret + solve(i + 1, j + 1, 0) + 1) % MOD;
    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0 ; i < n ; ++i)scanf("%d", a + i);
    for(int i = 0 ; i < m ; ++i)scanf("%d", b + i);
    memset(dp, -1, sizeof dp);
    ll ans = solve(0, 0, 0) + 1;
    printf("%lld\n", ans % MOD);
}

Measured memory_bytes: 94848
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int bit[maxn],nxt[2][maxn],pre[2][maxn];
int n;
int get(int idx){
    int sum=0;
    for(;idx>0;idx-=(idx&(-idx)))
        sum+=bit[idx];
    return sum;
}
int get(int l,int r){
    return get(r)-get(l-1);
}
void update(int idx,int val){
    for(;idx<=n;idx+=((idx)&(-idx)))
        bit[idx]+=val;
}
int p[maxn],pos[maxn];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&p[i]);
        pos[p[i]]=i;
    }
    for(int i=n;i>=1;i--){
        int cur = pos[i];
        if(get(cur+1,n)==0){
            nxt[0][cur]=-1;
            nxt[1][cur]=-1;
        }
        else{
            int l=cur+1,r=n,mid,ans;
            while(l<=r){
                mid=l+r>>1;
                if(get(cur,mid)>=1){
                    ans=mid;
                    r=mid-1;
                }
                else{
                    l=mid+1;
                }
            }
            nxt[0][cur]=ans;
            if(get(cur,n)==1){
                nxt[1][cur]=-1;
            }
            else{
                l=cur+1,r=n;
                while(l<=r){
                    mid=l+r>>1;
                    if(get(cur,mid)>=2){
                        ans=mid;
                        r=mid-1;
                    }
                    else l=mid+1;
                }
                nxt[1][cur]=ans;
            }
        }
        if(get(cur-1)==0){
            pre[0][cur]=-1;
            pre[1][cur]=-1;
        }
        else{
            int l=1,r=cur-1,mid,ans;
            while(l<=r){
                mid=l+r>>1;
                if(get(mid,cur)>=1){
                    ans=mid;
                    l=mid+1;
                }
                else{
                    r=mid-1;
                }
            }
            pre[0][cur]=ans;
            if(get(cur)==1){
                pre[1][cur]=-1;
            }
            else{
                l=1, r=cur-1;
                while(l<=r){
                    mid=l+r>>1;
                    if(get(mid,cur)>=2){
                        ans=mid;
                        l=mid+1;
                    }
                    else{
                        r=mid-1;
                    }
                }
               // cout<<cur<<'\n';
               // cout<<ans<<'\n';
                pre[1][cur]=ans;
            }
        }
        update(cur,1);
    }

    long long ans=0;
    int l,r,ll,rr;
    for(int i=1;i<=n;i++){
         r=nxt[0][i];
         l=pre[0][i];
         ll=pre[1][i];
         rr=nxt[1][i];
      //   printf("%d %d %d %d\n",l,r,ll,rr);
        if(r==-1 && l==-1)continue;
        if(r!=-1){
        ans += (1LL)*p[i]*((rr==-1 ? n+1:rr)-(r))*(l==-1 ? i : i-l);
        }
        if(l!=-1){
        ans += (1LL) * p[i] *(ll==-1 ? l: l-ll) *(r==-1 ? n-i+1: r-i);
        }
       // cout<<ans<<'\n';
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 7168
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N, M = mis()
    S = input()

    ans = []
    r = N
    l = max(r - M, 0)
    while r > 0:
        for i in range(l, r):
            if S[i] == '0':
                ans.append(r - i)
                r = i
                l = max(r - M, 0)
                break
        else:
            print(-1)
            return
    ans.reverse()
    print(*ans, sep=' ')


main()


Measured memory_bytes: 6896
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int a, b, c;
  cin >> a >> b >> c;
  if(a==b){
    cout << c << endl;
  }else if(b==c){
    cout << a << endl;
  }else{
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const int MAXN = 3e3 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;
ll a[MAXN];
ll dp[MAXN][MAXN];
ll n;

bool check(ll k){
    if ((n % 2 and k % 2) or (!n%2 and !k%2)){
        return true;
    }
    return false;
}

ll memoize(int l,int r){
    if (l > r){
        return 0;
    }
    if (dp[l][r] != -1){
        return dp[l][r];
    }
    int turn = n - r + l;
    if (turn & 1){
        return dp[l][r] = max(memoize(l + 1,r) + a[l],memoize(l,r - 1) + a[r]);
    }
    else{
        return dp[l][r] = min(memoize(l + 1,r) - a[l],memoize(l,r - 1) - a[r]);
    }
}

int main()
{
    fast_io;
    cin >> n;
    memset(dp,-1,sizeof(dp));
    for (int i = 1;i <= n;i++){
        cin >> a[i];
    }
    cout << memoize(1,n) << endl;
}


Measured memory_bytes: 71168
import sys


def ask(n):
    print n
    sys.stdout.flush()
    ans = raw_input()
    if ans == 'Female':
        return 0
    elif ans == 'Male':
        return 1
    else:
        exit()


N = input()
x = ask(0)
l = 1
r = N-1
lx = x
rx = x

while True:
    m = (l + r) / 2
    x = ask(m)
    if (m - l + 1) % 2 == 0 and lx != x:
        r = m - 1
        rx = x
    elif (m - l + 1) % 2 == 1 and lx == x:
        r = m - 1
        rx = x
    elif (r - m + 1) % 2 == 0 and rx != x:
        l = m + 1
        lx = x
    elif (r - m + 1) % 2 == 1 and rx == x:
        l = m + 1
        lx = x
    else:
        r = m - 1
        rx = x


Measured memory_bytes: 3292
// https://atcoder.jp/contests/abc144/tasks/abc144_a
#include <iostream>

int main()
{
	std::cin.sync_with_stdio(false);
	std::cout.sync_with_stdio(false);

	int a, b;
	std::cin >> a >> b;
	if (a > 9 || b > 9)
		std::cout << -1;
	else
		std::cout << a * b;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
l,x,y = [],min(a,b),max(a,b)
for i in range(1,x+1):
  if x%i==0 and y%i==0: 
    l.append(i)
l = l[::-1]
#print(l)
print(l[c-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    int res = 0;
    for (int i=1;i<=N;i++){
        if (to_string(i).length()%2==1) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <int mod>
struct ModInt
{
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p)
    {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p)
    {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p)
    {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p)
    {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const
    {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0)
        {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const
    {
        ModInt ret(1), mul(x);
        while (n > 0)
        {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p)
    {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a)
    {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt<(int)(1e9 + 7)>;
int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    map<char, ll> M;
    rep(i, N)
    {
        cin >> S[i];
        char c = S[i][0];
        if (c == 'M' or c == 'A' or c == 'R' or c == 'C' or c == 'H')
        {
            M[c] += 1;
        }
    }
    ll ans(0);
    for (auto i : M)
    {
        for (auto j : M)
        {
            for (auto k : M)
            {
                if (i != k and i != j and j != k)
                {
                    ans += i.second * j.second * k.second;
                }
            }
        }
    }
    cout << (ans / 6);
    return 0;
}

Measured memory_bytes: 5760
N=int(input())
S=input()
ans=0
for i in range(1,N):
  l=[]
  r=[]
  for j in range(i):
    l.append(S[j])
  for j in range(i,N):
    r.append(S[j])
  count=0
  for item in set(l):
    if item in r:
      count+=1
  if ans<count:
    ans=count
print(ans)

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

int main(){
    int64_t X;
    cin >> X;
    vector<int64_t> A(241, 1);
    int j = 0;
    for(int i=-120; i<=120; i++){
        for(int k=0; k<5; k++) A.at(j) *= i;
        j++;
    }
    int i=0;
    j=0;
    bool flag = false;
    for(i=0; i<241; i++){
        for(j=0; j<241; j++){
            if(A.at(i) - A.at(j) == X){
                flag = true;
                break;
            } 
        }
        if(flag) break;
    }
    cout << i - 120 << " " << j - 120 << endl;
}

Measured memory_bytes: 3588
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	N := next.Int()
	M := next.Int()
	n := make([]int, N+1)
	var a, b int
	for i := 0; i < M; i++ {
		a = next.Int()
		b = next.Int()
		n[a]++
		n[b]++
	}
	for i := 0; i < N; i++ {
		fmt.Println(n[i+1])
	}
}

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

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a []int) int {
	r := 0
	for i := 0; i < len(a); i++ {
		r += a[i]
	}
	return r
}

func pro(a []int) int {
	r := 1
	for i := 0; i < len(a); i++ {
		r *= a[i]
	}
	return r
}

func fill(a []int, n int) []int {
	for i := 0; i < len(a); i++ {
		a[i] = n
	}
	return a
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) String() string {
	return s.next()
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Ints(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = s.Int()
	}
	return r
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003;
const ll INF=1LL<<62;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    bool ok=true;
    
    for(int i=0;i<N;i++){
        int a;cin>>a;
        if(a%2==0){
            if(a%5&&a%3) ok=false;
        }
    }
    
    if(ok) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    
    
}



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 N               200005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    fio();

    string n;
    cin>>n;

    ll sum = 0;
    for(char c : n){
        int j = c - '0';
        sum += j;
    }

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

    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;

int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);cout.tie(0);
	int n;
	int a=0,b=0,c=0,d=0;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		if(s=="AC"){
			a++;
		}else if(s=="WA"){
			b++;
		}else if(s=="TLE"){
			c++;
		}else if(s=="RE"){
			d++;
		}
	} 
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
 	return 0;
}







Measured memory_bytes: 3608
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double L;
    cin >> L;
    cout << setprecision(10) << (L/3.0)*(L/3.0)*(L/3.0) << endl;



}

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

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

  vector<int> a(n);
  rep(i, n) cin >> a.at(i);

  sort(a.begin(), a.end());

  cout << abs(a.at(0) - a.at(n-1));
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h, w;
  cin>>h>>w;
  vector<string> vec(h);
  for(int i = 0; i < h; ++i)cin>>vec[i];
  const int inf = 1e9;
  vector<int> e(w, inf);
  vector<vector<int> > f(h, e);
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(i == 0 && j == 0)f[0][0] = (vec[0][0] == '#');
      else{
	if(i > 0){
	  f[i][j] = min(f[i][j], f[i - 1][j] + (vec[i-1][j] == '.' && vec[i][j] == '#'));
	}
	if(j > 0){
	  f[i][j] = min(f[i][j], f[i][j-1] + (vec[i][j-1] == '.' && vec[i][j] == '#'));
	}
      }
    }
  }
  cout<<f[h-1][w-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    string s;cin >> s;
    string ans = (s[2]==s[3] && s[4]==s[5])?"Yes":"No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n,k;
  cin >> n >> k;
  vll a(n);
  rep(i,0,n) cin >> a[i];
  ll g=a[0];
  rep(i,1,n) g=__gcd(g,a[i]);
  
  ll m=*max_element(all(a));
  
  if(m>=k&&(k%g==0)) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3948
N = int(input())
Testimony = []
for a_ in range(N):
    A_ = int(input())
    A = [tuple(map(int, input().split())) for _ in range(A_)]
    Testimony.append(A)

ans = 0


for i in range(1, 2**N):
    Honesty = [-1] * N
    flag = True
    for j in range(N):
        if not flag:
            break
        if (i >> j) & 1 == 1:
            if Honesty[j] == 0:
                flag = False
                break
            Honesty[j] = 1
            for jx, jy in Testimony[j]:
                jx -= 1
                if Honesty[jx] < 0:
                    Honesty[jx] = jy
                elif Honesty[jx] != jy:
                    flag = False
                    break
        else:
            if Honesty[j] == 1:
                flag = False
                break
            else:
                Honesty[j] = 0

    if flag:
        ans = max(ans, str(bin(i)).count('1'))

print(ans)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

class dice
{
public:
  int d[6];
  int t;
  int n;
  int e;
  int s;
  int w;
  int b;
  string cmd;
  
  dice();
  int init();
  int setCmd();
  int move(char c);
  int runCmd();
  int top();
};

dice::dice()
{
  t = 0;
  n = 4;
  e = 2;
  s = 1;
  w = 3;
  b = 5;
}

int dice::init()
{
  for(int i = 0; i < 6; i++ )
    {
      cin >> d[i];
    }
  return 0;
}

int dice::setCmd()
{
  cin >> cmd;
  return 0;
}

int dice::move(char c)
{
  int tmp;
  
  if ( c == 'E' )
    {
      tmp = t;
      t = w;
      w = b;
      b = e;
      e = tmp;
    }
  else if ( c == 'N' )
    {
      tmp = t;
      t = s;
      s = b;
      b = n;
      n = tmp;
    }
  else if ( c == 'S' )
    {
      tmp = t;
      t = n;
      n = b;
      b = s;
      s = tmp;
    }
  else if ( c == 'W' )
    {
      tmp = t;
      t = e;
      e = b;
      b = w;
      w = tmp;
    }

  return 0;
}

int dice::runCmd()
{
  for ( int i = 0; i < (int)cmd.size(); i++ )
    move( cmd[i] );

  return 0;
}

int dice::top()
{
  cout << d[t] << endl;
  return 0;
}

int main()
{
  dice d;
  
  d.init();
  d.setCmd();
  d.runCmd();
  d.top();
  
  return 0;
}

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

int index(int numToFind, std::vector<int> vectorToFindIn) {int len = vectorToFindIn.size();for (int i = 0; i < len; i++){if (vectorToFindIn[i] == numToFind){return i;}}return -1;}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	--a[0];
	bool isTrue = true;
	for (int i=1;i<n;++i)
	{
		if (a[i]<a[i-1])
		{
			isTrue=false;
			break;
		}
		if (a[i]>a[i-1])
		{
			--a[i];
		}
	}
	if (isTrue)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    i64 S;
    cin >> S;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    int l = 0, r = 0;
    int minwidth = 1e9;
    i64 sum = 0;
    while (1) {
        if (sum < S) {
            if (r == n) break;
            sum += as[r];
            r++;
            continue;
        }
        if (sum > S) {
            minwidth = min(minwidth, r - l);
            sum -= as[l];
            l++;
            continue;
        }
        minwidth = min(minwidth, r - l);
        sum -= as[l];
        l++;
    }
    cout << (minwidth == 1e9 ? 0 : minwidth) << endl; 
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{long long ans,n,i,k,min=1000000000009;
cin>>n;
for(i=1;i<=1000001;i++)
 {
 if(n%i==0)
 {
 k=n/i;
 ans=i+k-2;
 if(ans<min)
 min=ans;
 }
 
 
}
cout<<min;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef int I;const I INF=INT_MAX/4;typedef vector<I> vi;I n,a,b,s,f;vi nei[100005];vi bfs(I start){vi d(n,INF);d[start]=0;queue<I> q;q.push(start);while(!q.empty()){I t=q.front();q.pop();for(I i=0;i<nei[t].size();i++){I u=nei[t][i];if(d[u]>d[t]+1){d[u]=d[t]+1;q.push(u);}}}return d;}int main(){scanf("%d",&n);for(I i=0;i<n-1;i++){scanf("%d%d",&a,&b);a--;b--;nei[a].push_back(b);nei[b].push_back(a);}vi dis=bfs(0),rdis=bfs(n-1);for(I i=0;i<n;i++)if(dis[i]>rdis[i])s++;else f++;puts(f>s?"Fennec":"Snuke");}

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

main(){
	int n;
	cin >> n;
	int x[n][2];
	for(int i=0;i<n;i++){
		cin >> x[i][0] >> x[i][1];
	}
	
	int p,q;
	int answer_sub=0;

	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int ans_sub=0;
			p=x[j][0]-x[i][0];
			q=x[j][1]-x[i][1];
			
			for(int k=0;k<n-1;k++){
				for(int l=k+1;l<n;l++){
					if( ( x[l][0]-x[k][0]==p && x[l][1]-x[k][1]==q ) || ( x[k][0]-x[l][0]==p && x[k][1]-x[l][1]==q ) ){
						ans_sub++;
					}
				}
			}
			if(ans_sub>answer_sub){
				answer_sub=ans_sub;
			}
		}
	}
	int answer=n-answer_sub;
	cout << answer <<endl;
}


Measured memory_bytes: 256
def insertion_sort(array, gap):
    n = len(array)
    cnt = 0
    for i in range(gap, n):
        moving = array[i]
        j = i - gap
        while j >= 0 and array[j] > moving:
            array[j + gap] = array[j]
            j -= gap
            cnt += 1
        array[j + gap] = moving
    return array, cnt


def main():
    n = int(input())
    array = []
    for i in range(n):
        array.append(int(input()))

    cnt = 0
    gaps = []
    i = 1
    gap = 1
    while gap <= n:
        gaps.append(gap)
        i += 1
        gap = (3 ** i - 1) // 2
    gaps = gaps[:100][::-1]

    # shell_sort
    for gap in gaps:
        array, tmp_cnt = insertion_sort(array, gap)
        cnt += tmp_cnt

    print(len(gaps))
    print(" ".join(map(str, gaps)))
    print(cnt)
    for i in array:
        print(i)
    return

main()


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

using namespace std;

namespace program
{
	namespace IO
	{
		struct input_t
		{
			static const int BUF_SIZ = 500000;
			FILE *f;
			char Buf[BUF_SIZ], *p, *pend;
			input_t(FILE *_f) : f(_f), p(Buf), pend(Buf) {}
			~input_t() { fclose(f); }
			char getchar();
			template <typename T>
			T read();
		};

		char input_t::getchar()
		{
			if (p >= pend)
			{
				p = Buf;
				pend = Buf + fread(Buf, sizeof(char), BUF_SIZ, f);
				if (p >= pend)
					return EOF;
			}
			return *p++;
		}

		template <typename T>
		T input_t::read()
		{
			T s = 0;
			int fl = 0;
			char ch;
			while (!isdigit(ch = getchar()))
				fl ^= (ch == '-');
			do
				s = s * 10 + ch - '0';
			while (isdigit(ch = getchar()));
			return fl ? -s : s;
		}

		struct output_t
		{
			static const int BUF_SIZ = 500000;
			FILE *f;
			char Buf[BUF_SIZ], *p, *const pend;
			output_t(FILE *_f) : f(_f), p(Buf), pend(Buf + BUF_SIZ) {}
			~output_t()
			{
				fwrite(Buf, sizeof(char), p - Buf, f);
				fclose(f);
			}
			void putchar(char ch);
			template <typename T>
			void write(T x);
			void puts(const char *ch);
		};

		void output_t::putchar(char ch)
		{
			*p++ = ch;
			if (p >= pend)
			{
				fwrite(Buf, sizeof(char), p - Buf, f);
				p = Buf;
			}
		}

		template <typename T>
		void output_t::write(T x)
		{
			static char St[30];
			char *top = St;
			if (x < 0)
			{
				putchar('-');
				x = -x;
			}
			do
				*top++ = x % 10 + '0';
			while (x /= 10);
			while (top > St)
				putchar(*--top);
		}

		void output_t::puts(const char *ch)
		{
			while (*ch)
				putchar(*ch++);
			putchar('\n');
		}
	}

	IO::input_t input(stdin);
	IO::output_t output(stdout);

	typedef long long big;

	const int MAXN = 100000;

	template <typename T>
	vector<T> &operator*=(vector<T> &A, vector<int> B)
	{
		vector<T> C = A;
		for (int i = 0; i < A.size(); i++)
			A[i] = C[B[i]];
		return A;
	}

	template <typename T1, typename T2>
	void qpow(T1 &S, T2 X, big n)
	{
		while (n)
		{
			if (n & 1)
				S *= X;
			X *= X;
			n >>= 1;
		}
	}

	void work()
	{
		int n = input.read<int>(), m;
		big k;
		vector<big> X;
		vector<int> C;
		for (int i = 0; i < n; i++)
		{
			X.push_back(input.read<big>());
			C.push_back(i);
		}
		for (int i = n - 1; i > 0; i--)
			X[i] -= X[i - 1];
		m = input.read<int>();
		k = input.read<big>();
		while (m--)
		{
			int x = input.read<int>();
			swap(C[x - 1], C[x]);
		}
		qpow(X, C, k);
		for (int i = 1; i < n; i++)
			X[i] += X[i - 1];
		for (int i = 0; i < n; i++)
		{
			output.write(X[i]);
			output.puts(".0");
		}
	}
}

int main()
{
	program::work();
	return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string a,b;cin>>a>>b;
  a+=b;
  ll x=stoll(a);
  ll y=sqrt(x);
  ans1(x==y*y);
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  sort(a.begin(),a.end());

  Int ans=0;
  if(n&1||a[n/2-1]==a[n/2]){
    Int c=a[n/2];
    vector<Int> b(n);
    for(Int i=0;i<n;i++) b[i]=abs(c-a[i]);
    sort(b.begin(),b.end());
    for(Int i=0;i<n;i++){
      ans+=b[i];
      if(i>=2) ans+=b[i];
    }    
  }else{
    Int c=a[n/2];
    vector<Int> x,y;
    for(Int i=0;i<n;i++){
      if(a[i]<c) x.emplace_back(c-a[i]);
      else y.emplace_back(a[i]-c);
    }
    
    assert(x.size()==y.size());
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());      

    Int res=0;
    for(Int i=0;i<(Int)x.size();i++){
      res+=x[i];
      if(i) res+=x[i];
    }
    for(Int i=0;i<(Int)y.size();i++){
      res+=y[i];
      if(i) res+=y[i];
    }
    
    chmax(ans,res);
  }
  
  cout<<ans<<endl;
  return 0;
}


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

// const long long int MOD = 1000000007;
const int MOD = 1000000007;


int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N, vector<int>(0)), y(N, vector<int>(0));
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        vector<int> empty(A[i]);
        x[i] = empty;
        y[i] = empty;
        for (int j = 0; j < A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    int ans = 0;
    for (int tmp = 0; tmp < (1 << N); tmp++) {
        bitset<15> b(tmp);
        int ok_tmp = 1;
        for (int i = 0; i < N; i++) {
            if (b.test(i)) {
                for (int j = 0; j < A[i]; j++) {
                    if (y[i][j] == 1 && !(b.test(x[i][j]))) {
                        ok_tmp *= 0;
                        break;
                    }
                    else if (y[i][j]==0 && b.test(x[i][j])) {
                        ok_tmp *= 0;
                        break;
                    }
                }
            }
            if (ok_tmp == 0) {
                break;
            }
        }
        if (ok_tmp) {
            int alt = b.count();
            ans = max(ans, alt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3544
// AUTHOR:-  Harsh Thete
//   IIIT-Allahabad

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define feb(i,a,b) for(ll i=a;i>=b;i--)
#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define t 	int t;cin>>t;while(t--)
#define pb push_back
#define ub upper_bound
#define lb lower_bound


bool prime[1000001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=1000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=1000000; i += p) 
                prime[i] = false; 
        } 
    } 
  
} 

ll biexp(ll x, ll y) 
{ 
    ll res = 1;     
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1; 
        x = x*x;  
    }
    return res; 
}
ll bemo(ll x, ll y, ll m)  
{  
    ll res = 1;  
  
    x = x % m;  
   
    if (x == 0) return 0; 
  
    while (y > 0)  
    {   
        if (y & 1)  
            res = (res*x) % m;  
  
        y = y>>1; 
        x = (x*x) % m;  
    }  
    return res;  
}  
void my_ans_is()
{
int n;cin>>n;ll h[n+1];
  fl(i,0,n)
    cin>>h[i];
  ll dp[n+1];
  dp[0]=0;dp[1]=abs(h[1]-h[0]);
  fl(i,2,n)
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  cout<<dp[n-1];
}
int main()
{
	fst;
	//t
	{
         my_ans_is();
        }
   return 0;
}

Measured memory_bytes: 5172
n,a,b,c=map(int, input().split( ))
cnts = {"A":a,"B":b,"C":c}
ans=[]
s = [input() for _ in range(n)]+[""]
def rnd(ss,t):

    if cnts[ss[0]]>cnts[ss[1]]:
        cnts[ss[0]]-=1; cnts[ss[1]]+=1
        ans.append(ss[1])
    elif cnts[ss[1]]>cnts[ss[0]]:
        cnts[ss[0]]+=1; cnts[ss[1]]-=1
        ans.append(ss[0])
    else:
        if ss[0] in s[t]:
            cnts[ss[0]]+=1;cnts[ss[1]]-=1
            ans.append(ss[0])
        else:
            cnts[ss[1]]+=1;cnts[ss[0]]-=1
            ans.append(ss[1])

    for k in cnts:
        if cnts[k]<0:
            print("No")
            exit()
for i in range(n):
    rnd(s[i],i+1)
print("Yes")
for ai in ans:
    print(ai)

Measured memory_bytes: 88920
#include<stdio.h>
int main(){
	int x;
	long i;
	i=0;
	scanf("%d",&x);
	while(x>0){
	i++;
//	if(i<10000){
		printf("Case %ld: %d\n",i,x);
//	}
		scanf("%d",&x);
	}
	return 0;
}



Measured memory_bytes: 2048
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
D, X = map(int, input().split())

A = [int(input()) for _ in range(N)]

for i in range(N):
    for j in range(1, D + 1, A[i]):
        X += 1

print(X)

Measured memory_bytes: 9672