akhauriyash/Code-Regression huggingface dataset:
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    l = [int(i) for i in ipt().split()]
    l.sort()
    ans = 0
    dp = [[0]*(2*10**3+1) for i in range(2)]
    for i in l:
        ans += sum(dp[1][i+1::])
        for j in range(i,2*10**3+1):
            dp[1][j] += dp[0][j-i]
        dp[0][i] += 1
    print(ans)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 75856
import sys

def to_f(e):
  return float(e)

while True:
  line = sys.stdin.readline()
  if not line: break
  x1, y1, x2, y2, x3, y3, xp, yp = map(to_f, line.split(" "))
  a = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)
  b = (xp-x1)*(y3-y1)-(x3-x1)*(yp-y1)
  c = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1)
  s = b/a
  t = c/a
  if s>0 and t>0 and 0<s+t and s+t<1:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 6456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
vector<ll> x[1000];
vector<ll> y[1000];
int main(){
  
  ll N;
  cin>>N;
  
  vector<ll>A(N);
 
  ll ans=0;
  rep(i,N){
    cin>>A[i];
    rep(j,A[i]){
      ll a,b;
     cin>>a>>b;
      x[i].push_back(a);
      y[i].push_back(b);
      
    }
  }

  rep(i,power(2,N)){
    ll sum=0;
    bitset<15>b(i);
  string S=b.to_string();
    reverse(all(S));
 
    rep(k,N){
      ll sum2=0;
      
    rep(j,A[k]){
      if(y[k][j]==S[x[k][j]-1]-'0'){
        sum2++;
      
      }
    }
      
      if(S[k]=='1'){
if(sum2==A[k]){
  sum++;
}
   else {
sum-=mod;
   }
      }
 

   
      
   
        
    }
    ans=max(sum,ans);
  }

  cout<<ans<<endl;
  
}


    

Measured memory_bytes: 256
let count array =
  let rec count' array i max res =
    if i >= Array.length array then res
    else if array.(i) >= max then count' array (i + 1) array.(i) (res + 1)
    else count' array (i + 1) max res in
  count' array 0 0 0
;;

let () = Scanf.scanf "%d" (fun n ->
  Array.init n (fun _ -> Scanf.scanf " %d" (fun hi -> hi)) |> count |> print_int
);;

Measured memory_bytes: 384
from heapq import heappush,heappop
n=int(input())
xy=[]
yx=[]
for i in range(n):
    x,y=map(int,input().split())
    xy.append([x,y,i])
    yx.append([y,x,i])
xy.sort()
yx.sort()
data=[[0,0] for i in range(n)]
for i in range(n):
    x,y,a=xy[i]
    data[a][0]=i
    y,x,a=yx[i]
    data[a][1]=i
ans=0
que=[[0,0]]
flag=[0]*n
count=0
while count<=n:
    l,a=heappop(que)
    if flag[a]==1:
        continue
    ans+=l
    flag[a]=1
    count+=1
    if count==n:
        break
    b,c=data[a]
    xb=xy[b][0]
    yc=yx[c][0]
    if 1<=b<=n-2:
        xd,yd,d=xy[b-1]
        xe,ye,e=xy[b+1]
        if flag[d]==0:
            heappush(que,[abs(xd-xb),d])
        if flag[e]==0:
            heappush(que,[abs(xe-xb),e])
    elif b==0:
        xe,ye,e=xy[1]
        if flag[e]==0:
            heappush(que,[abs(xb-xe),e])
    else:
        xd,yd,d=xy[n-2]
        if flag[d]==0:
            heappush(que,[abs(xb-xd),d])
    if 1<=c<=n-2:
        yg,xg,g=yx[c+1]
        yf,xf,f=yx[c-1]
        if flag[f]==0:
            heappush(que,[abs(yf-yc),f])
        if flag[g]==0:
            heappush(que,[abs(yg-yc),g])
    elif c==0:
        yg,xg,g=yx[1]
        if flag[g]==0:
            heappush(que,[abs(yg-yc),g])
    else:
        yf,xf,f=yx[n-2]
        if flag[f]==0:
            heappush(que,[abs(yf-yc),f])
print(ans)


Measured memory_bytes: 60264
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int n, K;
int a[143];
int ans;

bool cmp(int u, int v) {
	return u > v;
}

int main(int argc, char const *argv[]) {
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}

	for (int i = 1; i <= n; ++i) {
		for (int j = i - 1; j <= n; ++j) {
			int lenl = j - i + 1, lenk = n - lenl;
			if (lenk > K) continue;
			vector<int> vec;
			for (int k = 1; k <= i - 1; ++k) {
				vec.push_back(a[k]);
			}
			for (int k = j + 1; k <= n; ++k) {
				vec.push_back(a[k]);
			}
			sort(vec.begin(), vec.end(), cmp);
			int kk = K - (i - 1) - (n - j);
			while (kk > 0 && !vec.empty() && vec[vec.size() - 1] < 0) {
				--kk;
				vec.pop_back();
			}
			int sum = 0;
			for (int k = 0; k < vec.size(); ++k) {
				sum += vec[k];
			}
			ans = max(ans, sum);
		}
	}

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

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main()
{
int N,i,j;
scanf("%d", &N);
for(i=1;i<=9;i++){
	for(j=1;j<=9;j++){
		if(N==i*j){
			puts("Yes");
			return 0;
        }
	}
}
puts("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

template<class T>
struct SegTree {
  int n;
  vector<T> node;
  function<T(T, T)> f;
  int iniV;
  SegTree(vector<T> v, function<T(T, T)> f, T iniV): iniV(iniV), f(f) {
    int sz = v.size();
    n = 1; while (n < sz) n *= 2;
    node.resize(n * 2 - 1, iniV);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--) {
      node[i] = f(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }
  void update(int x, T val) {
    x += n - 1;
    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = f(node[x * 2 + 1], node[x * 2 + 2]);
    }
  }
  T getval(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return iniV;
    if (a <= l && r <= b) return node[k];
    T vl = getval(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = getval(a, b, k * 2 + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

int _min(int a, int b) {
  if (a < b) return a;
  return b;
}

const int INF = 2147483647;

int main(void) {
  int n, q;
  cin >> n >> q;

  vector<int> a(n, INF);
  

  SegTree<int> seg(a, _min, INF);

  vector<int> ans;
  rep (i, q) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) seg.update(x, y);
    else ans.pb(seg.getval(x, y + 1));
  }

  rep (i, ans.size()) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 4752
import bisect
A, B, Q = map(int, input().split())
S = []
for _ in range(A):
    S.append(int(input()))
T = []
for _ in range(B):
    T.append(int(input()))

for _ in range(Q):
    x = int(input())
    sr = bisect.bisect_right(S, x)
    tr = bisect.bisect_right(T, x)
    tmpS = []
    tmpT = []
    if sr == A:
        tmpS.append(S[A-1])
    elif sr == 0:
        tmpS.append(S[sr])
    else:
        tmpS.append(S[sr])
        tmpS.append(S[sr-1])
    if tr == B:
        tmpT.append(T[B-1])
    elif tr == 0:
        tmpT.append(T[tr])
    else:
        tmpT.append(T[tr])
        tmpT.append(T[tr-1])
    ans = 10**16
    for s in tmpS:
        tmp = abs(x-s)
        tmp1 = 10**16
        for elemT in tmpT:
            tmp1 = min(tmp1, abs(elemT-s))
        ans = min(ans, tmp+tmp1)
    for t in tmpT:
        tmp = abs(x-t)
        tmp1 = 10**16
        for elemS in tmpS:
            tmp1 = min(tmp1, abs(elemS-t))
        ans = min(ans, tmp+tmp1)
    print(ans)


Measured memory_bytes: 12092
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
  
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        map<ll,ll> m;
        ll ans=0;
        rep(i,n){
        	ll x;cin>>x;
        	m[x]++;
        	ans+=x;
        }
        ll q;cin>>q;
        while(q--){
        	ll b,c;cin>>b>>c;
        	ll u=m[b];
        	m[b]=0;
        	ans-=(u*b);
        	ans+=(u*c);
        	m[c]+=u;
        	cout<<ans<<endl;
        }
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 9560
#include <iostream>
#include <list>

using namespace std;

int main(void)
{
    string init_str;
    bool inversed = false;
    list<char> processed_str;
    int operations_count;

    cin >> init_str;
    cin >> operations_count;

    for(int i = 0; i < init_str.size(); i++){
        processed_str.push_back(init_str[i]);
    }

    for(int i = 0; i < operations_count; i++){
        int operation;
        cin >> operation; // 1:inverse 2:append

        if(operation == 1){
            if(inversed){
                inversed = false;
            }else{
                inversed = true;
            }
        }else{
            int pos;
            cin >> pos; // 1:front 2:back
            char extra;
            cin >> extra;

            if((pos == 1 && !inversed) || (pos == 2 && inversed)){
                processed_str.push_front(extra);
            }else{
                processed_str.push_back(extra);
            }
        }
    }
    
    if(inversed){
        for(auto itr = processed_str.rbegin(); itr != processed_str.rend(); itr++){
            cout << *itr;
        }
        cout << endl;
    }else{
        for(auto itr = processed_str.begin(); itr != processed_str.end(); itr++){
            cout << *itr;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 9984
import itertools

N=int(input())
L=[0]*(10**4+10)
X=[x for x in range(1,101)]
plus=[0,1,3,6]

for v in itertools.combinations_with_replacement(X,3):
  x,y,z=v[0],v[1],v[2]
  temp=len(set(v))
  try:
    L[x**2+y**2+z**2+x*y+y*z+z*x]+=plus[temp]
  except:
    continue

for i in range(1,N+1):
  print(L[i])


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

int main() {
  int n;  cin >> n;
  vector<int> L(n);
  rep(i,n)
  cin >> L[i];

  sort(all(L));
  int ans=0;
  rep(b,n)rep(a,b){
    int ab=L[a]+L[b];
    int r=lower_bound(all(L),ab)-L.begin();
    int l=b+1;
    ans+=r-l;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
inf = 10000000000

def partition(a, left, right):
    pivot = a[right - 1]
    i = left - 1
    for j in range(left, right - 1):
        if a[j][1] <= pivot[1]:            
            i = i + 1
            A[i], A[j] = A[j], A[i]
            
    A[i + 1], A[right - 1] = A[right - 1], A[i + 1]
    return i + 1

def quick_sort(a, left, right):
    if left < right:
        q = partition(a, left, right)
        quick_sort(a, left, q)
        quick_sort(a, q + 1, right)

def merge(a, left, mid, right):
    L = a[left : mid] + [('jorker', inf)]
    R = a[mid : right] + [('jorker', inf)]
    i = j = 0
    for k in range(left, right):
        if L[i][1] <= R[j][1]:
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1


def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)

    

if __name__ == "__main__":
    n = int(input())
    A = [None] * n
    B = [None] * n
    for i in range(n):
        picture, number = input().split()
        A[i] = (picture, int(number))
        B[i] = (picture, int(number))
    
    quick_sort(A, 0, n)
    merge_sort(B, 0, n)

    if A == B:
        print('Stable')
    else:
        print('Not stable')

    for a in A:
        print(a[0], a[1])
    




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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 405;
LL arr[N];
LL pre[N];
LL dp[N][N];


LL dfs(int l, int r){
    //dbg_out(l, r);
    if(l == r) return 0;
    if(dp[l][r] != -1) return dp[l][r];
    LL res = pre[r+1] - pre[l];
    LL mn = 1e14;
    for(int k = l; k < r; ++k){
        mn = min(mn, dfs(l, k) + dfs(k+1, r));
    }
    return dp[l][r] = res + mn;
}

void solve(){
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> arr[i];
    pre[0] = 0;
    for(int i = 0; i < n; ++i) pre[i+1] += pre[i] + arr[i];

    memset(dp, -1, sizeof dp);
    cout << dfs(0, n-1) << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 4936
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x ;
        int y ;

        while (true) {
            x = scanner.nextInt();
            y = scanner.nextInt();
            if (x == 0 && y == 0) {

                break;
            }
            if (x <= y) {
                System.out.println(x + " " + y);
            } else {
                System.out.println(y + " " + x);
            }

        }

    }

}

Measured memory_bytes: 34472
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
bool prime[600001];
vi pr;
void primeSieve() 
{
    
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=600001; p++)
    {
        if (prime[p] == true) 
        {
        	//pr.pb(p);
            for (ll i=p*p; i<=600001; i += p) 
                prime[i] = false; 
        } 
    } 
    for(ll i=2;i<=600001;i++)
    {
    	if(prime[i])
    	{
    		pr.push_back(i);
		}
	}
}
void solve(){
	primeSieve();
	int x;
	cin>>x;
	auto y=lower_bound(pr.begin(),pr.end(),x)-pr.begin();
	if(pr[y]<x){
		y++;
	}
	cout<<pr[y]<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
    string S; cin >> S; int diff = 10e7;
    for (int i = 0; i < S.length(); ++i) {
        string w = S.substr(i, 3);
        int n = stoi(w);
        if (diff > abs(753 - n)) diff = abs(753 - n);
    }
    printf("%d\n", diff);
}


Measured memory_bytes: 3668
H, W = gets.split.map(&:to_i)
if H%3==0 || W%3==0
    puts 0; exit
end

ans = [H, W].min

(1...H).each do |i|
    s1 = i*W
    s2 = (H-i)*(W/2)
    s3 = H*W-s1-s2
    result = [s1, s2, s3].max - [s1, s2, s3].min
    ans = result if ans > result
end

(1...W).each do |i|
    s1 = i*H
    s2 = (W-i)*(H/2)
    s3 = H*W-s1-s2
    result = [s1, s2, s3].max - [s1, s2, s3].min
    ans = result if ans > result
end

puts ans

Measured memory_bytes: 1788
n, k=map(int, input().split())
a=[0]+list(map(int, input().split()))

c=1

for i in range(k, n):
    center=a[i]
    left=a[c]
    right=a[i+1]

    if left<right:
        print("Yes")
        c+=1
    else:
        print("No")
        c+=1

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define Fix( x ) setprecision( x ) << fixed
#define mem( a , x ) memset( a , x , sizeof( a ) )
#define bug( a , b ) cerr<< #a <<" = "<<a<<" , "<< #b <<" = "<<b<<"\n";
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define FOR( i , a , b ) for( int i = a; i <= b; i++ )
#define ROF( i , a , b ) for( int i = a; i >= b; i-- )
#define sz( V ) (int)V.size( )
#define all( V ) V.begin( ),V.end( )
#define Found( S , val ) S.find( val ) != S.end( )
#define Unique( V ) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
typedef pair < int , int > ii;
typedef pair < int , ii > iii;
typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)1e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );

LL a[ 2*N ];
int n;


LL calc( LL b ) {
    LL res = 0;
    for( int i = 1; i <= n; i++ ) res += abs( a[i]-(b+i) );
    return res;
}
LL TernarySearch( LL l , LL r ) {
    LL lo = l , hi = r , midL , midR;
    LL ret = 2*INF;
    int iter = 200;
    while( iter-- ) {
        midL = ( 2*lo+hi )/3 , midR = ( lo+2*hi )/3;
        LL x = calc( midL ) , y = calc( midR );
        if( x < y ) hi = midR , ret = min( ret , x );
        else lo = midL;
    }
    return min( ret , min( calc(lo) , calc(hi) ) );
}
int main( int argc, char const *argv[] ) {
        fast_io;
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        cout << TernarySearch( -inf , inf ) << endl;
        return 0;
}








Measured memory_bytes: 1792
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    int n, m, l;
    long p;
    vector < vector<int> > a, b;
    std::cin >> n >> m >> l;
    a.resize(n);
    b.resize(m);
    for (int i=0; i<n; ++i){
        a[i].resize(m);
    }
    for (int i=0; i<m; ++i){
        b[i].resize(l);
    }
    // input matrix A
    for (int i=0; i<n; ++i){
        for (int j=0; j<m; ++j){
            std::cin >> a[i][j];
        }
    }
    // input matrix B
    for (int i=0; i<m; ++i){
        for (int j=0; j<l; ++j){
            std::cin >> b[i][j];
        }
    }
    
    for (int i=0; i<n; ++i){
        for (int j=0; j<l; ++j){
            p = 0;
            for (int k=0; k<m; ++k){
                p += a[i][k] * b[k][j];
            }
            if (j == l-1){
                std::cout << p << endl;
            }
            else {
                std::cout << p << " ";
            }
        }
    }
    return 0;
}



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

int main() {
	int a, b;
	cin >> a >> b;
	string ans = "Impossible";
	if(a%3 == 0) ans = "Possible";
	if(b%3 == 0) ans = "Possible";
	if((a+b)%3 == 0) ans = "Possible";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

	int n ;
	cin >> n;
	vector< int > A(30 , (1 << 22)) ;
	for(int i = 0 ;i < n ;i ++){
		string s; 
		cin >> s;
		vector< int > B(30);
		for(int l = 0 ;l < s.size() ;l ++)
			B[s[l] - 'a'] ++;
		for(int l = 0; l < 30 ;l ++)
			A[l] = min(A[l] , B[l]);
	}
	string res = "";
	for(int i = 0 ;i < 30 ;i ++){
	
		for(int k = 0 ; k < A[i] ; k ++)
			res += char(i + 'a');
	}
	cout << res << endl;
	
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	a := intSliceScanner(n)
	ans := make([][]int, 1, n)
	f := 0
	for i := 0; i < n; i++ {
		x := ans[len(ans)-1]
		if len(x) >= 2 {
			if x[len(x)-1] <= a[i] && f != 2 {
				ans[len(ans)-1] = append(ans[len(ans)-1], a[i])
				if x[len(x)-1] < a[i] {
					f = 1
				}
			} else if x[len(x)-1] >= a[i] && f != 1 {
				ans[len(ans)-1] = append(ans[len(ans)-1], a[i])
				if x[len(x)-1] > a[i] {
					f = 2
				}
			} else {
				ans = append(ans, []int{a[i]})
				f = 0
			}
		} else {
			ans[len(ans)-1] = append(ans[len(ans)-1], a[i])
			if len(ans[len(ans)-1]) == 2 {
				if ans[len(ans)-1][0] < ans[len(ans)-1][1] {
					f = 1
				} else if ans[len(ans)-1][0] > ans[len(ans)-1][1] {
					f = 2
				} else {
					f = 0
				}
			}
		}
	}
	fmt.Println(len(ans))
}


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

int n;
int a[105];
double sum;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=1.0/a[i];
	}
	cout<<fixed<<setprecision(10);
	cout<<1.0/sum;
	
	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 drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int divceil(int a, int b) {
    return (a+b-1)/b;
}

int main() {
	ll k, q;
	cin >> k >> q;
    vector<int> d(k);
    rep(i,k) cin >> d[i];
    rep(qi,q) {
        int n, x, m;
        cin >> n >> x >> m;
        ll last = x, eq = 0;
        rep(i,k) {
            ll num = divceil(n-1-i,k);
            last += (d[i]%m) * num;
            if (d[i]%m == 0) eq += num;
        }
        ll ans = (n-1) - (last/m - x/m) - eq;
        cout << ans << endl;
    }
	return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		final int N = Integer.parseInt(scan.nextLine());
		List<Integer> list = new ArrayList<Integer>(N);
		for (int i = 0; i < N; i++) {
			list.add(Integer.parseInt(scan.next()));
		}
		scan.close();

		Integer[] ordered = list.stream().sorted().toArray(Integer[]::new);

		if (ordered[N / 2] == ordered[(N / 2) - 1]) {
			System.out.println(0);
		} else {
			System.out.println(ordered[N / 2] - ordered[(N / 2) - 1]);
		}
	}

}

Measured memory_bytes: 49816
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int inf=1e9+9;
int ans=inf;
int32_t main(){
  BOOST;
  string s,t;
  cin>>s>>t;
  for (int i=0;i<sz(s);i++){
    int ile=0;
    if (i+sz(t)-1>=sz(s))break;
    for (int j=i;j<=i+sz(t)-1;j++){
      if (s[j]!=t[j-i])ile++;
    }
    ans=min(ans,ile);
    //cout<<"TERAZ "<<i<<" "<<ile<<"\n";
  }
  cout<<ans;
  return 0; 
}


Measured memory_bytes: 3616
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[2100];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	long long ret=0;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++){
			int now=p[i]+p[j];
			int r=lower_bound(p,p+a,now)-p;
			ret+=max(0,r-j-1);
		}
	}
	printf("%lld\n",ret);
}

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

int main() {
   int a, b, h;
   cin >> a >> b >> h;

   cout << (a + b) * h / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;


int N,M;
const int SIZE = 600005;
int c[SIZE];
int A[SIZE];
int Next[SIZE];
int res[600005];
int show[6000005];
bool fir[SIZE];


struct Q
{
    int l,r;
    int pos;
}q[600005];


int lowbit(int k)
{
    return k&(-k);
}


void modify(int n,int v)
{
    while(n <= N)
    {
        c[n] += v;
        n += lowbit(n);
    }
}


int sum(int n)
{
    int ans = 0;
    while(n > 0)
    {
        ans += c[n];
        n -= lowbit(n);
    }
    return ans;
}


int cmp(Q a, Q b)
{
    return a.l < b.l;
}


int main()
{
    scanf("%d",&N);
    scanf("%d",&M);
    for(int i=1;i<=N;i++) scanf("%d",&A[i]);

    for(int i=N;i>=1;i--)
    {
        if(!show[A[i]])
        {
            show[A[i]] = i;
            fir[i] = true;
        }
        else
        {
            Next[i] = show[A[i]];
            fir[Next[i]] = false;
            fir[i] = true;
            show[A[i]] = i;
        }
    }


    for(int i=1;i<=M;i++)
    {
        scanf("%d%d",&q[i].l,&q[i].r);
        q[i].pos = i;
    }
    sort(q+1,q+1+M,cmp);


    for(int i=1;i<=N;i++)
        if(fir[i])
        {
            modify(i,1);
        }
    int qtemp = q[1].l;
    int ptr = 1;
    for(int i=1;i<=M;i++)
    {
        for(;ptr<q[i].l;ptr++)
        {
            if(fir[ptr])
            {
                modify(ptr,-1);
                fir[ptr] = false;
                if(Next[ptr])
                {
                    fir[Next[ptr]] = true;
                    modify(Next[ptr],1);
                }
            }
        }
        ptr = q[i].l;
        qtemp = q[i].l;
        res[q[i].pos] = sum(q[i].r) - sum(q[i].l-1);
    }
    for(int i=1;i<=M;i++) printf("%d\n",res[i]);
    return 0;
}



Measured memory_bytes: 19344
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_A(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
    
}

void solve_B(){
    
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 256
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

int main() {
    fast_io();
    ll a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << "\n";
    return 0;
}


Measured memory_bytes: 256
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int N=15;
int n,x[N][N],y[N][N],a[N],S;
bool st(int p)
{
	return (S>>p)&1;
}
bool check()
{
	for(int i=0;i<n;++i)
		if(st(i))
		{
			for(int j=0;j<a[i];++j)
				if(y[i][j]!=st(x[i][j]))
					return false;
		}
	return true;
}
int main()
{
	n=read();
	for(int i=0;i<n;++i)
	{
		a[i]=read();
		for(int j=0;j<a[i];++j)
		{
			x[i][j]=read()-1;
			y[i][j]=read();
		}
	}
	int ans=0;
	for(S=0;S<(1<<n);++S)
		if(check())
			ans=max(ans,__builtin_popcount(S));
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  ll a,b;
  cin >> a >> b;

  ll ans=0;
  for (ll i=0; i<50 ; i++) {
    if (a==0) {
      ans=b;
      break;
    }
    ll x=1ll<<i;
    ll cnt_a=(((a-1)+1)/(x*2))*x+max(0ll,((a-1)+1)%(x*2)-x);
    ll cnt_b=((b+1)/(x*2))*x+max(0ll,(b+1)%(x*2)-x);
    ans+=(((cnt_b-cnt_a)%2)<<i);
  }
  
  cout << ans << endl;
  return 0;
}

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

int main() {
 int N,K;
 cin >> N >> K;
 vector<int> A(N);
 map<int,int> p;
 for(int i = 0; i < N; i++) {
    cin >> A[i];
    p[A[i]] += 1;
 }
   vector<int> num;
 for(auto i : p) {
    num.push_back(i.second);
 }
   sort(num.begin(),num.end());
   reverse(num.begin(),num.end());
   int sum = 0;
   int shurui = 0;
   for(auto it : num) {
      if(shurui < K) { sum += num.front(); shurui++; num.erase(num.begin()); }
   }

   cout << N - sum;
 return 0;

}

Measured memory_bytes: 11516
n, l = map(int, input().split())

k = l + n - 1

sum_pp = l * n + n * (n - 1) / 2
sum_p = int(sum_pp)

if l >= 0:
    ans = sum_p - l
elif k<= 0:
    ans = sum_p - k
else:
    ans = sum_p

print(ans)


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int A,B,i,result=0;
  scanf("%d",&A);
  scanf("%d",&B);
  for(i=0;i<2;i++){
    if(A > B){
      result += A;
      A--;
    }else{
      result += B;
      B--;
    }
  }
  printf("%d\n",result);
  return 0;
}

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

#define ld long double
#define ll long long
#define ull unsigned long long

#define f first
#define s second

#define endl '\n'
#define pii pair <ll, ll>

#define ios ios_base::sync_with_stdio(0), cin.tie()
#define pb push_back
#define mp make_pair

#define pi 3.14159265358979323846264
#define y1 abacaba
 
#define fn "abc"

using namespace std;

const int MXN = 1e5 + 30;
const int MAXN = 1e3 + 2;
const ll INF = 1e9 + 7;
const ll BINF = 1e18;
const int mod = 1e9 + 7;
const ld EPS = 1e-15;   
const ll dx[] = {0, 0, 1, -1};
const ll dy[] = {1, -1, 0, 0};

int n;
ll x, y;
ll a[MXN];

ll last[MXN][2];

ll pre[MXN][2];

ll dp[MXN][2];

int main(){
    #ifdef DIAS
        freopen("input.txt", "r", stdin);
    #elif NAME 
    	freopen(fn".in", "r", stdin);
    	freopen(fn".out", "w", stdout);
    #endif
    cin >> n >> x >> y;
    a[0] = -BINF;
    pre[0][0] = -1;
    pre[0][1] = -1;
    for(int i = 1; i <= n; i++){
    	cin >> a[i];
    	if(a[i] - a[i - 1] >= x) last[i][0] = last[i - 1][0];
    	else last[i][0] = i;

    	if(a[i] - a[i - 1] >= y) last[i][1] = last[i - 1][1];
    	else last[i][1] = i;

    	pre[i][0] = pre[i - 1][0];
    	while(a[i] - a[pre[i][0] + 1] >= x && pre[i][0] +  1 < i) pre[i][0] ++; 

    	pre[i][1] = pre[i - 1][1];
    	while(a[i] - a[pre[i][1] + 1] >= y && pre[i][1] + 1 < i) pre[i][1] ++;  

    }
    dp[0][1] = 1;
    for(int i = 1; i <= n; i++){
    	if(a[i] - a[i - 1] >= x){
    		dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
    	} else{
    		if(last[i - 1][1] <= pre[i][0] + 1){
    			dp[i][0] = dp[pre[i][0] + 1][1];
    		} else{
    			dp[i][0] = 0;
    		}
    	}
    	
    	if(a[i] - a[i - 1] >= y){
    		dp[i][1] = (dp[i - 1][1] + dp[i - 1][0]) % mod;
    	} else{         	
    		if(last[i - 1][0] <= pre[i][1] + 1){
    			dp[i][1] = dp[pre[i][1] + 1][0];
    		} else{
    			dp[i][1] = 0;
    		}
    	}

    	//cout << dp[i][0] << ' ' << dp[i][1] << endl;
    }
    cout << (dp[n][0] + dp[n][1]) % mod;
    return 0;                     
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ll gcd(ll a, ll b)
{
	if(a==0) return b;
	if(b==0) return a;
	if(a==b) return a;
	if(a>b) swap(a,b);
	return gcd(a,b%a);
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ll ans=1;
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x;
		ans=(ans/gcd(ans,x))*x;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int N, K; cin >> N >> K;
    ll a[N]; rep(i,N) cin >> a[i];

    for (int i = K; i < N; ++ i) {
        if (a[i-K] < a[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    
    


    return 0;
}



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

signed main() {
  int N;
  cin >> N;
  
  vector<int> kazu(5, 0);
  // 0=M,1=A,2=R,3=C,4=H
  string S;
  for( int i = 0; i < N; i++ ){
    cin >> S;
    if( S.at(0) == 'M' ) kazu.at(0)++;
    else if( S.at(0) == 'A' ) kazu.at(1)++;
    else if( S.at(0) == 'R' ) kazu.at(2)++;
    else if( S.at(0) == 'C' ) kazu.at(3)++;
    else if( S.at(0) == 'H' ) kazu.at(4)++;
  }
  
  int ans = 0;
  for( int i = 0; i < 5; i++ ){
    for( int j = i+1; j < 5; j++ ){
      for( int k = j+1; k < 5; k++ ){
        ans += kazu.at(i)*kazu.at(j)*kazu.at(k);
      }
    }
  }
  cout << ans << endl;
  
  
}


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

void solve(string S, string T)
{
    int res = 0;
    for (int i = 0; i < (int)S.size(); i++)
    {
        if (S.at(i) == T.at(i))
            res++;
    }
    cout << res << endl;
}

int main()
{
    string S;
    cin >> S;
    string T;
    cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int INF=1000010000;
typedef long long ll;
const int mod=1000000007;
int main() {
  int h,w;cin >> h >> w;
  vector<vector<char>> grid(h,vector<char>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> grid[i][j];
    }
  }
  vector<vector<ll>> dp(h+1,vector<ll>(w+1,0));
  dp[0][0]=1;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(i+1<h&&grid[i+1][j]=='.'){
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]%=mod;
      }
      if(j+1<w&&grid[i][j+1]=='.'){
        dp[i][j+1]+=dp[i][j];
        dp[i][j+1]%=mod;
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int MAX  = 1e7 + 5;
long long int f[MAX]={0};
int main() {

    jaldi

    int n;
    cin>>n;

    for(int i=1;i<MAX;i++) {
        for(int j=i;j<MAX;j+=i){
            f[j]++;
        }
    }
    long long int ans =0;
    for(int i=1;i<n;i++) {
        ans+=f[i];
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 81728
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

const long long int INF=0x7fffffffffffffff;
#define NINF 0xc0c0c0c0

using namespace std;

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 1000

void _solver(int x, int y, int *base, int baseSize) {
	int i,j;
	int dx[4] = {0, 1, 0, -1};
	int dy[4] = {1, 0, -1, 0};
	
	char pos[4] = {'U', 'R', 'D', 'L'};

	int posIndex = 0;
	long long int xx = x, yy = y;
	long long int xTmp, yTmp;
	long long int sumTmp;
	long long int sumMin = INF;

	FOR(i, 0, baseSize) {
		sumMin = INF;
		FOR(j, 0, 4) {
			xTmp = xx - dx[j]*base[i];
			yTmp = yy - dy[j]*base[i];
			sumTmp = abs(xTmp) + abs(yTmp);

			//printf("== i %d j %d xTmp %lld yTmp %lld sumTmp %lld\n", i, j, xTmp, yTmp, sumTmp);
			if (sumTmp<=sumMin) {
				sumMin = sumTmp;
				posIndex = j;
			}
		}

		xx -= dx[posIndex]*base[i];
		yy -= dy[posIndex]*base[i];

		printf("%c", pos[posIndex]);
	}

	printf("\n");
	return;
}

void solver(int *xNums, int *yNums, int numsSize) {
	int i;
	int base[32];
	base[31] = 1;
	base[30] = 1;

	// check x,y parity
	int parity = (xNums[0]^yNums[0])&1;

	FOR(i, 1, numsSize) {
		if (((xNums[i]^yNums[i])&1) != parity) {
			printf("-1\n");
			return;
		}
	}

	// set robot arm's sections
	EFOR(i, 29, -1) {
		base[i] = base[i+1]<<1;
	}

	int baseSize = (parity == 1)?31:32;

	// print baseSize
	printf("%d\n", baseSize);

	printf("%d", base[0]);
	FOR(i, 1, baseSize) {
		printf(" %d", base[i]);
	}
	printf("\n");

	FOR(i, 0, numsSize) {
		_solver(xNums[i], yNums[i], base, baseSize);
	}
	return;
}

int main() {
	int i,n;
	int x[MAXN] = {0};
	int y[MAXN] = {0};

	scanf("%d", &n);

	FOR(i, 0, n) {
		scanf("%d %d", &x[i], &y[i]);
	}

	solver(x, y, n);
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = 10 ** 9 + 7
cnt = [0] * (k + 1)

for i in range(k, 0, -1):
    cnt[i] = pow((k // i), n, p)
    for j in range(i * 2, k + 1, i):
        cnt[i] -= cnt[j]

print(sum((i * cnt[i] for i in range(1, k + 1))) % p)


Measured memory_bytes: 11224
N = int(input())
As = list(map(int,input().split()))
X0 = sum(As) - 2 * (sum([As[j] for j in range(1,N-1,2)]))
Xs =[X0]
for i in range(1,N):
    Xs.append(2 * As[i-1]-Xs[i-1])
print(' '.join(list(map(str,Xs))))

Measured memory_bytes: 19096
n = gets.to_i
names = Hash.new(0)
n.times do
  c = gets[0]
  names[c] += 1 if ['M', 'A', 'R', 'C', 'H'].include?(c)
end
ans = 0
names.values.combination(3).each do |s|
  ans += s.inject(:*)
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    string s1,s2,s3; cin>>s1>>s2>>s3;
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int H, W;

    while (1)
    {
        cin >> H >> W;

        if (H == 0 && W == 0)
            break;

        rep(i, H)
        {
            rep(j, W)
            {
                if ((i + j) % 2 == 0)
                {
                    cout << "#";
                }
                else
                {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3112
n = input()
str_n = list(n)

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

Measured memory_bytes: 61888
#include <stdio.h>

	int main() {
		long long a, flag = 0;
		long long last = 1;
		
		scanf("%lld", &a);
		long long arr[a] = {};
		
		for(int i = 0; i < a; i++) {
			
			scanf("%lld", &arr[i]);
			
		}
		
		for(int i = 0; i < a; i++) {
			if(arr[i] == 0) {
				printf("0\n");
				
				return 0;
			}
		}

		for(int i = 0; i < a; i++) {
				
			if(arr[i] <= 1000000000000000000/last) {
				last =  last * arr[i];
			}
			
			else {
				
				printf("-1\n");
				return 0;
			}
		
	}
	printf("%lld", last);
	return 0;
}



Measured memory_bytes: 2500
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()

const int N = 1e5 + 5;
int arr[N];
int DP[N];

int solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	for(int i = n - 1; i >= 0; i--)
	{
		if(i == n - 1)
		{
			DP[i] = 0;
		}
		else if(arr[i] >= arr[i + 1])
		{
			DP[i] = DP[i + 1] + 1;
		}
	}
	cout << *max_element(DP, DP + n);
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}          

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

int main() {
    // 入力
    int n, m; cin >> n >> m;
    vector<int> P(m), Y(m);
    for (int i = 0; i < m; ++i) cin >> P[i] >> Y[i], --P[i];
    
    // vals[v] := P[i] = v であるような i についての Y[i] の値を集めたもの
    vector<vector<int> > vals(n);
    for (int i = 0; i < m; ++i) vals[P[i]].push_back(Y[i]);
    
    // 各 p の値に対して
    for (int v = 0; v < n; ++v) {
        sort(vals[v].begin(), vals[v].end());
        
        // 今回は不要だが、通常は数のダブりをなくす
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    // 答え
    for (int i = 0; i < m; ++i) {
        int v = P[i];
        printf("%06d", v + 1);
        
        // 座標圧縮して導いた答え
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
}

Measured memory_bytes: 9540