akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

const int MAX_N=100010;
const int MAX_M=200020;
int n,m;
int L[MAX_M],R[MAX_M],D[MAX_M];

vector<pii> graph[MAX_N];
bool used[MAX_N];
int x[MAX_N];

void dfs(int s){
	used[s]=true;
	for(int i=0;i<graph[s].size();i++){
		int to=graph[s][i].first;
		if(!used[to]){
			x[to]=x[s]+graph[s][i].second;
			dfs(to);
		}
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>L[i]>>R[i]>>D[i];
		L[i]--; R[i]--;
		graph[L[i]].push_back(pii(R[i],D[i]));
		graph[R[i]].push_back(pii(L[i],-D[i]));
	}
	fill(used,used+n,false);
	for(int i=0;i<n;i++){
		if(!used[i]){
			x[i]=0;
			dfs(i);
		}
	}
	for(int i=0;i<m;i++){
		if(x[R[i]]-x[L[i]]!=D[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    ll x,y,z;cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  string s;
  cin >> s;
  ll ans=0;
  int countA=0;

  REP(i,s.size()-1){
    if(s[i]=='A'){
      countA++;
    }
    else if(s[i]=='C'){
      countA=0;
    }
    else { //B
      if(s[i+1]=='C'){
	i++;
	ans+=countA;
      }
      else {
	countA=0;
      }
    }
  }

  cout<<ans;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>

using namespace std;

//start of 0uts1de's library

int cin_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cin >> arr.at(i);
    }
    return 0;
}

int cin_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cin >> arr.at(i);
    }
    return 0;
}


int cout_int_arr(vector<int>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_int_arr(vector<int>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr){
    for (int i = 0; i < arr.size(); ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}

int cout_double_arr(vector<double>& arr, int n){    //overload
    for (int i = 0; i < n; ++i){
        cout << arr.at(i) << endl;
    }
    return 0;
}


int max_int_arr(std::vector<int>& arr, int mode = 0){    //0 -> data  1 -> index
    int maxVal = INT_MIN;       //min of int
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            if (mode == 0){
                maxVal = arr.at(i);
            }
            else if (mode == 1){
                maxVal = arr.at(i);
                maxIndex = i;
            }
            else{
                cout << "Invalid mode." << endl;
                return -1;
            }
        }
    }
    if (mode == 0){
        return maxVal;
    }
    else if (mode == 1){
        return maxIndex;
    }
    return -1;
}

double max_double_arr(std::vector<double>& arr, int mode = 0){    //0 -> data  1 -> index
    double maxVal = -DBL_MAX;       //min of double
    int maxIndex = 0;
    for (int i = 0; i < arr.size(); ++i){
        if (arr.at(i) > maxVal){
            if (mode == 0){
                maxVal = arr.at(i);
            }
            else if (mode == 1){
                maxVal = arr.at(i);
                maxIndex = i;
            }
            else{
                cout << "Invalid mode." << endl;
                return -1;
            }
        }
    }
    if (mode == 0){
        return maxVal;
    }
    else if (mode == 1){
        return maxIndex;
    }
    return -1;
}

//end of 0uts1de's library

int main(){
    int n, k, ans = INT_MAX;
    cin >> n >> k;
    vector<int> h(n);
    cin_int_arr(h);
    sort(h.begin(), h.end());
    for (int i = 0; i < n - k + 1; ++i){
        if (h.at(i + k - 1) - h.at(i) < ans){
            ans = h.at(i + k - 1) - h.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
def resolve():
    a, b = input().split()
    a = int(a)
    b100 = int(b.replace('.', ''))

    ans = str(a * b100)
    if len(ans) > 2:
        ans = ans[:-2]
    else:
        ans = 0

    ans = int(ans)
    print(ans)
resolve()

Measured memory_bytes: 61864
from itertools import accumulate
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
s = list(accumulate(l))
l_2 = [s[k - 1]]
for i in range(len(l) - (k - 1) - 1):
    l_2 += [s[i + k] - s[i]]
print(max(l_2))


Measured memory_bytes: 25152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
int n;

int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		if(a==b)
		puts("Draw");
		else if(a==1||(a>b&&b!=1))
		puts("Alice");
		else
		puts("Bob");
	}
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if (x < 0 || y < 0 || W < x || H < y)
		printf("No\n");

	else if (x - r < 0 || y - r < 0 || W < x + r || H < y + r)
		printf("No\n");

	else
		printf("Yes\n");

		return 0;
}

Measured memory_bytes: 584
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
a = LI()
d = [0,0]
for i in a:
    if i%2:
        d[0] += 1
    if i%4 == 0:
        d[1] += 1
if n % 2:
    d[0] -= 1
d[0] -= d[1]
if d[0] <= 0:
    print("Yes")
else:
    print("No")
"""

#D
h,w = LI()
n = I()
a = LI()
c = [[None for x in range(w)] for y in range(h)]
i = 0
for y in range(h):
    if y%2:
        for x in range(w)[::-1]:
            if not a[i]:
                i += 1
            c[y][x] = i+1
            a[i] -= 1
    else:
        for x in range(w):
            if not a[i]:
                i += 1
            c[y][x] = i+1
            a[i] -= 1
for i in c:
    print(*i)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 42864
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif // LOCAL
using ll = long long ;
ll n;
ll rec(ll x){
    if(x  < 2) return 1;
    return x * rec(x - 2);
}

int main(){
    cin >> n;
    if(n % 2) return !printf("0");
    if(n < 10) {
        ll res = rec(n);
        int ans = 0;
        while(res % 10 == 0){
            ans ++;
            res /= 10;
        }
        return !printf("%d\n", ans);
    }
    n = n - (n % 10);
    ll res = n / 10;
    ll cur = 5;
    n /= 10;
    while(cur <= n){
        res += n / cur;
        if((double)5 * cur > n) break;
        cur *= 5;
    }
    return !printf("%lld\n", res);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
import collections, itertools

h, w, m = map(int, input().split())
bombs = set(tuple(map(int, input().split())) for _ in range(m))

a = collections.Counter(x for x, y in bombs)
b = collections.Counter(y for x, y in bombs)
a_max_val = max(a.values())
b_max_val = max(b.values())
a_max_list = [k for k, v in a.items() if v == a_max_val]
b_max_list = [k for k, v in b.items() if v == b_max_val]

for a_max, b_max in itertools.product(a_max_list, b_max_list):
    if not (a_max, b_max) in bombs:
        print(a_max_val + b_max_val)
        exit(0)

print(a_max_val + b_max_val - 1)

Measured memory_bytes: 86240
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long int
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define LN outchar('\n')
using namespace std;
const ll MOD  = int(1e9 + 7);

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}
const int NAX = 1e5 + 5;
const int mod = 1e9 +7;

int dp[105][NAX];
int prefix[105][NAX];
	
int main () {
	int n; int k;
	cin >> n >> k;
	int arr[n]; 
	for (int i = 0; i< n;i ++) {
		cin >> arr[i];
	}
	
	for (int i = 0; i<=k ; i++) {
		if (i<=arr[0]) {
			dp[0][i] = 1;
		}
		prefix[0][i+1] = prefix[0][i] +dp[0][i];
	}

	// pahla child me to 1
	for (int child = 1 ; child <n ; child ++ ) {
		for (int j = 0; j<=k;j++) { // 0 se K candines 0 se children -1 tak bat gya
			
			dp[child][j] = prefix[child-1][j+1] - prefix[child-1][ (int)max( j-arr[child], 0)]; // Jth index tak ke sum me se 
			dp[child][j]%=mod; dp[child][j]+=mod; dp[child][j]%=mod; // Made sure +ve	
			prefix[child][j+1] = prefix[child][j] + dp[child][j];
			prefix[child][j+1]%=mod;
			// cout << child << " "<<  j << " " << dp[child][j] <<endl; 
		}
	}

	
	cout << dp [n-1][k] <<endl;
}



Measured memory_bytes: 82176
#include <iostream>
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
int main() {
int N; cin>>N;
while(N--) {
char c[10]; scanf("%s",c );
if(c[0] == 'Y') {
cout <<"Four"<<endl;return 0;
}
}
cout<<"Three"<<endl;
}

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

using namespace std;

int main() {

	string n;
	cin >> n;

	int res=0;
	int ncount = 0;
	for (int i = 1; i < n.size(); i++) {
		res += 9;
		if (n[i] == '9') { ncount++; }
	}

	if (ncount != n.size() - 1) {
		cout << res + (char)(n[0]) - '0' - 1 << endl;
	}
	else {
		cout << res + (char)(n[0]) - '0' << endl;
	}
	return 0;
}

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = (a), i##end = (b); i < i##end; ++ i)
#define Rep(i, a, b) for (int i = (a), i##end = (b); i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = (b); i >= i##end; -- i)

typedef long long LL;

template<class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template<class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template<class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template<class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template<class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 2000 + 5;

int n, k, num;

struct Tree {
  int hed[MAXN], nxt[MAXN * 2], to[MAXN * 2], cnt;

  void addEdge(int u, int v) {
    ++ cnt;
    to[cnt] = v;
    nxt[cnt] = hed[u];
    hed[u] = cnt;
  }

  void DFS(int u, int p, int d, int fa) {
    if (d <= k >> 1) {
      ++ num;
    }
    for (int e = hed[u]; e; e = nxt[e]) {
      int v = to[e];
      if (v != fa && v != p) {
        DFS(v, p, d + 1, u);
      }
    }
  }
} T;

struct Edge {
  int u, v;
} edge[MAXN];

int main() {
  scanf("%d%d", &n, &k);
  For(i, 2, n) {
    scanf("%d%d", &edge[i].u, &edge[i].v);
    T.addEdge(edge[i].u, edge[i].v);
    T.addEdge(edge[i].v, edge[i].u);
  }
  int answer = 0;
  if (k & 1) {
    For(i, 2, n) {
      num = 0;
      T.DFS(edge[i].u, edge[i].v, 0, 0);
      T.DFS(edge[i].v, edge[i].u, 0, 0);
      chkmax(answer, num);
    }
  } else {
    For(i, 1, n) {
      num = 0;
      T.DFS(i, 0, 0, 0);
      chkmax(answer, num);
    }
  }
  printf("%d\n", n - answer);
  return 0;
}

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    long long n, k;
    cin >> n >> k;
    // if (n == 0 || k == 1) {
    //     cout << 0 << endl;
    // }else if(n <= k) {
    //     cout << min(n, llabs(n-k)) << endl;
    // }else if(k <= n/2) {
    //     cout << n%k << endl;
    // }else {
    //     n -= k;
    //     cout << min(n, llabs(n-k)) << endl;
    // }
    long long t = n%k;
    cout << min(t, k-t);
}


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

typedef long long ll;


int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
    int n;
    ll a[200005],sum;
    ll mod=1e9+7;

    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        ans = (ans+a[i]*sum)%mod;
        sum = sum+ a[i];
        sum = sum%mod;
    }
    cout << ans;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void) {
    string s;
    cin >> s; 

if(s == "ABC"){
    printf("ARC\n");
return 0;
}
else{
    printf("ABC\n");
}

  return 0;
}

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

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

  int K,X;
  cin >> K >> X;

  if(500*K >= X) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define mod1 1000000007
#define mod2 998244353
#define debug(x) cout<<#x<<" : "<<x<<endl

int main()
{
	optimize

	string s,t;
	cin>>s;
	cin>>t;

	int ans = 0;
	forab(i,0, s.size())
	{
		if(s[i] != t[i])
			ans++;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3808
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
vector<string> V1,V2;
string s1,s2;

ll jud(ll x1,ll x2){
	if(x1>=s1.size()||x2>=s2.size()) return 0;
	ll res=0;
	while(res<min(V1[x1].size(),V2[x2].size())&&V1[x1][res]==V2[x2][res]){
		res++;
	}
	return res;
}

int main()
{
	while(cin>>s1>>s2){
	V1.clear();
	V2.clear();
	ll ans=0;
	for(ll i=0;i<s1.size();i++){
		V1.push_back(s1.substr(i));
	}
	for(ll i=0;i<s2.size();i++){
		V2.push_back(s2.substr(i));
	}
	sort(V1.begin(),V1.end());
	sort(V2.begin(),V2.end());
	for(ll i=0;i<V1.size();i++){
		ans=max(ans,jud(i,lower_bound(V2.begin(),V2.end(),V1[i])-V2.begin()));
	}
	for(ll i=0;i<s2.size();i++){
		ans=max(ans,jud(lower_bound(V1.begin(),V1.end(),V2[i])-V1.begin(),i));
	}
	cout<<ans<<endl;
}}

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

signed main()
{
   int ans=0;
   int N; cin>>N;
   for(int i=0;i<N;i++){
      int a; cin>>a;
      ans+=(a%2==0);
   }
   cout<<ans<<endl;
}




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

int main ()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> d[i];
    }

    sort(d.begin(), d.end());
    int half = n/2;
    if (d[half-1] == d[half])
    {
        cout << 0 << endl;
    }
    else
    {
        int ans = d[half] - d[half-1];
        cout << ans << endl;
    }
    
    return 0;
}

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

const int N = 200010;
const ll INF = 1e+9 + 7;
ll dp[N];

int main(){
    int h, n;
    cin >> h >> n;
    int a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];
    int amax = 0;
    rep(i, n) amax = max(a[i], amax);

    rep(i, N) dp[i] = INF;
    dp[0] = 0;

    rep(i, h){
        rep(j, n){
            dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j]);
        }
    }
    ll ans = INF;
    rep(i, amax) ans = min(ans, dp[h + i]);
    cout << ans << endl;
}

Measured memory_bytes: 1792
let linear_search x ys = List.fold_left (fun acc y -> acc || (if y = x then true else false)) false ys

let () =
  let read_seq () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string in
  let _ = read_int () in
  let s = read_seq () in
  let _ = read_int () in
  let t = read_seq () in
  List.fold_left (fun acc e -> acc + (if linear_search e s then 1 else 0)) 0 t
  |> Printf.printf "%d\n"

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 500010;
ll num, ans=0, count=0, sum=0;
int main() {
    ll N;
    cin >> N;
    vl h(N);
    rep(i, N) cin >> h[i];

    sum=h[0];
    rep(i, N-1) sum += max((ll)0,h[i+1]-h[i]);
    cout << sum << endl;
    return 0;
}

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

public class Main {
	
	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	public void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String seq = sc.nextLine();
		sc.close();
		
		ArrayList<ArrayList<Integer>> numPosList = new ArrayList<>(10);
		for(int i = 0; i < 10; i++) {
			numPosList.add(new ArrayList<>());
		}
		
		for(int i = 0; i < n; i++) {
			int charAtI = seq.charAt(i) - 48;
			numPosList.get(charAtI).add(new Integer(i));
		}
		
		int ans = 0;
		int iPos,jPos,kPos;
		for(int i = 0; i < 10; i++) {
			
			ArrayList<Integer> firstList= numPosList.get(i);
			if(firstList.size() == 0) {
				continue;
			}else {
				iPos = firstList.get(0);
			}
			for(int j = 0; j < 10; j++) {
				
				ArrayList<Integer> secondList = numPosList.get(j);
				jPos = 0;
				for(int l = 0; l < secondList.size(); l++) {
					int candSecondPos = secondList.get(l);
					if(candSecondPos > iPos) {
						jPos = candSecondPos;
						break;
					}
				}
				if(jPos <= iPos) {
					continue;
				}
				
				for(int k = 0; k < 10; k++) {
					ArrayList<Integer> thirdList = numPosList.get(k);
					kPos = 0;
					for(int m = 0; m < thirdList.size(); m++) {
						int candThirdPos = thirdList.get(m);
						if(candThirdPos > jPos) {
							kPos = candThirdPos;
							break;
						}
					}
					if(kPos > jPos) {
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 25300
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());

using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MOD = 1000000007; // 10^9 + 7

string s;

string dfs(string res, int sum, int i) {
  if (i == 4) return sum == 7 ? res + "=7" : "";

  int si = s[i] - '0';
  string s1 = dfs(res + "+" + s.substr(i, 1), sum + si, i + 1);
  if (s1.size() > 0) return s1;

  string s2 = dfs(res + "-" + s.substr(i, 1), sum - si, i + 1);
  if (s2.size() > 0) return s2;

  return "";
}

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

  cin >> s;
  cout << dfs(s.substr(0, 1), s[0] - '0', 1) << endl;
}

Measured memory_bytes: 888
N = int(input())
A = list(map(int, input().split()))

P = [0]*100001
sumA = sum(A)

for i in range (0, N):
	P[A[i]]+=1

Q = int(input())

for i in range (0, Q):
	B, C = map(int, input().split())
	if P[B] > 0:
		sumA+=(C-B)*P[B]
		P[C]+=P[B]
		P[B] = 0
		print(sumA)
	else:
		print(sumA)

Measured memory_bytes: 21024
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B,C,K = map(int,input().split())

num = K
ans = 0
if num - A <= 0:
    print(K)
    exit()
elif num - A - B <= 0:
    print(A)
    exit()
elif num - A -B -C <=0:
    ans = A - (K - A - B)
    print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <iomanip>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  int k, s;
  int x, y, z;
  cin >> k >> s;
  
  int cnt = 0;
  REP(x,k+1){
    REP(y,k+1){
      z = s - x - y;
      if(z >= 0 && z <= k){
	cnt++;
      }
    }
  }
  FINA(cnt);
 return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c;
	int k;
	int n;

	scanf("%d%d%d", &a, &b, &c);
	n = 0;
	for (k = a; k <= b; k++) {
		if (c % k == 0) n++;
	}
	printf("%d\n", n);
	return 0;
}



Measured memory_bytes: 2144
use proconio::input;
use proconio::marker::{Bytes, Chars, Isize1, Usize1};

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64
    }

    let ans = vec![a*c,a*d,b*c,b*d];



    println!("{}",ans.iter().max().unwrap())
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define unmap  	unordered_map<int,int>
#define	unset	unordered_set<int>
#define maxpq  	priority_queue<int>
#define minpq  	priority_queue<int, vector<int>, greater<int>>
#define pb 		push_back		
#define ll 		long long
#define ull     unsigned ll
#define ff 		first
#define ss 		second//typedef second ss;
#define foton(i,n) for(int i=0;i<n;i++)
#define	faton(i,a,n)	for(int i=a;i<=n;i++)
#define mod 	1000000007
int const inf = 10000007;
#define endl "\n"
using namespace std;

int main(){
	fastio;
	int n;cin>>n;
    int cnt = 0;
    for(int i=0;i<n;i++){
        int a,b;cin>>a>>b;
        if(a==b) cnt++;
        else if(cnt>=3){
            continue;
        }
        else cnt = 0;
    }
	if(cnt>=3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

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

int u[65], v[65], w[65];

int main (){
	int L, n = 0, m = 0, i, d;
	scanf("%d", &L);
	d = L; while(d){
		d /= 2;
		++n;
	}
	for(i = 0; i < n - 1; ++i){
		if(i < n - 1){
			u[m] = i, v[m] = i + 1, w[m++] = 0;
			u[m] = i, v[m] = i + 1, w[m++] = (1 << i);
		}
		if(L & (1 << i)){
			u[m] = i, v[m] = n - 1, w[m++] = ((1 << n) - (1 << (i + 1))) & L;
		}
	}
	printf("%d %d\n", n, m);
	for(i = 0; i < m; ++i)
		printf("%d %d %d\n", u[i] + 1, v[i] + 1, w[i]);
	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;

vector<string> split(const string &s, char c = ' '){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.pb(t);
	}
	return ret;
}

vector<string> get_word(string s){
	vector<string> ret;
	for(int i = 0; i < s.size(); i++){
		for(int j = i; j < s.size(); j++){
			if((s[j] >= 'A' && s[j] <= 'Z') || j == s.size() - 1){
				if(s[j] > 'Z' && j == s.size() - 1) j++;
				else s[j] += 'a' - 'A';
				ret.push_back(s.substr(i, j - i));
				i = j - 1;
				break;
			}
		}
	}
	return ret;
}

string calc(string s, string t1, string t2){
	string ret;
	if(t1 == "U"){
		if(t2 == "L"){
			ret = s;
			ret[0] += 'a' - 'A';
		}
		else if(t2 == "D"){
			s[0] += 'a' - 'A';
			vector<string> v = get_word(s);
			// cout<<"  ";
			// for(int i = 0; i < v.size(); i++){
			// 	cout<<v[i];
			// }
			// cout<<endl;
			for(int i = 0; i < v.size(); i++){
				s = v[i];
				//s[0] += 'a' - 'A';
				if(ret.size() != 0) ret += "_";
				ret += s; 
			}
		}
		else ret = s;
	}
	else if(t1 == "L"){
		if(t2 == "U"){
			ret = s;
			ret[0] += 'A' - 'a';
		}
		else if(t2 == "D"){
			vector<string> v = get_word(s);
			for(int i = 0; i < v.size(); i++){
				s = v[i];
				//s[0] +='a' - 'A';
				if(ret.size() != 0) ret += "_";
				ret += s; 
			}
		}
		else ret = s;
	}
	else{
		if(t2 == "U"){
			vector<string> v = split(s, '_');
			for(int i = 0; i < v.size(); i++){
				s = v[i];
				s[0] += 'A' - 'a';
				ret += s;
			}
		}
		else if(t2 == "L"){
			vector<string> v = split(s, '_');
			for(int i = 0; i < v.size(); i++){
				s = v[i];
				if(i != 0) s[0] += 'A' - 'a';
				ret += s;
			}
		}
		else ret = s;
	}
	return ret;
}

int main(){
	string s, t;
	while(cin>>s>>t && t != "X"){
		if(s.find("_") != string::npos) cout<<calc(s, "D", t);
		else if(s[0] >= 'A' && s[0] <= 'Z') cout<<calc(s, "U", t);
		else cout<<calc(s,"L", t);
		cout<<endl;
	}
	
}

Measured memory_bytes: 1212
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    p = list(map(int,sys.stdin.readlines()))
    p.sort()
    p[-1] = p[-1]//2
    ans = sum(p)
    print(ans)



Measured memory_bytes: 5868
#include <iostream>

using namespace std;

int main()
{
    char w;
    cin >> w;

    if(w == 'a' || w == 'i' || w == 'u' || w == 'e' || w == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool check(int a, int b, int s, int f){
  if(f<=a){return false;}
  if(b<=s){return false;}
  return true;
}

int main(){
  int a,b,n;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    int s,f;
    cin>>s>>f;
    if(check(a,b,s,f)){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);

  int first = 0;
  int second = 0;
  int third = 0;

  for (int i = 0; i < N; i++) {
    if (P.at(i) <= A)
      first++;
    else if (P.at(i) > A && P.at(i) <= B)
      second++;
    else
      third++;
  }

  cout << min({first, second, third}) << endl;
}

Measured memory_bytes: 256
function Main(input) {
  const lines = input.trim().split("\n");
  const H = lines[1].split(" ").map(h => parseInt(h));
  let ans = 0;
  let maxH = 0;
  H.forEach((h, _) => {
    if (h >= maxH) {
      ans++;
      maxH = h;
    }
  });
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
from collections import deque
n,m = map(int,input().split())
data = [[] for i in range(n)]
ans = [0]*n
for i in range(m):
    a,b =map(int,input().split())
    a -= 1
    b -= 1
    data[a].append(b)
    data[b].append(a)
hantei = [False]*n
hantei[0] = True
deq = deque([0])
while deq:
    k = deq.popleft()
    for i in data[k]:
        if hantei[i]:
            continue
        hantei[i] = True
        ans[i] = k
        deq.append(i)
print("Yes")
for i in range(1,n):
    print(ans[i]+1)

Measured memory_bytes: 34800
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll x,y;
  cin >> x >> y;
  y -= x*2;
  if(y<0 || y%2==1 || y/2>x) {
    cout << "No" << endl;
    return 0;
  } else{
    cout << "Yes" << endl;
    return 0;
  }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
using vvp=vector<vp>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int n;
    cin>>n;
    vp a(n-1);
    cin>>a;
    vi d(n);//jisuu
    vvp g(n);
    REP(i,n-1){
        --a[i].F;
        --a[i].S;

        ++d[a[i].F];
        ++d[a[i].S];

        g[a[i].F].emplace_back(a[i].S, i);
        g[a[i].S].emplace_back(a[i].F, i);
    }
    int color=*max_element(all(d));
    vi c(n-1, -1);

    queue<P> q;
    q.push({0, -1});
    while(q.size()){
        int j = q.front().F;
        int oc = q.front().S;
        q.pop();
        for(auto e:g[j]){
            if(c[e.S]<0){

                q.push({e.F, c[e.S]=(++oc)%=color});
            }
        }
    }
    print(color);
    REP(i,n-1)cout<<c[i]+1<<endl;
}


Measured memory_bytes: 8320
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		HashSet<String> h = new HashSet<String>();

		String[] s = sc.next().split("");
		String ss = String.join("", s);

		for(int i = 0; i < 4; i++) {
			h.add(s[i]);
		}

		System.out.println(h.size() == 2 && ss.replace(ss.substring(0, 1), "").length() == 2 ? "Yes" : "No");
	}
}

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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N;
vector<string> S;

int main(){
  cin >> N;
  S.resize(N);
  map<char, int> cnt;
  
  ll ans = 0;
  REP(i, N){
    cin >> S[i];
    char c = S[i][0];
    if(c == 'M' || c == 'A' || c == 'R' || c=='C' || c=='H'){
      cnt[c]++;
    }
  }
  vector<char> idx = {'M', 'A', 'R', 'C', 'H'};
  REP(i, 5-2){
    FOR(j, i+1, 5-1){
      FOR(k, j+1, 5){
        ans += (ll)cnt[idx[i]]*cnt[idx[j]]*cnt[idx[k]];
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main{
  
  
  static long max(long a,long b) {
  		return a>b ? a: b;
  	}
  static long knapsack(int W, int arr[],int val[],int n){
  		
    	long grid[][]=new long[n+1][W+1];
    	for(int i=0;i<=n;i++){
        	for(int j=0;j<=W;j++){
        	    
              	if(i == 0 || j == 0)
                  grid[i][j]=0;
              	else if(arr[i-1]<=j)
                   grid[i][j]=max(grid[i-1][j], val[i-1]+grid[i-1][j-arr[i-1]]);     
              	else
                 grid[i][j]=grid[i-1][j];
            
            }
        }
    	return grid[n][W];
  
  }
	public static void main(String [] args){
    	Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	int W=sc.nextInt();
      	int arr[]=new int[n];
      	int val[]=new int[n];
      	for(int i=0;i<n;i++){
        	arr[i]=sc.nextInt();
          	val[i]=sc.nextInt();
        }
      	long res = knapsack(W,arr,val,n);
      	System.out.println(res);
    }
}

Measured memory_bytes: 125652
#include <stdio.h>

int
main(int argc, char *argv[])
{
  long long N, ans = 0, temp = 0, sqN;
  scanf("%lld", &N);

  for(long long i = 1; i < N; i++){
    if(temp <= N && N < i * i){
      sqN = i - 1;
      break;
    }
    temp = i * i;
  }

  for(long long i = 1; i <= sqN; i++){
    if(N % i == 0 && N / i - 1 > i) ans += N / i - 1;
  }

  

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

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

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

    int n, c;
    cin >> n >> c;
    vector<vector<int> > D(c, vector<int>(c, 0));
    vector<vector<int> > C(n, vector<int>(n, 0));
    REP(i, c)REP(j, c){
        cin >> D[i][j];
    }

    REP(i, n)REP(j, n){
        cin >> C[i][j];
        C[i][j]--;
    }
    vector<vector<int> > sm(c, vector<int>(3,0));

    REP(k, c)REP(i, n)REP(j, n){
        sm[k][(i+j)%3] += D[C[i][j]][k];
    }

    LL ans = 101010101010;
    REP(i, c)REP(j, c)REP(k, c){
        if(i==j || j==k || k==i) continue;
        ans = min(ans, (LL)sm[i][0]+sm[j][1]+sm[k][2]);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define chmin(a,b) if(a>b)a=b
const int N=1e5+5;

int n,m;
int a[N];
int dp[N];

int main()
{
	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	memset(dp,60,sizeof(dp));
	dp[1]=0;
	for(int i=2;i<=n;i++)
	for(int j=1;j<=m;j++)
		if(i>j) chmin(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	printf("%d\n",dp[n]);
	
	return 0;
}

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

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, n) cin >> a[i + 1];
    sort(all(a));

    ll sum = 0;
    for (int i = 1; i < n; i++)
    {
        sum += a[n - (i / 2)];
    }

    cout << sum << endl;
}


Measured memory_bytes: 3976
a,b,m=gets.split.map(&:to_i)
aa=gets.split.map(&:to_i)
bb=gets.split.map(&:to_i)
mm=aa.min+bb.min
m.times do
  x,y,c=gets.split.map(&:to_i)
  d=aa[x-1]+bb[y-1]-c
  mm=d if mm>d
end
puts mm




Measured memory_bytes: 18700
#include<iostream>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
using namespace std;
int main() 
{
 int i,n,x,cnt=0,j, flag=0;
 vector<int>a;
 cin>>n;
 for(i=0;i<n;i++) 
 {
 	cin>>x;
 	a.push_back(x);
 } 
 sort(a.begin(),a.end());
 vector<int>b(a[n-1]+1,0);
 for(i=0;i<n;i++) 
 b[a[i]]+=1;
 for(i=1;i<n;i++) 
 {
 	if(a[i]!=a[i-1]) 
 	{
 		for(j=1;j<=(int)sqrt((a[i]*1.0)+1);j++) 
 		{
 			if(a[i]%j==0)
 			{
 				
 				if(b[j])
 				{
 					flag=1;
 					break;
 				} 
 				if((a[i]/j)==a[i] && b[a[i]]>1)
 				{
 					flag=1;
 					break;
 				} 
 				if((a[i]/j)!=a[i] && b[(a[i]/j)]>0)
 				{
 					flag=1;
 					break;
 				} 
 			} 
 		}
 		if(!flag) cnt+=1;
 		else flag=0;
 	} 
 } 
 if(n>1 && a[0]!=a[1]) cnt+=1;
 if(n==1)cout<<1<<endl;
 else cout<<cnt<<endl;
 return 0;
} 


Measured memory_bytes: 7856
#include <bits/stdc++.h>
#ifdef IS_MY_ENVIRONMENT
#include <tourist>
#endif
using namespace std;

double ans;

signed main() {

    int n, k;
    cin >> n >> k;
    for ( int i = 1; i <= n; i++ ) {
        int cnt = 0;
        int b = i;
        while ( b < k ) {
            cnt++;
            b *= 2;
        }
        ans += pow(0.5, cnt);
    }

    ans /= (double)n;
    printf("%.12lf\n", ans);

    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;

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

    string s;
    cin >> s;

    if(s.back() == 's') s += "es";
    else s += "s";

    cout << s << "\n";

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n, k, cnt=0;
    cin >> n >> k;
    int h[n];
    REP(i, n){
        cin >> h[i];
        if(h[i] >= k) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
from itertools import accumulate
import sys
input = sys.stdin.readline

k, q = map(int, input().split())
d = list(map(int, input().split()))
for _ in range(q):
    n, x, m = map(int, input().split())
    ans = n - 1
    s = x % m
    dm = [i % m for i in d]
    accum = list(accumulate(dm))
    count = [0] * k
    for i in range(k):
        if dm[i] == 0:
            count[i] += 1
    count = list(accumulate(count))

    s += accum[-1] * ((n-1) // k)
    ans -= count[-1] * ((n-1) // k)
    if (n-1) % k > 0:
        s += accum[(n-1) % k - 1]
        ans -= count[(n-1) % k - 1]
    ans -= s // m
    print(ans)


Measured memory_bytes: 119132
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int B, W;
ll f[200001], finv[200001];

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a = a*x%mod;
		}
		x = x*x%mod;
		y >>= 1;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

ll comb(int x, int y) {
	if (x < y)return 0;
	return f[x] * finv[x - y] % mod*finv[y] % mod;
}

int main(){
	cin >> B >> W;
	f[0] = 1;
	for (int i = 1; i <= B + W; ++i) {
		f[i] = f[i - 1] * i%mod;
	}
	for (int i = 0; i <= B + W; ++i) {
		finv[i] = modinv(f[i]);
	}
	ll t = 1, b, w;
	b = w = 0;
	for (int i = 0; i < B + W; ++i) {
		t = t*finv[2] % mod;
		cout << (((1 - (b+w) % mod) + mod) *finv[2] + w) % mod << endl;
		b = (b + t*comb(i, B - 1)) % mod;
		w = (w + t*comb(i, W - 1)) % mod;
	}
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int w,h,n,x,x1,x2,y,y1,y2,a,ans=0;
  cin>>w>>h>>n;
  x1=0;x2=w;
  y1=0;y2=h;
  rep(i,0,n){
    cin>>x>>y>>a;
    if(a==1){
      x1=max(x1,x);
    }else if(a==2){
      x2=min(x2,x);
    }else if(a==3){
      y1=max(y1,y);
    }else{
      y2=min(y2,y);
    }
  }
  if(x2-x1>0&&y2-y1>0){
    ans=(x2-x1)*(y2-y1);
  }else{
    ans=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>


using namespace std;

int main(){
    
    char str[4];
    scanf("%s",str);
    
    
    if(strcmp(str, "ABC")==0){
        printf("%s\n","ARC");
    }else{
        printf("%s\n","ABC");
    }
    
    
    
   
    return 0;
}


Measured memory_bytes: 3688