akhauriyash/Code-Regression huggingface dataset:
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 14
 * 
 */

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    ivv(a);
    ivv(b);
    ivv(c);
    a-=b;
    cout<<max(0 , c-a)<<endl;
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(int argc, char const *argv[])
{
    int a, b, c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if (a-b < c){
        printf("%d\n", c - (a-b));
    }
    else{
        printf("%d\n", 0);
    }


    
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,a[N][5],dp[N][5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&a[i][1],&a[i][2],&a[i][3]);
	dp[1][1]=a[1][1],dp[1][2]=a[1][2],dp[1][3]=a[1][3];
	for(int i=2;i<=n;i++)
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i][1],dp[i][2]=max(dp[i-1][1],dp[i-1][3])+a[i][2],dp[i][3]=max(dp[i-1][1],dp[i-1][2])+a[i][3];
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
	return 0;
}

Measured memory_bytes: 4224
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  n <- readLn :: IO Int
  ss <- fmap (map read . words) getLine :: IO [Int]
  let ans = solve ss
  if isNothing ans
    then putStrLn "-1"
    else putStr . unlines . map show $ fromJust ans

solve = go [] 
  where
    go as [] = Just as
    go as ss 
      | null v = Nothing
      | otherwise = go (s:as) $ unins s ss 
      where
        v = vanishable ss
        s = last v

vanishable :: [Int] -> [Int] 
vanishable ss = map fst . filter (\(i, j) -> i == j) $ zip ss [1..]

ins :: Int -> [Int] -> [Int]
ins a as = let (l, r) = splitAt (a - 1) as
           in l ++ [a] ++ r
unins :: Int -> [Int] -> [Int]
unins a as = let (l, r) = splitAt a as
             in (init l) ++ r


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

using namespace std;

typedef long long int 	ll;
typedef pair<int,int>   ii;
typedef vector< ii >   vii;
typedef vector<int>     vi;
typedef vector< vi >   vvi;

#define mm 100005
#define nn 1005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define cases int t;  cin>>t;   while(t--)
#define check(a,n) forn(iiii,int(n)) cout<<int(a[iiii])<<" "; cout<<endl
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll a[2*mm],ans=1e18;

int main()
{
    int n;
    cin>>n;
    forn(i,n)
        cin>>a[i+1],a[i+1]+=a[i];
    forn(i,n-1)
        ans=min(ans,abs(2LL*a[i+1]-a[n]));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> B(N - 1);
    rep(i, N - 1) cin >> B[i];

    ll res = B[0] + B.back();
    for (int i = 0; i + 1 < B.size(); i++) {
        res += min(B[i], B[i + 1]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
#define sz(x) int(x.size())
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

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

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> F(N);
    repeat(i, N) cin >> A[i];
    repeat(i, N) cin >> F[i];
    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    auto f = [&](long long mid) -> bool {
        long long x = 0;
        repeat(i, N) {
            if ((long long)A[i] * F[i] > mid) {
                long long y = ((long long)A[i] * F[i] - mid + F[i] - 1) / F[i];
                x += y;
            }
        }
        return x <= K;
    };

    long long ng = -1, ok = 1e12 + 1000;
    while (abs(ok - ng) > 1) {
        long long mid = ng + (ok - ng) / 2;
        if (f(mid))
            ok = mid;
        else
            ng = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 4820
a,b,c=map(int, input().split(" "))
ans=0
if (max(a,b,c)*3-a-b-c)%2==0:
    ans=int((max(a,b,c)*3-a-b-c)/2)
else:
    ans = ((max(a, b, c) * 3 - a - b - c) // 2)+2
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    string s; cin>>s;
    deque<char> que;
    int Bcount=0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='B')Bcount++;
        else{
            if(Bcount>0){
                Bcount--;
                continue;
            }
            que.push_front(s[i]);
        }
    }
    /*
    for(auto itr=que.begin();itr<=que.end();itr++){
        cout<<*itr;
    }
     */
    for(auto it:que){
        cout<<it;
    }
    cout<<endl;
    return 0;

}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(x[n-1])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    set<char> se;
    rep(i, S.size()) { se.insert(S[i]); }
    if(S == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }
    if(S.size() == 26) {
        for(int i = S.size() - 1; i >= 0; i--) {
            for(int j = S[i] - 'a' + 1; j < 26; j++) {
                int flag = 0;
                for(int k = 0; k < i; k++) {
                    if(S[k] == (char)('a' + j))
                        flag = 1;
                }
                if(flag == 0) {
                    cout << S.substr(0, i) + (char)('a' + j) << endl;
                    return 0;
                }
            }
        }
    } else {
        for(int i = 0; i < 26; i++) {
            if(!se.count((char)('a' + i))) {
                cout << S << (char)('a' + i) << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll h, k = 1,sum = 0;
  cin >> h;
  while (h != 1) {
    h = h / 2;
    sum += k;
    k = k * 2;
  }
  sum += k;
  cout << sum;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	void rect(){
		int a,b;
		Scanner s1 = new Scanner(System.in);
		a = s1.nextInt();
		b = s1.nextInt();
		System.out.println(a*b + " " + (2*a+2*b));
	}
	public static void main(String args[]){
		Main m1 = new Main();
		m1.rect();
	}
}

Measured memory_bytes: 26112
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<pii, int> piipi;
int x[100002], y[100002], X[100002], Y[100002], d;
bool vis[100002];
set<piipi> set1, set2;
vector<piipi> v1, v2;
vector<piipi> v;
void dfs(int u){
    vis[u] = 1;
    set1.erase(set1.find(piipi(pii(X[u], Y[u]), u)));
    set2.erase(set2.find(piipi(pii(Y[u], X[u]), u)));
    set<piipi>::iterator its;
    int x1 = X[u]-d, x2 = X[u]+d, y1 = Y[u]-d, y2 = Y[u]+d;
    while(1){
        its = set1.lower_bound(piipi(pii(x1, y1), 0));
        if(its != set1.end() && (its->first.first == x1 && its->first.second <= y2)) dfs(its->second);
        else break;
    }
    while(1){
        its = set1.lower_bound(piipi(pii(x2, y1), 0));
        if(its != set1.end() && (its->first.first == x2 && its->first.second <= y2)) dfs(its->second);
        else break;
    }

    while(1){
        its = set2.lower_bound(piipi(pii(y1, x1), 0));
        if(its != set2.end() && (its->first.first == y1 && its->first.second <= x2)) dfs(its->second);
        else break;
    }
    while(1){
        its = set2.lower_bound(piipi(pii(y2, x1), 0));
        if(its != set2.end() && (its->first.first == y2 && its->first.second <= x2)) dfs(its->second);
        else break;
    }
}
int main(){
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    for(int i=1;i<=n;i++){
        scanf("%d%d", &x[i], &y[i]);
        X[i] = x[i]-y[i];
        Y[i] = x[i]+y[i];
    }
    d = abs(x[a]-x[b]) + abs(y[a]-y[b]);
    for(int i=1;i<=n;i++){
        set1.insert(piipi(pii(X[i], Y[i]), i));
        set2.insert(piipi(pii(Y[i], X[i]), i));
    }
    dfs(a);
    for(int i=1;i<=n;i++){
        if(vis[i]){
            v1.emplace_back(piipi(pii(X[i], Y[i]), i));
            v2.emplace_back(piipi(pii(Y[i], X[i]), i));
        }
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    LL ans = 0;
    for(int i=1;i<=n;i++){
        if(vis[i]){
            int x1 = X[i]-d, x2 = X[i]+d, y1 = Y[i]-d, y2 = Y[i]+d;
            ans += (upper_bound(v1.begin(), v1.end(), piipi(pii(x1, y2), 1e9)) - v1.begin() - 1) - (lower_bound(v1.begin(), v1.end(), piipi(pii(x1, y1), 0)) - v1.begin()) + 1;
            ans += (upper_bound(v1.begin(), v1.end(), piipi(pii(x2, y2), 1e9)) - v1.begin() - 1) - (lower_bound(v1.begin(), v1.end(), piipi(pii(x2, y1), 0)) - v1.begin()) + 1;
            ans += (upper_bound(v2.begin(), v2.end(), piipi(pii(y1, x2-1), 1e9)) - v2.begin() - 1) - (lower_bound(v2.begin(), v2.end(), piipi(pii(y1, x1+1), 0)) - v2.begin()) + 1;
            ans += (upper_bound(v2.begin(), v2.end(), piipi(pii(y2, x2-1), 1e9)) - v2.begin() - 1) - (lower_bound(v2.begin(), v2.end(), piipi(pii(y2, x1+1), 0)) - v2.begin()) + 1;
        }
    }
    printf("%lld\n", ans/2);
}

Measured memory_bytes: 20992
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
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;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  
  ll N = input();
  ll K = input();
  vector<ll> H;
 
  for(ll i=0;i<N;i++){
    H.push_back(input());
  }
 
  sort(H.begin(), H.end());

  ll sum = 0;
  for(ll i=H.size()-1;i>=0;i--){
    if(H.size()-i>K){
      sum += H[i];
    }
  }
 
  output(sum);
  
  return 0;
}

Measured memory_bytes: 2420
N, M = map(int,input().split())
a = [int(input()) for i in range(M)]
ans=[1]
mod = 10**9+7
broken=[1]*N

for i in range(M):
    broken[a[i]-1]=0

for i in range(N):
    if i == 0:
        ans.append(broken[0])
    else:
        ans.append(ans[i] * broken[i-1] + ans[i-1] * broken[i-2])
        
print((ans[N]) % mod)

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  string S_rev = S, S_begin, S_begin_rev, S_end, S_end_rev;
  S_begin = S.substr(0,(N-1)/2);
  S_begin_rev = S_begin;
  S_end = S.substr((N+3)/2-1,N-1);
  S_end_rev = S_end;
  reverse(S_rev.begin(), S_rev.end());
  reverse(S_begin_rev.begin(), S_begin_rev.end());
  reverse(S_end_rev.begin(), S_end_rev.end());

  if (S == S_rev & S_begin == S_begin_rev & S_end == S_end_rev)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;

int main(void){
  int n;
  while ((cin >> n) && n) {
    vector<char> c(n);
    VI t(26, 0);
    REP(i, 0, n) {
      cin >> c[i];
      t[c[i] - 'A']++;
    }
    int dec = -1;
    char winner = 0;
    int ma = 0;
    REP(i, 0, 26) {
      ma = max(ma, t[i]);
    }
    REP(i, 0, 26) {
      if (t[i] == ma) {
	winner = winner ? '!' : 'A' + i;
      }
    }
    if (winner == '!') { winner = 0; }
    if (winner == 0) {
      cout << "TIE" << endl;
      continue;
    }
    fill(t.begin(), t.end(), 0);
    REP(i, 0, n) {
      if (dec >= 0) {
	break;
      }
      t[c[i] - 'A']++;
      int rest = n - i - 1;
      int sec = 0;
      REP(j, 0, 26) {
	if ('A' + j != winner) {
	  sec = max(sec, t[j]);
	}
      }
      if (sec + rest < t[winner - 'A']) {
	dec = i;
      }
    }
    cout << winner << " " << dec + 1 << endl;
  }
}

Measured memory_bytes: 3080
#include <stdio.h>

typedef enum {
	RIGHT,
	DOWN,
	LEFT,
	UP,
	UNDEFINED
} Direction;

void make_destination(
		int wx[5][4], int wy[4][5], Direction data[5][5][4]) {
	int *x1, *y1, *y0, i, j;
	Direction *d;

	x1 = wx[0];
	y1 = wy[0];

	d = data[0][0];
	d[0] = x1[0] ? RIGHT : UNDEFINED;
	d[1] = y1[0] ? DOWN : UNDEFINED;
	d[2] = d[3] = UNDEFINED;
	for (i = 0; i < 3; i++) {
		d = data[0][i+1];
		d[0] = x1[i+1] ? RIGHT : UNDEFINED;
		d[1] = y1[i+1] ? DOWN : UNDEFINED;
		d[2] = x1[i] ? LEFT : UNDEFINED;
		d[3] = UNDEFINED;
	}
	d = data[0][4];
	d[0] = d[3] = UNDEFINED;
	d[1] = y1[4] ? DOWN : UNDEFINED;
	d[2] = x1[3] ? LEFT : UNDEFINED;

	for (j = 1; j < 4; j++) {
		y0 = y1;
		x1 = wx[j];
		y1 = wy[j];

		d = data[j][0];
		d[0] = x1[0] ? RIGHT : UNDEFINED;
		d[1] = y1[0] ? DOWN : UNDEFINED;
		d[2] = UNDEFINED;
		d[3] = y0[0] ? UP : UNDEFINED;
		for (i = 0; i < 3; i++) {
			d = data[j][i+1];
			d[0] = x1[i+1] ? RIGHT : UNDEFINED;
			d[1] = y1[i+1] ? DOWN : UNDEFINED;
			d[2] = x1[i] ? 2: UNDEFINED;
			d[3] = y0[i+1] ? UP : UNDEFINED;
		}
		d = data[j][4];
		d[0] = UNDEFINED;
		d[1] = y1[4] ? DOWN : UNDEFINED;
		d[2] = x1[3] ? LEFT : UNDEFINED;
		d[3] = y0[4] ? UP : UNDEFINED;
	}

	y0 = y1;
	x1 = wx[4];

	d = data[4][0];
	d[0] = x1[0] ? RIGHT : UNDEFINED;
	d[1] = d[2] = UNDEFINED;
	d[3] = y0[0] ? UP : UNDEFINED;
	for (i = 0; i < 3; i++) {
		d = data[4][i+1];
		d[0] = x1[i+1] ? RIGHT : UNDEFINED;
		d[1] = UNDEFINED;
		d[2] = x1[i] ? LEFT : UNDEFINED;
		d[3] = y0[i+1] ? UP : UNDEFINED;
	}
	d = data[4][4];
	d[0] = d[1] = UNDEFINED;
	d[2] = x1[3] ? LEFT : UNDEFINED;
	d[3] = y0[4] ? UP : UNDEFINED;
}

void walk(Direction data[5][5][4]) {
	int i, x = 1, y = 0;
	Direction *ways, move = RIGHT;

	int destination[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
	int *dest;

	Direction permutation[4][4] = {
		{UP, RIGHT, DOWN, LEFT}, {RIGHT, DOWN, LEFT, UP},
		{DOWN, LEFT, UP, RIGHT}, {LEFT, UP, RIGHT, DOWN}
	};
	Direction *per;

	putchar('R');

	while (x != 0 || y != 0) {
		ways = data[y][x];
		per = permutation[move];

		for (i = 0; i < 4; i++) {
			move = ways[per[i]];
			if (move == UNDEFINED)
				continue;
			dest = destination[move];
			break;
		}
		x += dest[0];
		y += dest[1];
		putchar("RDLU"[move]);
	}
	putchar('\n');
}

int main(void) {
	char in[10];
	int i, j, wx[5][4], wy[4][5];
	Direction data[5][5][4];

	for (j = 0; j < 4; j++) {
		scanf("%s ", in);
		for (i = 0; i < 4; i++) {
			wx[j][i] = in[i] - '0';
		}
		scanf("%s ", in);
		for (i = 0; i < 5; i++) {
			wy[j][i] = in[i] - '0';
		}
	}
	scanf("%s ", in);
	for (i = 0; i < 4; i++) {
		wx[4][i] = in[i] - '0';
	}

	make_destination(wx, wy, data);
	walk(data);
	return 0;
}

Measured memory_bytes: 524
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  n: usize,
  mut a: [i64; n],
  }

  let mut cnt = 0;
  for i in 0..n {
    if (i + 1) % 2 == 1 && a[i] % 2 == 1 {
      cnt += 1;
    }
  }

  println!("{}", cnt);
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.resize(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(A + B, max(A - B, A * B)) << endl;
}


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    ll n = s.size();
    vector<ll> h;
    h.push_back(0); //h stores cumulative sum assuming 0s and ?s are -1
    for(auto c:s)
        h.push_back(h.back() + (c=='1'?1:-1));
    vector<ll> z = h;
    for(ll i=n-1;i>=0;i--)
        z[i] = max(z[i],z[i+1]);
    
    ll mx = -1;
    for(ll i=0;i<=n;i++)
        mx = max(mx,h[i]);
    ll ans = INT64_MAX;
    for(ll random_variable=0;random_variable<2;random_variable++){
        ll cur = 0,mn = 0;
        for(ll i=0;i<n;i++){
            if(s[i] == '?'){
                if(cur + z[i+1] - h[i] +2 <=mx)
                    cur++;
                else
                    cur--;
            }
            else if(s[i] == '0')
                cur--;
            else 
                cur++;
            mn = min(mn,cur);
        }
        ans = min(ans,mx-mn);
        mx++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 20316
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <set>

using namespace std;

using ll = long long;

int main() {
    ll a, b;
    cin >> a >> b;
    for (ll i = (b-a+1); i <= (b+a-1); ++i) {
	if (i > (b-a+1)) {
	    cout << " ";
	}
	cout << i;
    }
    cout << "\n";
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int dp[2][110];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    rep(y, 2) rep(x, N) cin >> A[y][x];
    dp[0][0] = A[0][0];
    rep(y, 2) rep(x, N) {
        if (x) chmax(dp[y][x], dp[y][x-1] + A[y][x]);
        if (y) chmax(dp[y][x], dp[y-1][x] + A[y][x]);
    }
    cout << dp[1][N-1] << endl;
    return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    int m=n-1;
    Vi used(n,0),a(m),b(m),p(q),x(q),coin(n,0),ans(n,0);
    VVi connect(n);
    REP(i,0,m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        connect[a[i]].pb(b[i]);
        connect[b[i]].pb(a[i]);
    }
    REP(i,0,q){
        cin>>p[i]>>x[i];
        p[i]--;
        coin[p[i]]+=x[i];
    }
    
    queue<Tiii> qu;
    qu.push(mt(0,-1,0));
    while(!qu.empty()){
        int now,past,dnow;
        tie(now,past,dnow)=qu.front();
        qu.pop();
        dnow+=coin[now];
        ans[now]=dnow;
        REP(i,0,connect[now].size()) if(connect[now][i]!=past) qu.push(mt(connect[now][i],now,dnow));
    }
    REP(i,0,n) cout<<ans[i]<<" ";
    cout<<endl;
    
}


Measured memory_bytes: 30576
// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)
#define Bug(num) cout<<"here "<<num<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll maxn=110;
const ll mod=1e9+7;
const ll inf=4e18;

pair<ll,bool>mp[maxn];
set<ll>rd;

int main(){
	ll n;cin>>n;
	REP(i,n){
		ll x,y;cin>>x>>y;
		mp[y]=MP(x,0);
	}
	REP(i,n){
		ll x,y;cin>>x>>y;
		mp[y]=MP(x,1);
	}
	ll ans=0;
	REP(i,(2*n)){
		if(mp[i].S==0){// red
			rd.insert(mp[i].F);
		}
		else{// blue
			set<ll>::iterator it=rd.upper_bound(mp[i].F);
			if(it==rd.end()){
				if(sz(rd)){
					ans++;
					rd.erase(--it);
				}
			}
			else{
				if(it!=rd.begin()){
					ans++;
					rd.erase(--it);
				}
			}
		}
	}
	cout<<ans;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    double a[n];
    double sum = 0;
    for(i=0;i<n;i++){
        cin >> a[i];
        a[i] = 1.0/a[i];
        sum += a[i];
    }
    printf("%.8f\n",1.0/sum);
    return 0;
}

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

const ll INF = 1e18;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  int si, sj, ti, tj;
  cin >> si >> sj >> ti >> tj;
  --si; --sj; --ti; --tj;
  vector<string> g(h);
  rep(i,h) cin >> g[i];

  auto toId = [&](int i, int j, int v) {
    return (i*w+j)*4+v;
  };
  auto modCeilK = [&](ll x) {
    return (x+k-1)/k*k;
  };

  vector<ll> dist(h*w*4, INF);
  priority_queue<LP, vector<LP>, greater<LP>> q;
  auto push = [&](int i, int j, int v, ll x) {
    int id = toId(i,j,v);
    if (dist[id] <= x) return;
    dist[id] = x;
    q.emplace(x,id);
  };
  rep(v,4) push(si, sj, v, 0);
  while (!q.empty()) {
    ll d = q.top().first;
    int id = q.top().second;
    q.pop();
    if (dist[id] != d) continue;
    int i = id/w/4;
    int j = id/4%w;
    int v = id%4;
    rep(nv,4) push(i,j,nv,modCeilK(d));
    {
      int ni = i+di[v], nj = j+dj[v];
      if (0 <= ni && ni < h && 0 <= nj && nj < w) {
        if (g[ni][nj] == '.') {
          push(ni,nj,v,d+1);
        }
      }
    }
  }

  ll ans = INF;
  rep(v,4) ans = min(ans, dist[toId(ti,tj,v)]);
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    ans = modCeilK(ans)/k;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 44112
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

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

  int maxK = (N-1) * (N-2)/2;
  if(K > maxK){
    cout << -1 << endl;
    return 0;
  }

  int dK = maxK - K;
  int M = N-1 + dK;
  cout << M << endl;
  for(int i = 0; i < N-1; i++){
    cout << "1 " << i+2 << endl;
  }
  int sN = 2;
  int eN = 3;
  while(dK > 0){
    cout << sN << " " << eN << endl;
    eN+=1;
    if(eN==N+1){
      sN += 1;
      eN = sN+1;
    }
    dK-=1;
  }

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
#include<stack>
typedef long long LL;
using namespace std;
const int Maxn = 1e2+10;
const int Inf = 1e9 + 7;
int N;
int A[Maxn];
int main()
{
	while( cin >> N ){
		int ans = 0;
		for( int i = 1 ; i <= N ; i++ ){
			cin >> A[i];
		}
		for( int i = 1 ; i <= N ; i++ ){
			if( A[i] == A[i-1] ){
				ans++;
				A[i] = 10001;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;


int main() {
  ll L;
  cin >> L;
  ll R;
  cin >> R;
  ll d;
  cin >> d;
  int ans{};
  for (int i = L; i <= R; ++i) {
    if (i%d==0) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, y;
  cin >> n >> y;
  rep(i, n + 1) rep(j, n + 1) {
    ll k = n - i - j;
    if(k < 0) continue;
    if(10000 * i + 5000 * j + 1000 * k != y) continue;
    cout << i << ' ' << j << ' ' << k << endl;
    return 0;
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

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

int main(){
  long int a,b; cin >> a >> b;
  int r;
  if(a>0){
    r = 1;
  }else if(a==0 || b==0){
    r = 0;
  }else if(a<0){
    if(b>0){r = 0;}
    else{
      int temp = b-a+1;
      if( temp%2==0 ){r=1;}
      else{r = -1;}
    }
  }
  switch(r){
    case 1:
      cout << "Positive\n";
      break;
    case -1:
      cout << "Negative\n";
      break;
    case 0:
      cout << "Zero\n";
      break;
  }
}
  

Measured memory_bytes: 256
/*
    By Prabal Aggarwal
*/
#include <bits/stdc++.h>
#define fastIo                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
using namespace std;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define ll long long
#define MOD 1000000007
const int N = 1000005;
ll dp[N][2][2];
int main()
{
    fastIo;

    ll n;
    cin >> n;

    dp[1][0][0] = 8;
    dp[1][0][1] = 1;
    dp[1][1][0] = 1;
    dp[1][1][1] = 0;

    for (ll i = 2; i <= n; i++)
    {

        dp[i][0][0] = (8 * dp[i - 1][0][0]) % MOD;
        dp[i][1][0] = (dp[i - 1][0][0] + (9 * dp[i - 1][1][0]) % MOD) % MOD;

        dp[i][0][1] = (dp[i - 1][0][0] + (9 * dp[i - 1][0][1]) % MOD) % MOD;
        dp[i][1][1] = ((dp[i - 1][1][0] + dp[i - 1][0][1]) % MOD + (10 * dp[i - 1][1][1]) % MOD) % MOD;
       // trace(i, dp[n][1][1]);
    }

    cout << dp[n][1][1] << endl;

    return 0;
}

Measured memory_bytes: 34856
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

if a<40:
    a=40
if b<40:
    b=40
if c<40:
    c=40
if d<40:
    d=40
if e<40:
    e=40

f=a+b+c+d+e
g=int(f/5)

print(g)



Measured memory_bytes: 5592
#include <stdio.h>
 
int main(void){
	char str[1000];
	int digit,check_times,check_digit,check_num;
	int x = 0;
	int y = 0;
	int z = 0;
	int ans = 0;
	int x_count = 0;
	
	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d %d",&digit,&check_times);
	
	for(int i = 0; i < check_times; i++){
		fgets(str,sizeof(str),stdin);
		sscanf(str,"%d %d",&check_digit,&check_num);
		switch(check_digit){
			case 1:
				if(x == 0){
					x = check_num;
					x_count ++;
				}else if(x != check_num){
					ans = -1;
				}
				break;
			case 2:
				if(y == 0){
					y = check_num;
				}else if(y != check_num){
					ans = -1;
				}
				break;
			case 3:
				if(z == 0){
					z = check_num;
				}else if(z != check_num){
					ans = -1;
				}
				break;
			default:
				break;
		}
	}
	
	switch(digit){
		case 3:
			if(x == 0){
				if(x_count == 0){
					x = 1;
				}else{
					ans = -1;
				}
			}
			x = x * 100;
			y = y * 10;
			z = z;
			break;
		case 2:
			if(x == 0){
				if(x_count == 0){
					x = 1;
				}else{
					ans = -1;
				}
			}
			x = x * 10;
			y = y;
			break;
		case 1:
			x = x;
			break;
		default:
			break;
	}
	
	if(ans == 0){
		ans = x + y + z;
	}
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 128
N = int(input())
a = list(map(int, input().split()))
if max(a) - min(a) >= 2:
    print("No")
    exit()
else:
    M = max(a)
    m = min(a)
    if M == m:
        if m <= N / 2 or m == N - 1:
            print("Yes")
        else:
            print("No")
    else:
        if a.count(m) >= M or a.count(M) + 2 * a.count(m) < 2 * M:
            print("No")
        else:
            print("Yes")

Measured memory_bytes: 83864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<ll> A(3*N);
	for (auto& x : A) cin >> x;
	vector<ll> a(3*N), b(3*N);
	{
		multiset<ll> s;
		ll sum = 0;
		for (int i = 0; i < 3*N; ++ i) {
			sum += A[i];
			s.insert(A[i]);
			if (i >= N) {
				sum -= *s.begin();
				s.erase(s.begin());
			}
			a[i] = sum;
		}
	}
	{
		multiset<ll> s;
		ll sum = 0;
		for (int i = 3*N-1; i >= 0; -- i) {
			sum -= A[i];
			s.insert(-A[i]);
			if (i < 2*N) {
				sum -= *s.begin();
				s.erase(s.begin());
			}
			b[i] = sum;
		}
	}
	ll r = -(1LL<<60);
	for (int i = N-1; i < 2*N; ++ i) {
		r = max(r, a[i] + b[i+1]);
	}
	cout << r << endl;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, q_num;
string s;
map<char, set<int>> mp;

int main()
{
    cin>>n>>s>>q_num;
    REPALL(k,s) {
        mp[s[k]].insert(k);
    }
    REP(k,q_num) {
        int q;
        cin>>q;
        if (q == 1) {
            int i;
            char c;
            cin>>i>>c;
            mp[s[i-1]].erase(i-1);
            mp[c].insert(i-1);
            s[i-1] = c;
            //debug(s);
        } else {
            int l, r, tans = 0;
            cin>>l>>r;
            l--; r--;
            REP(kk,26) {
                char tmpc = 'a' + kk;
                // auto itr = lower_bound(mp[tmpc].begin(), mp[tmpc].end(), l);     // before
                auto itr = mp[tmpc].lower_bound(l);                                 // after
                /*if (itr != mp[tmpc].end()) {
                    debug(tmpc);
                    debug(*itr);
                }*/
                if (itr != mp[tmpc].end() && *itr <= r)
                    tans++;
            }
            cout<<tans<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 24196
def conb(a, b):
    ans = 1
    for i in range(b):
        ans *= (a - i)
        ans /= (i + 1)
    return ans
    
A = {"M":0, "A":0, "R":0, "C":0, "H":0}
N = int(input())
S = [input() for i in range(N)]
S = [c for c in S if c[0] in A]
for c in S:
    A[c[0]] += 1

N = len(S)
if N >= 3:
    zen = conb(N , 3)
    for a in A:
        a = A[a]
        if a > 2:
            zen -= (conb(a, 3) + conb(a, 2) * (N - a))
        elif a > 1:
            zen -= (N - a)
else:
    zen = 0
print(int(zen))

Measured memory_bytes: 10520
def laod_to_mill():
    days = int(input())
    prices = tuple(map(int, input().split()))

    total = 1000
    ks = 0

    for d in range(days):
        if d == days - 1:
            total += ks * prices[d]
            break

        if prices[d] < prices[d + 1]:
            buy = total // prices[d]
            total -= buy * prices[d]
            ks += buy

        elif prices[d] > prices[d + 1]:
            total += ks * prices[d]
            ks = 0

    print(total)

def main():
    laod_to_mill()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9060
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>a>>b;
    if(b%a==0) cout<<a+b;
    else cout<<b-a;

    

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
 int i=0,j=0;
  while(c>0)
  {
      c=c-b;
      i++;
  }
  while(a>0)
  {
      a=a-d;
      j++;
  }
    if(i>j)
  {
      cout<<"No"<<endl;
  }
  else
    cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
	int n, m, select, voteSum;
	double pivot;
	int ai[1000];
	int i;

	scanf("%d%d", &n, &m);

	voteSum = 0;

	/* 商品の種類ごとに獲得票を合計する */
	for (i = 0; i < n; i++)
	{
		scanf("%d", &ai[i]);
		voteSum += ai[i];
	}

	pivot = voteSum / (4.0 * m);

	select = 0;

	/* 選択対象の商品を数える */
	for (i = 0; i < n; i++)
	{
		if (ai[i] >= pivot)
		{
			select++;
		}
	}

	if (select >= m)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>
#include <string.h>

int a[21][21];
int dx[128], dy[128];
int main(void)
{
    dx['E']=1, dx['W']=-1;
    dy['N']=1, dy['S']=-1;
    while (1) {
        int n, m, i, cx, cy, r;
        scanf("%d", &n);
        if (n==0) break;

        memset(a, 0, sizeof(a));
        for(i=0;i<n;++i) {
            int x, y;
            scanf("%d%d", &x, &y);
            a[x][y]=1<<i;
        }

        cx=cy=10;
        r=0;
        scanf("%d", &m);
        while (m--) {
            char c[2];
            int d;
            scanf("%s%d", c, &d);
            for(i=1;i<=d;++i) {
                cx+=dx[*c], cy+=dy[*c];
                r|=a[cx][cy];
            }
        }
        puts(r==(1<<n)-1 ? "Yes" : "No");
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    long long L[n+1] = {0};

    if(n == 1){
        cout << 1 << endl;
    }else{
        L[0] = 2;
        L[1] = 1;
        for(int i=2;i<=n;i++){
            L[i] = L[i-1] + L[i-2];
        }
        cout << L[n] << endl;
    }

    return 0;
}

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

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

    int n;
    cin >> n;
    int p[n];
    rep(i,n) cin >> p[i];
    
    int base[n];
    rep(i,n){
        base[i] = i + 1;
    }
    
    int count = 0;
    rep(i,n){
        if(base[i] != p[i]) count++;
    }
    
    if(count <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		long A = sc.nextInt();
		long V = sc.nextInt();
		long B = sc.nextInt();
		long W = sc.nextInt();
		long T = sc.nextInt();

		if (V <= W) {
			System.out.println("NO");
		} else {
			long d = Math.abs(A - B);
			if ((V-W)*T>=d) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		}

	}
}

Measured memory_bytes: 27024
s=[];
(1..gets.to_i).each do |i|
  x=i
  if x%3 == 0
    s << i
  else
    while x!=0
      if x%10 == 3
        s << i
        break
      else
        x = (x/10).to_i
      end
    end
  end
end
puts " "+s.join(" ")

Measured memory_bytes: 6168
import sys
sys.setrecursionlimit(10**6)

n=int(input())

edge=[[] for _ in range(n+1)]

for i in range(n-1):
    v1,v2,w=map(int,input().split())
    if w%2!=0:
        edge[v1].append((v2,-1))
        edge[v2].append((v1,-1))
    else:
        edge[v1].append((v2,1))
        edge[v2].append((v1,1))

color=[None]*(n+1)        
def set_color(x,col):
    color[x]=col
    
    for i,j in edge[x]:
        if color[i] is None:
            set_color(i,j*col)
set_color(1,1)

for x in color[1:]:
    print((x+1)//2)
        

Measured memory_bytes: 76464
#include<iostream>
#include<string>
using namespace std;
int main(){
	long long a,b;
	while(cin>>a>>b){
		while(true){
			if(a>b)
				a-=b;
			if(a<b)
				b-=a;
			if(a==b)
				break;
		}
		cout<<a<<endl;
	}
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main(){
    ios::sync_with_stdio(false);
    LL A[3];
    for(int i = 0; i < 3; i += 1) cin >> A[i];
    sort(A, A + 3);
    if(A[0] % 2 == 0 or A[1] % 2 == 0 or A[2] % 2 == 0)
        cout << 0;
    else cout << A[0] * A[1];
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> res;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(n%2==0){
                if(i+j!=n-1){
                    res.push_back({i,j});
                }
            }
            else{
                if(i+j!=n-2){
                    res.push_back({i,j});
                }
            }
            
        }
    }
    cout<<res.size()<<endl;
    for(auto p:res){
        cout<<p.first+1<<" "<<p.second+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define f first
#define s second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    //cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    int res=1;
    bool zero=false;
    rep(i,n){
        cin >> a[i];
        if(a[i]==0) zero=true;
    }
    if(zero){
        cout<<0<<endl;
        return 0;
    }
    rep(i,n){
        res*=a[i];

        if(res>1000000000000000000 || res<0 || res<a[i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    if(res>1000000000000000000) cout<<-1<<endl;
    else if(res<0) cout<<-1<<endl;
    else cout<<res<<endl;

}

Measured memory_bytes: 4052