akhauriyash/Code-Regression huggingface dataset:
def examA():
    X, Y, Z = LI()
    X, Y = Y,X
    X,Z = Z, X
    print(X,Y,Z)
    return

def examB():
    N, M = LI()
    A = LI()
    need = (sum(A)-1)//(4*M) + 1
    ans = 0
    #print(need)
    for a in A:
        if a>=need:
            ans += 1
    if ans>=M:
        print("Yes")
    else:
        print("No")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

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

int main() {
	int n, m, A[100][100], b[100], c[100];
	cin >> n >> m;
	
	for ( int i = 0; i < n; i++ ){
		for ( int j = 0; j < m; j++ ) cin >> A[i][j];
	}
	for ( int i = 0; i < m; i++ ) cin >> b[i];
	
	for ( int i = 0; i < n; i++ ){
		c[i] = 0;
		for ( int j = 0; j < m; j++ ){
			c[i] += A[i][j]*b[j];
		}
	}
	
	for ( int i = 0; i < n; i++ ) cout << c[i] << endl;
	
	
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define INF (int) 2e9
#define MOD (int) 1e9 + 7
typedef long long ll;

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    vector<ll> v;

    for (ll i = 1; i <= sqrt(g); i++) {
        if(g%i==0){
            if(i!=sqrt(g)){
                v.emplace_back(i);
                v.emplace_back(g/i);
            }else{
                v.emplace_back(i);
            }
        }
    }

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

    vector<ll> ans;
    bool ok;
    for (auto u : v){
        ok = true;
        for(auto a:ans){
            if(__gcd(a, u)!=1){
                ok = false;
                break;
            }
        }

        if(ok) ans.emplace_back(u);
    }
            
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	cout << 1 + (n - 2) / (k - 1) << endl;
}


Measured memory_bytes: 768
#include<cstdio>
using ll=long long;
int main(){
    ll w,h,x,y;
    scanf("%lld%lld%lld%lld",&w,&h,&x,&y);
    printf("%.10lf %d\n",(double)w*h/2,((x*2==w)&&(y*2==h))?1:0);
    return 0;
}

Measured memory_bytes: 128
import math

def input_number():
    return int(input())

def is_odd(number):
    if number % 2 == 1:
        return True
    else:
        return False

def is_8(number):
    fraction_of_the_number = 0
    for i in range(1, int(math.sqrt(number)) + 1, 2):
        if number % i == 0:
            fraction_of_the_number += 2
    if fraction_of_the_number == 8 and is_odd(number):
        return True
    else:
        return False

def main():
    n = input_number()
    answer = 0
    for i in range(1, n+1, 2):
        if is_8(i):
            answer += 1
    print(answer)

main()

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

typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int n; cin >> n;
    int hap[n][3];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> hap[i][j];
        }
    }
    int dp[n][3];
    dp[0][0] = hap[0][0], dp[0][1] = hap[0][1], dp[0][2] = hap[0][2];
    for (int i = 1; i < n; ++i) {
        dp[i][0] = hap[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = hap[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = hap[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }
    int k = max(dp[n - 1][0], dp[n - 1][1]);
    k = max(dp[n - 1][2], k);
    cout << k << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Measured memory_bytes: 5928
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	var sum float64
	for i := 0; i < n; i++ {
		sum += 1 / a[i]
	}

	fmt.Println(1 / sum)
}


Measured memory_bytes: 512
A, B, C = map(int, input().split())
K = int(input())
k = 0
ans = 'Yes'
while k <= K and (B <= A or C <= B):
    if B <= A:
        B *= 2
    elif C <= B:
        C *= 2
    if k == K:
        ans = 'No'
    k += 1
print(ans)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll T1,T2,A1,A2,B1,B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll p = (A1 - B1) * T1;
    ll q = (A2 - B2) * T2;
    if(p > 0){
        p *= -1;
        q *= -1;
    }
    if(p + q < 0){
        cout << 0 << endl;
    }else if(p + q == 0){
        cout << "infinity" << endl;
    }else{
        ll s = (-p) / (p + q);
        ll t = (-p) % (p + q);
        cout << (s * 2 + (t == 0 ? 0 : 1)) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string p;
  cin >> p;

  for (int i = 0; i < p.size(); i++) {
    if (p[i] == '?') {
      p[i] = 'D';
    }
  }

  cout << p << ln;

  return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int N;
  cin >> N;
  ll app=2;
  ll ap=1;
  rep(i,N-1){
    ll t=ap;
    ap=app + ap;    
    app=t;
  }
  cout << ap << endl;
  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>
main(){
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  char A;
  while(scanf("%c",&A)!=EOF){
    if('A'<=A&&A<='Z'){
      A=tolower(A);
    }
    else if('a'<=A&&A<='z'){
      A=toupper(A);
    }
    printf("%c",A);
  }
  return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(){
    int a, b, n, p;
    scanf("%d %d %d", &n, &a, &b);
    p = n * a;
    if(p < b){
        printf("%d\n", p);
    }else if(b < p){
        printf("%d\n", b);
    }else if(b == p){
        printf("%d\n", p);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define vi vector<long long>
#define vvi vector<vector<long long>>
int main(void){
  long long H;
  cin >> H;
  long long i;
  for(i = 0; H>1; i++){
    H = H/2;
  }
  long long pw;
  for(pw = 1; i>=0; i--){
    pw *= 2;
  }
  cout<<pw-1;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

int main(){
    int n,m;
    int count;
    bool flag=false;
    cin >> n >> m;
    vector<vector<char>>a(n,vector<char>(n));
    vector<vector<char>>b(m,vector<char>(m));
    rep(i,n)rep(j,n) cin >> a[i][j];
    rep(i,m)rep(j,m) cin >> b[i][j];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            count=0;
            if(a[i][j]==b[0][0]){
                if(i+m-1<n&&j+m-1<n){
                    for(int s=0;s<m;s++){
                        for(int t=0;t<m;t++){
                            if(a[i+s][j+t]==b[s][t]) count++;
                        }
                    }
                }
                if(count==m*m) flag=true;
            }
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	
	x -= a;
	x%=b;
	cout<<x<<endl;
	
	return 0;
}




Measured memory_bytes: 764
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let nw = lines.shift().split(/\s/).map((v) => v - 0);
    let N = nw[0] - 0, W = nw[1] - 0;
    let wv = new Array(N);
    for (let n = 0; n < N; n++) {
        wv[n] = lines.shift().split(/\s/).map((v) => v - 0);
    }
    let dp = new Array(N + 1).fill(0).map(() => new Array(W + 1).fill(0));
    for (let n = 0; n < N; n++) {
        for (let sum_w = 0; sum_w <= W; ++sum_w) {
            if (sum_w - wv[n][0] >= 0) {
                dp[n + 1][sum_w] = Math.max(dp[n + 1][sum_w], dp[n][sum_w - wv[n][0]] + wv[n][1]);
            }
            dp[n + 1][sum_w] = Math.max(dp[n + 1][sum_w], dp[n][sum_w]);
        }
    }
    console.log(dp[N][W]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
/*
N	W
6	15

w	v
6	5
5	6
6	4
6	6
3	5
7	2

	0	1	2	3	4	5	6	7	8	9	10	11	12	13	14	15
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1	0	0	0	0	0	0	5	5	5	5	5	5	5	5	5	5
2	0	0	0	0	0	6	6	6	6	6	6	11	11	11	11	11
3	0	0	0	0	0	6	6	6	6	6	6	11	11	11	11	11
4	0	0	0	0	0	6	6	6	6	6	6	12	12	12	12	12
5	0	0	0	5	5	6	6	6	11	11	11	12	12	12	17	17
6	0	0	0	5	5	6	6	6	11	11	11	12	12	12	17	17
*/


Measured memory_bytes: 197776
#include<stdio.h>
#include<string.h>
#define MAX 1005

char X[MAX], Y[MAX];
int dp[MAX][MAX], q;

int max(int a, int b){
    if (a>b)
        return a;
    return b;
}

int SS() {
  int i,j, save=0;
  int n = strlen(X);
  int m = strlen(Y);
  
  memset(dp,0,sizeof dp);
  
  for(i=0;i<n;i++) {
    for(j=0;j<m;j++) {
      if(i) 
        dp[i][j] = max(dp[i][j],dp[i-1][j]);
      if(j)
        dp[i][j] = max(dp[i][j],dp[i][j-1]);
      if(X[i] == Y[j]) {
    	dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
	    save = max(save,dp[i+1][j+1]);
      }
    }
  }
  return save;
}

int main() {
  int i;
  
  scanf("%d",&q);
  for(i=0;i<q;i++) {
      scanf(" %s",&X[0]);
      scanf(" %s",&Y[0]);
      printf("%d\n",SS());
  }
  
  return 0;
}



Measured memory_bytes: 5800
#include<iostream>
#define int long long
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define line cout<<"here - "<<__LINE__<<"\n";
#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
#define infi INT_MAX
#define rinfi INT_MIN
#define inf 1e18
#define ff first
#define ss second
using namespace std;
main()
{
    //fast
    int tc=1,i,j,k;
//    cin>>tc;
    while(tc--)
    {
       int a;
       cin>>a;
       int aa[a];
       for(i=0;i<a;i++)
        cin>>aa[i];
        int ans=inf;
       for(i=-100;i<=100;i++)
       {
           int sum=0;
           for(j=0;j<a;j++)
           {
               sum+=(abs(i-aa[j])*abs(i-aa[j]));
           }
           ans=min(ans,sum);
       }
       cout<<ans<<endl;
    }
}




Measured memory_bytes: 3548
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		if(K % 2 == 0) {
			System.out.println((long)(Math.pow((N / (K / 2)) - (N / K), 3) + Math.pow(N / K, 3)));
		} else {
			System.out.println((long)(Math.pow(N / K, 3)));
		}
	}
}


Measured memory_bytes: 23892
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;

  if (S.size() + 1 == T.size()) {
    if (S == T.substr(0, S.size()))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

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


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

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

    std::vector<int> a(n + 2);
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        std::cin >> a[i];
        sum += std::abs(a[i] - a[i - 1]);
    }
    sum += std::abs(a[n + 1] - a[n]);

    for (int i = 1; i <= n; i++)
    {
        int x = std::abs(a[i - 1] - a[i]);
        int y = std::abs(a[i] - a[i + 1]);
        int z = std::abs(a[i - 1] - a[i + 1]);
        std::cout << sum - x - y + z << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3756
{
  const main = (input: string) => {
    const read = reader(input)
    const [p, q, r] = read.ns()

    console.log(Math.min(p + q, q + r, r + p))
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


Measured memory_bytes: 7372
# フェルマーの小定理
N, K = map(int, input().split())

m = 1000000007

n = max(K, N - K + 1)
fac = [0] * (n + 1)
fac[0] = 1
for i in range(n):
    fac[i + 1] = fac[i] * (i + 1) % m


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


result = []
for i in range(1, K + 1):
    result.append(mcomb(K - 1, i - 1) * mcomb(N - K + 1, i) % m)
print('\n'.join(str(i) for i in result))


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

using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll money = 1000;
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    bool have = false;
    for (ll i = 0; i < n; i++) {
        if (have) {
            if (i == n - 1) {
                while (cnt > 0) {
                    money += a[i];
                    cnt--;
                }
                continue;
            }
            if (a[i] < a[i + 1]) {
                continue;
            }
            money += cnt * a[i];
            cnt = 0;
            have = false;
        } else {
            if (i == n - 1) {
                continue;
            }
            if (a[i] > a[i + 1]) {
                continue;
            }
            ll div = money / a[i];
            ll mod = money % a[i];
            money = mod;
            cnt = div;
            have = true;
        }
    }
    cout << money << endl;
    return 0;
}


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

int n;
string s;
int ta = 0;
int iwa = 0;

int main(){
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			ta++;
		}
		else {
			ta--;
		}
		if (iwa < ta) {
			iwa = ta;
		}
	}
	cout << iwa << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    sort(A.begin(), A.end());
    vector<ll> P, Ne;
    for(int i=1;i<N-1;i++){
    	if(A[i] >= 0){
    		P.push_back(A[i]);
    	}else{
    		Ne.push_back(A[i]);
    	}
    }
    vector<pll> sec;

    ll tmp1 = A[N-1];
    REP(i, Ne.size()){
    	sec.push_back({tmp1, Ne[i]});
    	tmp1 -= Ne[i];
    }

    ll tmp2 = A[0];
    REP(i, P.size()){
    	sec.push_back({tmp2, P[i]});
    	tmp2 -= P[i];
    }
    ll res = tmp1 - tmp2;
    sec.push_back({tmp1, tmp2});
    cout << res << endl;
    REP(i, sec.size()){
    	cout << sec[i].first << " " << sec[i].second << endl;
    }
    return 0;
}

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

int main()
{
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> S(n, vector<ll>(2));
  vector<vector<ll>> P(m, vector<ll>(2));

  for (int i = 0; i < n; i++)
  {
    ll a, b;
    cin >> a >> b;
    S.at(i).at(0) = a;
    S.at(i).at(1) = b;
  }
  for (int i = 0; i < m; i++)
  {
    ll c, d;
    cin >> c >> d;
    P.at(i).at(0) = c;
    P.at(i).at(1) = d;
  }

  for (int i = 0; i < n; i++)
  {
    ll man = 200000000;
    ll ans = m;
    for (int j = 0; j < m; j++)
    {
      ll d = abs(S.at(i).at(0) - P.at(j).at(0)) + abs(S.at(i).at(1) - P.at(j).at(1));
      if (man > d)
      {
        ans = j + 1;
      }
      man = min(man, d);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3612
#include<stdio.h>
int main()
{
    int x=0,y=0,z=0,n,i,p;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&p);
        if(p%4==0)
            z=z+1;
        if(p%2==0)
            y=y+1;
        else
            x=x+1;
    }
    y=y-z;
    if(n%2&&n!=3){
        if(z>=x-1)
        printf("Yes");
    else printf("No");
    }
    else if(n==3)
    {
        if(z>=1||y==3)
            printf("Yes");
        else
            printf("No");
    }
    else {if(z>=x)
        printf("Yes");
    else printf("No");}
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#include<functional>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<double,double>P;


void recursive_comb(int *indexes, int s, int rest, function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int main()
{
    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,n)
    {
        cin>>s[i];
    }
    map<char,ll> smap;
    rep(i,n)
    {
        smap[s[i][0]]++;
    }
    vector<ll> num;
    num.push_back(smap['M']);
    num.push_back(smap['A']);
    num.push_back(smap['R']);
    num.push_back(smap['C']);
    num.push_back(smap['H']);
    ll ans=0;
    foreach_comb(5,3,[&](int *indexes)
    {
        ans+=(num[indexes[0]]*num[indexes[1]]*num[indexes[2]]);
    });
    cout<<ans;
}

Measured memory_bytes: 6144
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>

//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
ll n;
struct Edge{
  ll to,dist;
};
ll dy[200000];
ll ds[200000];
vector<Edge> Gy[200000];
vector<Edge> Gs[200000];
void dijkstraY(ll u){
  REP(i,n)dy[i]=INF;
  priority_queue<P,vector<P>,greater<P>> que;
  que.push({0,u});
  while(!que.empty()){
    auto r=que.top();que.pop();
    if(r.first>=dy[r.second])continue;
    dy[r.second]=r.first;
    
    for(Edge& e: Gy[r.second]){
      que.push({r.first+e.dist,e.to});
    }
  }
}
void dijkstraS(ll u){
  REP(i,n)ds[i]=INF;
  priority_queue<P,vector<P>,greater<P>> que;
  que.push({0,u});
  while(!que.empty()){
    auto r=que.top();que.pop();
    if(r.first>=ds[r.second])continue;
    ds[r.second]=r.first;
    
    for(Edge& e: Gs[r.second]){
      ll dist=ds[r.second]+e.dist;
      if(dist>=ds[e.to])continue;
      que.push({r.first+e.dist,e.to});
    }
  }
}
int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll m,s,t;cin>>n>>m>>s>>t;//n都市,m電車,都市sからtに移動
  s--,t--;
  ll u0,v0,a0,b0;
  REP(i,m){
    cin>>u0>>v0>>a0>>b0;//a円bスヌーク
    u0--,v0--;
    Gy[u0].push_back({v0,a0});
    Gy[v0].push_back({u0,a0});
    Gs[u0].push_back({v0,b0});
    Gs[v0].push_back({u0,b0});
  }
  dijkstraY(s);
  dijkstraS(t);
  
  ll ans[n+1];ans[n]=INF;
  REP(i,n){
    ans[n-i-1]=min(ans[n-i],dy[n-i-1]+ds[n-i-1]);
  }
  REP(i,n){
    cout<<(1000000000000000LL-ans[i])<<"\n";
  }
  return 0;
}


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


int main()
{
     int a,b;
     scanf("%d%d",&a,&b);
     for(int i=min(a,b);i<=max(a,b);i++)
     {
     	  if(abs(a-i)==abs(b-i)) 
		   {
		   	  printf("%d",i);
		   	  return 0;
		   }
	 }
	 printf("IMPOSSIBLE");
	 return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

h = ni()
c = 1
ans = 0
while h:
    ans += c
    c <<= 1
    h >>= 1
print(ans)


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

#define int long long 

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}
 
void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int > 
#define fr first
#define sc second
#define mp make_pair

#define vec vector<pii >
#define pb push_back
#define iter vector <pii > :: iterator
#define for_vec(i,x) for(iter i=x.begin();i!=x.end();i++) 

#define _sort(x,y) sort(x.begin(),x.end(),y)
#define I (int)

const int maxn = 3e5+10;
const int inf = 1e9;
const lf eps = 1e-8;

int cmpx(pii x,pii y) {return x.fr<y.fr;}
int cmpy(pii x,pii y) {return x.sc<y.sc;}

int son[maxn][2],v[maxn][2],n,d[maxn],mid,mn[maxn];
vec f[maxn];

void solve(vec &ls,vec &rs,vec &s) {
    if(ls.size()>rs.size()) swap(ls,rs);
    if(!s.empty()) s.clear();
    _sort(ls,cmpy),_sort(rs,cmpx);
    mn[0]=rs[0].sc;for(int i=1;i<I rs.size();i++) mn[i]=min(mn[i-1],rs[i].sc);
    int p1=0,p2=rs.size()-1;
    for(;p1<I ls.size();p1++) {
	while(p2>=0&&ls[p1].sc+rs[p2].fr>mid) p2--;
	if(~p2) s.pb(mp(ls[p1].fr,mn[p2]));
    }
    _sort(ls,cmpx),_sort(rs,cmpy);
    mn[0]=rs[0].fr;for(int i=1;i<I rs.size();i++) mn[i]=min(mn[i-1],rs[i].fr);
    for(p1=0,p2=rs.size()-1;p1<I ls.size();p1++) {
	while(p2>=0&&ls[p1].fr+rs[p2].sc>mid) p2--;
	if(~p2) s.pb(mp(mn[p2],ls[p1].sc));
    }
}

void dfs(int x) {
    if(!son[x][0]) return f[x].pb(mp(0,0)),void();
    int l=son[x][0],r=son[x][1];dfs(l),dfs(r);
    vec &ls=f[l],&rs=f[r];
    for_vec(i,ls) i->fr+=v[x][0],i->sc+=v[x][0];
    for_vec(i,rs) i->fr+=v[x][1],i->sc+=v[x][1];
    solve(ls,rs,f[x]);ls.clear(),rs.clear();
}

signed main() {
    read(n);
    for(int i=2,x,y;i<=n;i++) read(x),read(y),son[x][d[x]]=i,v[x][d[x]++]=y;
    int l=0,r=1e10,ans=1e10;
    while(l<=r) {
	mid=(l+r)>>1,dfs(1);//puts("fuckpps");printf("mid :: %lld %lld %lld\n",mid,l,r);
	//for_vec(i,f[1]) printf("%lld %lld\n",i->fr,i->sc);
	if(f[1].empty()) l=mid+1;
	else r=mid-1,ans=mid;f[1].clear();
    }write(ans);
    return 0;
}


Measured memory_bytes: 38648
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int k, s;

int main(void) {
	cin >> k >> s;
	int ret = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k && x + y <= s; y++) {
			int z = s - x - y;
			if (z <= k)
				ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7
P = 2 ** 127 - 1

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

pow2 = [1] * (N + 10)
for n in range(1, N + 10):
    pow2[n] = pow2[n - 1] * 2 % MOD

def mod_P(x):
    if x < 0:
        x += P
    high = x >> 127
    low = x & P
    x = low + high
    if x >= P:
        x -= P
    return x

def inv_mod(a):
    b = P
    u, v = 1, 0
    while a:
        q, r = divmod(b, a)
        a, b = r, a
        u, v = v - q * u, u
    if b < 0:
        v = -v
    if v < 0:
        v += P
    return v

pair_key = {0:-1, -1:0}

def to_key(a, b):
    if a == 0:
        return -1
    if b == 0:
        return 0
    
    x = mod_P(inv_mod(a) * abs(b))
    if b < 0:
        x = P - x
    y = P - mod_P(inv_mod(b) * abs(a))
    if a < 0:
        y = P - y
    pair_key[x] = y
    return x

  
counter = defaultdict(int)
origin = 0
for a, b in zip(A, B):
    if a == b == 0:
        origin += 1
        continue
    key = to_key(a, b)
    counter[key] += 1

answer = origin
k = 1
for key, cnt in counter.items():
    key1 = pair_key[key]
    if key1 not in counter:
        k *= pow2[cnt]
    elif key < key1:
        x, y = cnt, counter[key1]
        k *= pow2[x] + pow2[y] - 1
    k %= MOD
answer += k - 1
answer %= MOD
print(answer)


Measured memory_bytes: 182112
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define REP(i, n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;


class BFoodsLovedByEveryone {
public:
    int N, M;
    int fav[31]{0};


    void solve(std::istream& in, std::ostream& out) {
        in >> N >> M;
        REP(i, N) {
            int K; in >> K;
            REP(j, K) {
                int tmp; in >> tmp; fav[tmp]++;
            }
        }
        int res = 0;
        for (int i = 1; i <= M; ++i) {
            if (fav[i] == N) res++;
        }
        out << res << endl;
    }
};


int main() {
    BFoodsLovedByEveryone solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
x, y = map(int, input().split())
GroupA = [1,3,5,7,8,10,12]
GroupB = [4,6,9,11]
GroupC = [2]

if x in GroupA and y in GroupA:
    print("Yes")
elif x in GroupB and y in GroupB:
    print("Yes")
elif x in GroupC and y in GroupC:
    print("Yes")
else:
    print("No")


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;



int main(){
    int X; cin >> X;
    int res=X*360/__gcd(X, 360)/X;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h> 
using namespace std; 
int main()
{  int count=0;
	string str ,str2;
	cin>>str>>str2;
	for(int i=0;i<3;i++)
	{ 
		if(str[i]==str2[i])
		{
			count++;
		}}
		cout<<count;
		return 0;
	
	}



Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cmath>

using namespace std;

int main(){
	
	int in;
	scanf("%d", &in);
	
	if(in == 22) printf("Christmas Eve Eve Eve\n");
	if(in == 23) printf("Christmas Eve Eve\n");
	if(in == 24) printf("Christmas Eve\n");
	if(in == 25) printf("Christmas\n");
	
	return 0;
	
}


Measured memory_bytes: 128
n, k = map(int, input().split())
ls = [int(input()) for _ in range(n)]

ls.sort(reverse=True)

ans = 10 ** 9

for i in range(n - k + 1):
	sa = ls[i] - ls[i + k - 1]
	if sa <= ans:
		ans = sa

print(ans)

Measured memory_bytes: 7384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		long[,,,,] dp=new long[n+1,4,4,4,2];
		dp[1,0,0,0,0]=1;
		dp[1,0,0,1,0]=1;
		dp[1,0,0,2,0]=1;
		dp[1,0,0,3,0]=1;
		long ans=0;
		for(int i = 2;i<=n;i++) {
			for(int j = 0;j<4;j++) {
				for(int k = 0;k<4;k++) {
					for(int l = 0;l<4;l++) {
						if(j==1&&k==2&&l==3){continue;}
						if(j==1&&k==3&&l==2){continue;}
						if(j==2&&k==1&&l==3){continue;}
						for(int m = 0;m<4;m++) {
							if(j==0&&k==2&&l==3&&m==1){continue;}
							if(j==2&&k==0&&l==3&&m==1){continue;}
							if(j==2&&k==2&&l==3&&m==1){continue;}
							dp[i,j,k,l,0]+=dp[i-1,m,j,k,0];
							dp[i,j,k,l,0]%=mod;
						}
						if(i==n){ans=(ans+dp[i,j,k,l,0])%mod;}
					}
				}
			}
		}
		Console.WriteLine(ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b; cin >> a >> b;
	cout << a*b << endl;
	return 0;
}


Measured memory_bytes: 3612
package main

import (
    "fmt"
    "os"
    "bufio"
)

func ScanLongStringLine() string {
    maxSize := 1000000
    reader := bufio.NewReaderSize(os.Stdin, maxSize)
    buffer := make([]byte, 0)
    for {
        line, isPrefix, err := reader.ReadLine()
        if err != nil {
            fmt.Println(err)
        }
        buffer = append(buffer, line...)
        if !isPrefix {
            break
        }
    }
    return string(buffer)
}

func main() {
    S := ScanLongStringLine()

    i := 0
    count := 0
    temp := ""
    pre := ""
    for (i < len(S)) {
        temp += string(S[i])
        i += 1
        if (temp != pre) {
            pre = temp
            temp = ""
            count += 1
        }
    }
    fmt.Println(count)
}

Measured memory_bytes: 2304
def sumGCD(N,K,M):
    dp = [None for _ in range(K+1)]
    #dp[i]:gcd(A) % i == 0を満たすAの個数
    for i in reversed(range(1,K+1)):
        dp[i] = pow(K//i,N,M)
        for j in range(2,K//i+1):
            dp[i] -= dp[i*j]
            dp[i] %= M

    output = 0
    for i in range(1,K+1):
        output += (dp[i]*i)
        output %= M

    return output

def main():
    N,K = map(int,input().split())

    print(sumGCD(N,K,10**9+7))

if __name__ == "__main__":
    main()


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

int main() {
    int n, m; cin >> n >> m;
    int x[m+1], y[m+1];
    for (int i = 1; i <= m; i++) cin >> x[i] >> y[i];

    int num[n+1];
    bool red[n+1];
    for (int i = 1; i <= n; i++) {
        num[i] = 1;
        red[i] = false;
    }
    red[1] = true;

    for (int i = 1; i <= m; i++) {
        if (red[x[i]]) {
            red[y[i]] = true;
        }

        num[x[i]] -= 1;
        num[y[i]] += 1;

        if (!num[x[i]]) {
            red[x[i]] = false;
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (red[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
//a_i>a_jとなる場合の数
ll dp[3000][3000];
int a[3000]; int n,q;
ll calc() {
	ll res = 0;
	rep(i, n) {
		Rep(j, i + 1, n) {
			res += dp[i][j]; res %= mod;
		}
	}
	return res;
}
const ll t2 = (mod + 1) / 2;
int main() {
	cin >> n>>q;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		rep(j, n) {
			if (a[i] > a[j])dp[i][j] = 1;
		}
	}
	rep(aa, q) {
		//cout << calc() << endl;
		int x, y; cin >> x >> y; x--; y--;
		rep(i, n) {
			if (i == x || i == y)continue;
			dp[i][x] = dp[i][y] = (dp[i][x] + dp[i][y]) % mod*t2%mod;
			dp[x][i] = dp[y][i] = (dp[x][i] + dp[y][i]) % mod*t2%mod;
		}
		dp[x][y] = dp[y][x] = (dp[x][y] + dp[y][x]) % mod*t2%mod;
		/*rep(i, n) {
			Rep(j, i + 1, n) {
				cout << i<<" "<<j<<" "<<dp[i][j] << endl;
			}
		}*/
	}
	ll c = calc();
	rep(i, q) {
		c *= 2; c %= mod;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 70528
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    ll cnt = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if ( a&1 ) ++cnt;
    }
    cout << ((cnt&1) ? "NO" : "YES") << endl;
    return 0;
}


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

using namespace std;

bool CheckBug(string, map< char, pair< int, map<int, int> > >*);
bool CheckArray(string, int*, map< char, pair< int, map<int, int> > >*);
bool FindData(const char, int*, map< char, pair< int, map<int, int> > >*);
int AtoiString(const string);

int main(){
  int count, ans;
  string str;
  map< char, pair< int, map<int, int> > > data;

  while(1){
    cin >> str;
    if(str == ".") break;

    ans = 0;
    if(!CheckBug(str, &data)) ans = 1;

    count = 2;
    while(1){
      cin >> str;
      if(str == ".") break;
      if(ans != 0) continue;
      if(!CheckBug(str, &data)) ans = count;
      ++count;
    }

    cout << ans << endl;
    data.clear();
  }
  return 0;
}

bool CheckBug(string str, map< char, pair< int, map<int, int> > >* data){
  int n, m;
  string::iterator i;
  i = find(str.begin(), str.end(), '=');

  if(i == str.end()){
    if(!CheckArray(str, &n, data)) return false;
    map<int, int> empty_map;
    data->insert(make_pair(str[0], make_pair(n, empty_map)));
    return true;
  }else{
    string front(str.begin(), i);
    string back(i+1, str.end());
    if(!CheckArray(front, &n, data)) return false;

    if(find(back.begin(), back.end(), '[') == back.end()){
      m = AtoiString(back);
    }else{
      if(!CheckArray(back, &m, data)) return false;
      if(!FindData(back[0], &m, data)) return false;
    }

    map< char, pair< int, map<int, int> > >::iterator j;
    j = data->find(front[0]);
    if(j == data->end()) return false;
    if(n >= j->second.first) return false;

    map<int, int>::iterator k;
    k = j->second.second.find(n);
    if(k == j->second.second.end())
      j->second.second.insert(make_pair(n, m));
    else
      k->second = m;

    return true;
  }
}

bool CheckArray(string str, int* n, map< char, pair< int, map<int, int> > >* data){
  int i, j;
  i = str.find_last_of('[', string::npos) + 1;
  j = str.find_first_of(']', 0);
  const string str_(str.begin()+i, str.begin()+j);
  *n = AtoiString(str_);

  while(1){
    i -= 2;
    if(i == 0) return true;
    if(!FindData(str[i], n, data)) return false;
  }
}

bool FindData(const char c, int* n, map< char, pair< int, map<int, int> > >* data){
  map< char, pair< int, map<int, int> > >::iterator i;
  i = data->find(c);
  if(i == data->end()) return false;

  map<int, int>::iterator j;
  j = i->second.second.find(*n);
  if(j == i->second.second.end()) return false;

  *n = j->second;
  return true;
}

int AtoiString(const string s){
  int i, x, d;
  for(i=s.size()-1, x=0, d=1; i>=0; --i, d*=10)
    x += ((s[i] - 48) * d);
  return x;
}

Measured memory_bytes: 1252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		// 解説閲覧後

		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		int k = Integer.parseInt(br.readLine());

		HashSet<String> set = new HashSet<String>();
		set.add(s);

		for (int i = s.length() - 1; 0 <= i; i--) {
			for (int j = (k <= s.length() - i ? k : s.length() - i); 0 < j; j--) {
				set.add(s.substring(i, i + j));
			}
		}

		ArrayList<String> list = new ArrayList<String>(set);
		Collections.sort(list);

		System.out.println(list.get(k - 1));

	}

}


Measured memory_bytes: 24372
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N;
	cin >> N;
	map<ll, int, greater<ll>> cnt;
	REP(i, N) {
		ll A;
		cin >> A;
		cnt[A]++;
	}
	auto it = cnt.begin();
	ll res = 0;
	while (it != cnt.end() && it->second < 2) it++;
	if (it != cnt.end()) {
		if (it->second >= 4) {
			ll tmp = it->first;
			res = tmp * tmp;
		}
		else {
			ll tmp = it->first;
			it++;
			while (it != cnt.end() && it->second < 2) it++;
			if (it != cnt.end()) res = tmp * it->first;
		}
	}
	cout << res << "\n";

	return 0;
}

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

using namespace std;

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

    double ans = 0.0;
    while (n--) {
        double x;
        string s;
        cin >> x >> s;
        if (s == "BTC") x *= 380000.0;
        ans += x;
    }

    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# input
inp = input()
switch_num = int(inp.split()[0]) #N
light_num = int(inp.split()[1]) #M
switch_info = [input() for i in range(light_num)]
p_info = input()

# データ整理
k_list = []
for l in switch_info:
    k_list.append(int(l.split()[0]))
s_list = []
for l in switch_info:
    l_list = [int(i) for i in l.split()[1:]]
    s_list.append(l_list)
p_list = [int(l) for l in p_info.split()]

#bit作成
bit_list = []
for i in range(2 ** switch_num):
    c = format(i,'b').zfill(switch_num)
    bit_list.append(c)
bit_list = [list(i) for i in bit_list]

#電球のon/off確認
result = 0
for bit in bit_list:
    on_num = 0
    for i in range(light_num):
        on_light = sum([int(bit[s-1]) for s in s_list[i]])
        # print(on_light)
        if p_list[i] == (on_light%2):
            on_num += 1
    if on_num == light_num:
        result += 1

print(result)

Measured memory_bytes: 3316
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();

        string A, X, C;
        void solve() {
            A = cin.next();
            X = cin.next();
            C = cin.next();

            string ans = ""+A[0] + X[0] + C[0];

            Console.WriteLine(ans);

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
        }

        class Mathf {
            public int mod = 1000000007;//10^9+7
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {
                if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
            }
            public int GCD(int a, int b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
            public int GCD(int[] array) { return array.Aggregate((v, next) => GCD(v, next)); }
            public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int main(int argc, char **argv) {
    int N, A[100000];
    cin >> N;
    for(int i = 0; i < N; ++i)
        cin >> A[i];

    multiset<int> iset;
    for(int i = 0; i < N; ++i) {
        auto it = iset.lower_bound(A[i]);

        if(it == iset.begin()) {
            iset.insert(A[i]);
        } else {
            iset.erase(--it);
            iset.insert(A[i]);
        }
    }
    
    cout << iset.size() << endl;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll> va,vb;
	rep(i,0,n){
		ll a;
		cin>>a;
		va.pb(a);
	}
	rep(i,0,n){
		ll a;
		cin>>a;
		vb.pb(a);
	}
	ll c = 0;
	rep(i,0,n){
		if(va[i]>vb[i]){
			c += va[i]-vb[i];
		}
	}
	rep(i,0,n){
		if(va[i]<vb[i]){
			ll d = vb[i]-va[i];
			d -= d%2;
			c -= d/2;
		}
	}
	if(c<=0){
	    cout << "Yes" << endl;
	}
	else{
	    cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
n,m = map(int, input().split())

p = [-1]*n
for i in range(m):
  s,c = map(int, input().split())
  s -= 1
  if p[s] == -1:
    p[s] = c
  if p[s] != c:
    print(-1)
    exit()

if n == 1:
  if p[0] == -1:
    print(0)
    exit()
else:
  if p[0] == -1:
    p[0] = 1
  for i in range(1, n):
    if p[i] == -1:
      p[i] = 0
      
ans = ''
for i in p:
  ans += str(i)
ans = int(ans)

if len(str(ans)) == n:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 3064