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

int main() {
	ll n,m;
	cin>>n>>m;
	string s[n];
	for(ll i=0;i<n;i++)
	    cin>>s[i];
	ll a[n][m];
	for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)a[i][j]=0;
	a[n-1][m-1]=1;
	ll f1=0,f2=0;
	for(ll i=n-2;i>=0;i--)
	{
	    if(s[i][m-1]=='#')f1=1;
	    if(f1==0)a[i][m-1]=1;
	}
	for(ll i=m-2;i>=0;i--)
	{
	    if(s[n-1][i]=='#')f2=1;
	    if(f2==0)a[n-1][i]=1;
	}
	for(ll i=n-2;i>=0;i--)
	{
	    for(ll j=m-2;j>=0;j--)
	    {
	        if(s[i][j]=='#')a[i][j]=-1;
	        else{
	            if(s[i+1][j]!='#')a[i][j]=a[i+1][j];
	            if(s[i][j+1]!='#'){
	                a[i][j]+=a[i][j+1];
	                a[i][j]%=mod;
	            }
	        } 
	    }
	}
	cout<<a[0][0];
	return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) rep(i,0,n)

int main()
{
  int N, X; cin >> N >> X;
  vector<int> length(N);
  REP(i, N){ cin >> length[i]; }
  int now = 0;
  int count = 1;

  REP(i,N){
    now += length[i];
    if(now <= X){count++;}
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret

ans = dfs("0")
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int N=2e5+1;
int n, k, a[N], b[N];
int main() {
	scanf("%d%d", &n, &k);
	for(int i=1; i<=n; ++i) scanf("%d", a+i);
	for(int i=1; i<=k; ++i) {
		memset(b+1, 0, n*sizeof(int));
		for(int i=1; i<=n; ++i) {
			++b[std::max(1, i-a[i])];
			if(i+a[i]<n) --b[i+a[i]+1];
		}
		for(int i=1; i<=n; ++i) b[i]+=b[i-1];
		if(!memcmp(a+1, b+1, n*sizeof(int))) break;
		memcpy(a+1, b+1, n*sizeof(int));
	}
	for(int i=1; i<=n; ++i) printf("%d%c", a[i], " \n"[i==n]);
	return 0;
}


Measured memory_bytes: 5328
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	int N;
	cin>>N;
	int maxN=0;
	int nowN=0;
	int oldH=0;
	int nowH=0;
	for(int i=0;i<N;i++){
		cin>>nowH;
		if(nowH<=oldH){
			nowN++;
		}else{
			if(nowN>maxN)maxN=nowN;
			nowN=0;
		}
		oldH=nowH;
		//cout<<" "<<nowN<<endl;
	}
	if(nowN>maxN)maxN=nowN;
	cout<<maxN;
	return 0;
}

Measured memory_bytes: 256
#line 1 "cumulative_sum.test.cpp"
#define  PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0516"

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

#line 1 "../cumulative_sum.cpp"
template<class T>
struct CumulativeSum {
  vector<T> v;

  CumulativeSum(size_t n) : v(n+1) {};
  CumulativeSum(vector<T> v_) {
    v.resize(v_.size()+1);
    for (size_t i = 0; i < v_.size(); i++) v[i+1] = v_[i];
  };

  void add(size_t i, T x) {
    v[i+1] += x;
  }

  // O(N)
  void build() {
    for (size_t i = 0; i < v.size()-1; i++)
      v[i+1] += v[i];
  }

  // O(1) sum [l, r]
  T sum(size_t l, size_t r) const {
    return l == 0 ? v[r+1] : v[r+1]-v[l];
  }

  // O(1) sum [0, r]
  T sum(size_t r) const {
    return v[r+1];
  }

  T& operator[](size_t i) {
    return v[i];
  }

  const T& operator[](size_t i) const {
    return v[i];
  }
};
#line 15 "cumulative_sum.test.cpp"

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

  while (1) {
    ll n, k;
    cin >> n >> k;
    if (n == 0 and k == 0) return 0;
    vl a(n);
    rep(i, n) {
      cin >> a[i];
    }

    CumulativeSum<ll> cs(a);
    cs.build();
    ll ans = -1e4;
    for (ll i = 0; i+k-1 < n; i++) {
      cmax(ans, cs.sum(i, i+k-1));
    }

    cout << ans << endl;
  }
}



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

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<long>;
using vll = vector<ll>;
using vb  = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vector<int> >;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

int main()
{
    FASTIO;
    int n; cin >> n;
    vi a(n);
    int total_xor = 0;

    rep(i, 0, n-1) {
        cin >> a[i];
        total_xor ^= a[i];
    }

    rep(i, 0, n-1)
        cout << (total_xor ^ a[i]) << ' ';
    cout << nl;
    return 0;
}


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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);
#define COUT(d) cout<<std::setprecision(10)<<d<<endl;
#define CIN(n) getline(cin,n);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;


void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vector<ll>& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
	
  //init(); // mint初期化
  int n;
  string s;
  cin>>s;
  n=s.size();
  VI ans(n);

  REP(ri,2){
    int cnt=0;
    REP(i,n){
      if(s[i]=='R')cnt++;
      else{
        ans[i]+=cnt/2;
        ans[i-1]+=(cnt+1)/2;
        cnt=0;
      }
    }
    reverse(ans.begin(),ans.end());
    reverse(s.begin(),s.end());
    REP(i,n){
      if(s[i]=='L')s[i]='R';
      else s[i]='L';
    }
  }

  REP(i,n){
    cout<<ans[i]<<" ";
  }

  return 0;
}

Measured memory_bytes: 1104
N = int(input())
res = 0
import collections
cnt = collections.Counter()
for i in range(1, N+1):
    str_i = str(i)
    cnt[str_i[0] + str_i[-1]] += 1
res = 0
# print(cnt)
for k, v in cnt.items():
    if k[0] == k[-1]:
        res += v * v
    elif k[-1]+k[0] in cnt:
        res += v * cnt[k[-1]+k[0]]
print(res)

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

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

    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].first;
    for (int i = 0; i < n; i++)
        v[i].second = i + 1;
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++)
        if (i == n - 1) cout << v[i].second << endl;
        else cout << v[i].second << " ";
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sousuu = sc.nextInt(),henkan_suu = sc.nextInt();
		int[] jyun = new int[sousuu];
		for(int i=0;i<sousuu;i++) jyun[i]=i+1;

		for(int i=0;i<henkan_suu;i++){
			String s = sc.next();
			String[] ab = s.split(",");
			int ichi = Integer.parseInt(ab[0])-1;
			int ni   = Integer.parseInt(ab[1])-1;
			int temp = jyun[ichi];
			jyun[ichi] = jyun[ni];
			jyun[ni] = temp;
		}

		for(int i=0;i<sousuu;i++){
			System.out.println(jyun[i]);
		}
	}
}


Measured memory_bytes: 26096
using System;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            long a = long.Parse(str[0]);
            long b = long.Parse(str[1]);
            Console.WriteLine(a / b + " " + a % b + " " + string.Format("{0:0.000000}",((double)a / (double)b)));
        }
    }
}

Measured memory_bytes: 5776
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a + b == 15)cout << '+';
	else if (a * b == 15)cout << '*';
	else cout << 'x';
}

Measured memory_bytes: 256
import bisect
from itertools import product
I = lambda n: [int(input()) for _ in range(n)]
def f(S, x):
    p = bisect.bisect_left(S, x)
    return [S[p-1], S[p]]
g = lambda x, s, t: abs(x-s)+abs(s-t)
INF = 10**11
a, b, q = map(int, input().split())
S, T, X = [-INF]+I(a)+[INF], [-INF]+I(b)+[INF], I(q)
for x in X:
    min_ = INF
    for s, t in product(f(S, x), f(T, x)):
        min_ = min(min_, g(x, s, t), g(x, t, s))
    print(min_)

Measured memory_bytes: 16144
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
bool pr[1000007];
ll fpow(ll x,ll y){x=x%MOD;ll res=1;while(y){if(y&1)res=res*x;res%=MOD;y=y>>1;x=x*x;x%=MOD;}return res;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll n;
long double dp[301][301][301];
long double foo(ll x,ll y,ll z)
{
	if(x==0 && y==0 && z==0)
	return dp[x][y][z]=0;
	else if(dp[x][y][z]!=-1)
	return dp[x][y][z];
	else
	{
		long double t1=(n*1.0)/(x+y+z)*(1.0);
		long double t2=0,t3=0,t4=0;
		if(x>0)
		t2=((x*1.0)/(x+y+z)*1.0)*foo(x-1,y,z);
		if(y>0)
		t3=((y*1.0)/(x+y+z)*1.0)*foo(x+1,y-1,z);
		if(z>0)
		t4=((z*1.0)/(x+y+z)*1.0)*foo(x,y+1,z-1);
		dp[x][y][z]=t1+t2+t3+t4;
		return dp[x][y][z];
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	ll a[n];
	ll cnt1=0,cnt2=0,cnt3=0;
	for(int i=0;i<301;i++)
	for(int j=0;j<301;j++)
	for(int k=0;k<301;k++)
	dp[i][j][k]=-1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==1)
		cnt1++;
		else if(a[i]==2)
		cnt2++;
		else
		cnt3++;
	}
	cout<<fixed<<setprecision(10)<<foo(cnt1,cnt2,cnt3);

}


Measured memory_bytes: 426496
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  if ((A <= C && C <= B) || (B <= C && C <= A)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
from sys import stdin

n, m, l = [int(x) for x in stdin.readline().rstrip().split()]
a = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(n)]
b = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(m)]
c = [[0] *l for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k]*b[k][j]

for i in range(n):
    print(*c[i])


Measured memory_bytes: 7060
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int main() {
  std::cout << std::setprecision(9);
  int n, k;
  cin >> n >> k;

  double ans;
  for (int i = 1; i <= n; i++) {
    int base = 1;
    while (i * base < k) {
      base *= 2;
    }
    ans += 1.0 / base;
  }
  cout << ans / n << endl;;
}

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

int main() {
  int N;
  int c1, c2, c3, c4;
  
  cin >> N;
  
  c1 = N / 1000;
  c2 = N / 100 % 10;
  c3 = N / 10 % 10;
  c4 = N % 10;
  
  if (c1 == c2 && c2 == c3) {
    cout << "Yes" << endl;
  } else if (c2 == c3 && c3 == c4) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import itertools
from typing import List, Tuple
 
 
def main():
    d, g = map(int, input().split())
    v = []
    for _ in range(d):
        p, c = map(int, input().split())
        v.append((p, c))
 
    print(ag(v, g))
 
 
def ag(v: List[Tuple[int, int]], g: int) -> int:
    ret = 10 ** 10
    for comb in itertools.product((False, True), repeat=len(v)):
        cnt, score = 0, 0
        for i, bit in enumerate(comb):
            if bit:
                score += (i + 1) * 100 * v[i][0] + v[i][1]
                cnt += v[i][0]
        if score < g:
            idx = len(v) - list(reversed(comb)).index(False) - 1
            add = ((g - score) + ((idx + 1) * 100) - 1) // ((idx + 1) * 100)
            if add < v[idx][0]:
                cnt += add
            else:
                cnt = 10 ** 10  # impossible
        ret = min(ret, cnt)
    return ret
 
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 10116
import sys

n = int(input())
a = list(map(int, input().split()))
x=[0]
for i in range(n):
    if i % 2 == 0:
        x[0] += a[i]
    else:
        x[0] -= a[i]

for i in range(n-1):
    tmp = 2*a[i] - x[i]
    x.append(tmp)

for i in range(n):
    print(x[i] ,end = " ")
print("")

Measured memory_bytes: 14032
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
int w, h, n;
int X1[1200], X2[1200], Y1[1200], Y2[1200];
bool fld[6100][6100];

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

int compress(int *x1, int *x2, int w) {
	vector<int>xs;
	for (int i = 0; i < n; i++) {
		for (int d = -1; d <= 1; d++) {
			int tx1 = x1[i] + d;
			int tx2 = x2[i] + d;
			if (0 <= tx1&&tx1 <= w)xs.push_back(tx1);
			if (0 <= tx2&&tx2 <= w)xs.push_back(tx2);
		}
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	for (int i = 0; i < n; i++) {
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size()-1;
}

int main() {
	while (cin >> w >> h, w, h) {
		w *= 2, h *= 2;
		cin >> n;

		for (int i = 0; i < 1200; i++)X1[i] = 0, X2[i] = 0, Y1[i] = 0, Y2[i] = 0;

		for (int i = 0; i < n; i++) {
			int a, b, c, d;
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
			X1[i] *= 2, X2[i] *= 2, Y1[i] *= 2, Y2[i] *= 2;
		}

		int wa = compress(X1, X2, w);
		int ha = compress(Y1, Y2, h);
		for (int i = 0; i < 6002; i++)
			for (int j = 0; j < 6002; j++)fld[i][j] = false;

		for (int i = 0; i < n; i++) {
			for (int y = Y1[i]; y <= Y2[i]; y++) {
				for (int x = X1[i]; x <= X2[i]; x++) {
					fld[y][x] = true;
				}
			}
		}

		int ans = 0;
		for (int y = 0; y <= ha; y++) {
			for (int x = 0; x <= wa; x++) {
				if (fld[y][x])continue;
				ans++;

				queue<P>Q;
				Q.push(P(x, y));
				while (Q.size()) {
					int sx = Q.front().first;
					int sy = Q.front().second;
					Q.pop();

					for (int i = 0; i < 4; i++) {
						int tx = sx + dx[i], ty = sy + dy[i];
						if (tx < 0 || wa < tx || ty < 0 || ha < ty)continue;
						if (fld[ty][tx])continue;
						Q.push(P(tx, ty));
						fld[ty][tx] = true;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 38832
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {


        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var vals = Console.ReadLine().Split(' ').
                Select(x => long.Parse(x)).ToList();
            var N = vals[0]-1;

            var S = new List<char>();
            

            long strln = 1;
            long offset = 0;
            long pow = 26;

            while (offset+pow<=N)
            {
                strln++;
                offset+=pow;
                pow*=26;
            } 

            N = N - offset;
            for (int i = 0; i < strln; i++)
            {
                S.Add((char)('a'+(int)(N % 26) ));
                N /= 26;
            }

            S.Reverse();
            var B = new StringBuilder();
            foreach (var item in S)
            {
                B.Append(item);
            }


            Console.WriteLine(B.ToString());
            Console.Out.Flush();
        }




    }
}




Measured memory_bytes: 28316
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	while (N--) {
		vector<vector<int>>field(5, vector<int>(5));
		for (int i = 0; i < 5; ++i) {
			for (int j = 0; j < 5; ++j) {
				cin >> field[i][j];
			}
		}
		int ans = 0;
		for (int l = 0; l < 5; ++l) {
			for (int r = l+1; r <= 5;++r){
				for (int u = 0; u < 5; ++u) {
					for (int d = u + 1; d <= 5; ++d) {
						bool ok = true;
						for (int x = l; x < r; ++x) {
							for (int y = u; y < d; ++y) {
								if (!field[y][x])ok = false;
							}
						}
						if (ok)ans = max(ans, (r - l)*-(u - d));
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

map<int, int> factorize(int a) {
    map<int, int> ret;
    for(int i = 2; i * i <= a; i++) {
        int cnt = 0;
        while (a % i == 0) a /= i, cnt++;
        if (cnt != 0) ret[i] = cnt;
    }
    if (a != 1) ret[a] = 1;
    return ret;
}

signed main() {
    int N;
    cin >> N;
    map<int, int> f;
    rep(i, 1, N + 1) {
        auto tmp = factorize(i);
        for (auto p : tmp) {
            f[p.first] += p.second;
        }
    }

    int ans = 0;
    for (pii p : f) {
        if (p.second >= 74) {
            ans++;
        }
    }
    for (pii p : f) {
        for (pii q : f) {
            if (p.first == q.first) {
                continue;
            }
            if (p.second >= 4 && q.second >= 14) {
                ans++;
            }
            if (p.second >= 2 && q.second >= 24) {
                ans++;
            }
        }
    }
    int tmp = 0;
    for (pii p : f) {
        for (pii q : f) {
            for (pii r : f) {
                if (p.first == q.first || q.first == r.first || r.first == p.first) {
                    continue;
                }
                if (p.second >= 2 && q.second >= 4 && r.second >= 4) {
                    tmp++;
                }
            }
        }
    }
    ans += tmp / 2;
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <set>
#include <string>
#include <utility>
#include <cmath>
#include <cstring>
#include <limits>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;
#define sq(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
#define iter(i, j) for(auto i = j.begin(); i != j.end(); ++i)
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end()  
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define file_io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define IMAX std::numeric_limits<int>::max()
#define IMIN std::numeric_limits<int>::min()
using namespace std;
template <class T> T count_multiples_of(T x, T upper_bound, T lower_bound)
{
    T ans = upper_bound / x - lower_bound / x;
    if(lower_bound % x == 0) return ans + 1;
    else return ans;
}
ll C(ll n, ll k) 
{ 
    ll C[n + 1][k + 1]; 
    ll i, j; 
    for(i = 0; i <= n; i++) 
    { 
        for(j = 0; j <= min(i, k); j++) 
        { 
            if (j == 0 || j == i) 
                C[i][j] = 1; 
            else
                C[i][j] = C[i - 1][j - 1] + 
                          C[i - 1][j]; 
        } 
    } 
    return C[n][k]; 
}
template <class T> void display_1D_vector(vector<T> v)
{
    ll n = v.size();
    rep(i, n) cout << v[i] << " ";
    cout << endl;
}

template <class T> void display_2D_vector(vector< vector<T> > v)
{
    ll n = v.size(), m = v[0].size();
    rep(i, n)
    {   
        rep(j, m) cout << v[i][j] << " ";
        cout << endl;
    }
}
int fast_exp(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
    }
    return res;
}

int main()
{
    fast_io
    //file_io
    int n, k; cin >> n >> k;
    vll h(n);
    rep(i, n) cin >> h[i];
    sort(all(h));
    ll ans = 0;
    rep(i, n - k) ans += h[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			if (H % 2 == 0) {
				for (int i = 1; i <= H / 2; i++) {
					if (W % 2 == 0) {
						for (int j = 1; j <= W / 2; j++) {
							System.out.print("#.");
						}
						System.out.print("\n");
						for (int k = 1; k <= W / 2; k++) {
							System.out.print(".#");
						}
						System.out.print("\n");
					} else if (W != 1) {
						for (int j = 1; j <= W / 2; j++) {
							System.out.print("#.");
						}
						System.out.print("#\n");
						for (int k = 1; k <= W / 2; k++) {
							System.out.print(".#");
						}
						System.out.printf(".\n");
					} else {
						System.out.print("#\n");
						System.out.print(".\n");
					}
				}
			} else if (H != 1) {
				for (int i = 1; i <= H / 2; i++) {
					if (W % 2 == 0) {
						for (int j = 1; j <= W / 2; j++) {
							System.out.print("#.");
						}
						System.out.print("\n");
						for (int k = 1; k <= W / 2; k++) {
							System.out.print(".#");
						}
						System.out.print("\n");
					} else if (W != 1) {
						for (int j = 1; j <= W / 2; j++) {
							System.out.print("#.");
						}
						System.out.print("#\n");
						for (int k = 1; k <= W / 2; k++) {
							System.out.print(".#");
						}
						System.out.printf(".\n");
					} else {
						System.out.print("#\n");
						System.out.print(".\n");
					}
				}
				if (W % 2 == 0) {
					for (int j = 1; j <= W / 2; j++) {
						System.out.print("#.");
					}
					System.out.print("\n");
				} else if (W != 1) {
					for (int j = 1; j <= W / 2; j++) {
						System.out.print("#.");
					}
					System.out.print("#\n");
				} else {
					System.out.print("#\n");
				}
			} else {
				if (W % 2 == 0) {
					for (int j = 1; j <= W / 2; j++) {
						System.out.print("#.");
					}
					System.out.print("\n");
				} else if (W != 1) {
					for (int j = 1; j <= W / 2; j++) {
						System.out.print("#.");
					}
					System.out.print("#\n");
				} else {
					System.out.print("#\n");
				}
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 35260
#include<bits/stdc++.h>
using namespace std;
int a,b,i;
int main(){
  cin>>a>>b;
  vector<char> c(a*b);
  for(i=0;i<a*b;i++)cin>>c[i];
  for(i=0;i<b+2;i++)cout<<'#';
  cout<<endl;
  for(i=0;i<a;i++){
    cout<<'#';
    for(int j=0;j<b;j++)cout<<c[j+b*i];
    cout<<'#'<<endl;
  }
    for(i=0;i<b+2;i++)cout<<'#';
    cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Node{
	int location;
	int p,left,right;
};

struct Point{
	Point(){
		id = x = y = 0;
	}

	Point(int arg_id,int arg_x,int arg_y){
		id = arg_id;
		x = arg_x;
		y = arg_y;
	}
	bool operator < (const Point & arg)const{
		return id < arg.id;
	}
	void print(){
		printf("%d\n",id);
	}
	int id,x,y;
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int number;

bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y; }

int makeKDTree(int left,int right, int depth){

	if(!(left < right))return NIL;

	int mid = (left+right)/2;

	int node_id = number++;

	if(depth%2 == 0){
		sort(P+left,P+right,lessX);
	}else{
		sort(P+left,P+right,lessY);
	}

	T[node_id].location = mid;
	T[node_id].left = makeKDTree(left,mid,depth+1);
	T[node_id].right = makeKDTree(mid+1,right,depth+1);

	return node_id;
}

void find(int node_id,int sx,int tx,int sy,int ty, int depth, vector<Point> &ans){

	int x = P[T[node_id].location].x;
	int y = P[T[node_id].location].y;

	if(sx <= x && x <= tx && sy <= y && y <= ty){
		ans.push_back(P[T[node_id].location]);
	}

	if(depth%2 == 0){
		if(T[node_id].left != NIL){
			if(sx <= x)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[node_id].right != NIL){
			if( x <= tx)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
		}
	}else{
		if(T[node_id].left != NIL){
			if(sy <= y)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[node_id].right != NIL){
			if(y <= ty)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
		}
	}
}


int main(){

	int x,y;
	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d %d",&x,&y);
		P[i] = Point(i,x,y);
		T[i].left = T[i].right = T[i].p = NIL;
	}

	number = 0;

	int root = makeKDTree(0,N,0);

	int q;
	scanf("%d",&q);
	int sx,tx,sy,ty;
	vector<Point> ans;
	for(int i = 0; i < q; i++){
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		for(int j = 0; j < ans.size(); j++){
			ans[j].print();
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 22396
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
//#include <functional>
//#include <cmath>

int main(){
    int32_t N;
    std::cin >> N;

    //naiive: 2^N box condition, check whether meet the constraint -> N*2^N
    //better: from bigger N to 1, meet the condition, N^2 approach?
    //  a8 -> a7 -> a6 -> a5 -> a4(check a8) -> a3(check a6) -> a2(check a4,a6,a8) -> a1(check all)
    //  N + N/2 + N/3 + ... 1 = O(NlogN)? looks feasible.
    //concievable: order N possible?
    std::vector<int32_t> a(N);
    for(auto& i : a){
        std::cin >> i;
    }

    std::vector<int32_t> b(N,0);
    std::vector<int32_t> res;
    for(int32_t i = N-1; i >= 0; i--){
        int32_t sum = 0;
        for(int32_t j = 1; j * (i + 1) <= N; j++){
            sum += b[j*(i+1)-1];            
        }
        if(sum % 2 != a[i]){
            b[i] = 1;
            res.push_back(i+1);
        }
        // no -1 case?
    }

    if(!res.empty()){
        std::cout << res.size() << std::endl;
        for(int32_t i = res.size() -1; i >= 0; i--){
            std::cout << res[i] << " ";
        }
    }
    else{
        std::cout << 0;
    }


    return 0;
}


Measured memory_bytes: 3064
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int numRoutes = sc.nextInt();
        int timeLimit = sc.nextInt();

        int[] c = new int[numRoutes];
        int[] t = new int[numRoutes];

        for (int i = 0; i < numRoutes; i++) {
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
        }

        int optimalRoute = -1;
        for (int i = 0; i < numRoutes; i++) {
            if (t[i] > timeLimit) {
                continue;
            }

            if (optimalRoute == -1) {
                optimalRoute = i;
                continue;
            }

            if (c[i] < c[optimalRoute]) {
                optimalRoute = i;
            }
        }

        if (optimalRoute == -1) {
            System.out.println("TLE");
        } else {
            System.out.println(c[optimalRoute]);
        }

    }
}

Measured memory_bytes: 25300
#include<stdio.h>

int main()
{
	int w , h , x , y , r;
	scanf("%d %d %d %d %d" , &w , &h , &x , &y , &r);
	if((x + r <= w && x - r >= 0) && (y + r <= h && y - r >= 0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
} 


Measured memory_bytes: 2692
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
using namespace std;
typedef vector<int> vi;
typedef long long ll;
const ll mod = 1000000007;

vi g[1010],rg[1010], vs;
bool use[1010];
int ord[1010];
int n,m;

void fdfs(int v){
  use[v] = 1;
  for(int u : g[v])if(!use[u])fdfs(u);
  vs.pb(v);
}

void rdfs(int v,int k){
  use[v] = 1; ord[v] = k;
  for(int u : rg[v])if(!use[u])rdfs(u,k);
}

int scc(){
  memset(use,0,sizeof(use));
  vs.clear();
  rep(i,n)if(!use[i])fdfs(i);

  memset(use,0,sizeof(use));
  int k = 0;
  for(int i=vs.size()-1;i>=0;i--){
    if(!use[vs[i]])rdfs(vs[i],k++);
  }
  return k;
}

int main(){
  cin >> n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b; a--; b--;
    g[a].pb(b);
    rg[b].pb(a);
  }
  int k = scc();

  vector< vi > ng(k);
  rep(v,n)for(int u : g[v]){
    if(ord[v]!=ord[u])ng[ord[v]].pb(ord[u]);
  }

  vi deg(k,0);
  rep(v,k){
    sort(all(ng[v]));
    ng[v].erase(unique(all(ng[v])),ng[v].end());
    for(int u : ng[v])deg[u]++;
  }

  queue<int> q;
  rep(v,k)if(deg[v]==0)q.push(v);
  vector<int> to;

  while(q.size()){
    int v = q.front(); q.pop();
    to.pb(v);
    for(int u : ng[v]){
      deg[u]--;
      if(deg[u]==0)q.push(u);
    }
  }
  
  vector<ll> dp0(k,1), dp1(k,1);
  ll ans = 1;
  rep(i,k){
    int v = to[i];
    for(int u : ng[v]){
      (dp0[u] *= dp0[v]) %= mod;
      (dp1[u] *= dp0[v] + dp1[v]) %= mod;
    }
    if(ng[v].empty()) (ans *= dp0[v] + dp1[v]) %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<int, int> P;

vector<int> G[1000000];
vector<P> bridge;
vector<int> articulation;
int ord[1000000], low[1000000];
bool vis[1000000];

void dfs(int v, int p, int &k)
{
	vis[v] = true;
	
	ord[v] = k++;
	low[v] = ord[v];
	
	bool isArticulation = false;
	int ct = 0;
	
	for (int i = 0; i < G[v].size(); i++){
		if (!vis[G[v][i]]){
			ct++;
			dfs(G[v][i], v, k);
			low[v] = min(low[v], low[G[v][i]]);
			if (~p && ord[v] <= low[G[v][i]]) isArticulation = true;
			if (ord[v] < low[G[v][i]]) bridge.push_back(make_pair(min(v, G[v][i]), max(v, G[v][i])));
		}
		else if (G[v][i] != p){
			low[v] = min(low[v], ord[G[v][i]]);
		}
	}
	
	if (p == -1 && ct > 1) isArticulation = true;
	if (isArticulation) articulation.push_back(v);
}

int main(){
	
	int V, E;
	cin >> V >> E;
	
	for(int i = 0; i < E; i++){
		int v1, v2;
		cin >> v1 >> v2;
		G[v1].push_back(v2);
		G[v2].push_back(v1);
	}
	
	int k = 0;
	for (int i = 0; i < V; i++){
		if (!vis[i]) dfs(i, -1, k);
	}
	
	sort(bridge.begin(), bridge.end());
	sort(articulation.begin(), articulation.end());
	
	for (int i = 0; i < articulation.size(); i++){
		cout << articulation[i] << endl;
	}
	
	//cout << endl;
	/*
	for (int i = 0; i < bridge.size(); i++){
		cout << bridge[i].first << " " << bridge[i].second << endl;
	}
	*/
	return 0;
}



Measured memory_bytes: 28164
#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 <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
#define P_MAX (10000010)
int px[51*6];
int py[51*6];
int pz[51*6];
int W,H,D;
int N,K;
P sx[51];
P sy[51];
P sz[51];
int ash(P *ps,int *pp,int &p){
  vector<int> pv;
  for(int i=0;i<N;i++){
    for(int j=-1;j<2;j++){
      if(ps[i].F+j >= 0)
	pv.push_back(ps[i].F+j);
      if(ps[i].S+j >= 0)
	pv.push_back(ps[i].S+j);
    }
  }
  sort(pv.begin(),pv.end());
  pv.erase(unique(pv.begin(),pv.end()),pv.end());
  for(int i=0;i<N;i++){
    ps[i].F = find(pv.begin(),pv.end(),ps[i].F)-pv.begin();
    ps[i].S = find(pv.begin(),pv.end(),ps[i].S)-pv.begin();
  }
  for(int i=0;i<(int)pv.size()-1;i++){
    pp[i] = pv[i+1]-pv[i];
    //    printf("%d %d %d\n",pv[i+1],pv[i],pv[i+1]-pv[i]);
  }
  pp[(int)pv.size()-1] = P_MAX-pv[(int)pv.size()-1];
  //  printf("Last: %d\n",P_MAX-pv[(int)pv.size()-1]);
  p = (int)pv.size();
}

bool ok(int x,int y,int z,int id){
  if( sx[id].F <= x && x < sx[id].S ){
    if( sy[id].F <= y && y < sy[id].S ){
      if( sz[id].F <= z && z < sz[id].S ){
	return true;
      }
    }
  }
  return false;
}

void printN(){
  printf("%d %d %d\n",W,H,D);
  for(int id=0;id<N;id++){
    printf("%d %d %d %d %d %d\n",
	   sx[id].F,sy[id].F,sz[id].F,
	   sx[id].S,sy[id].S,sz[id].S);
  }
}

ll solve(){
  ll res = 0;
  ash(sx,px,W);
  ash(sy,py,H);
  ash(sz,pz,D);
  //  printN();
  for(int x=0;x<W;x++){
    for(int y=0;y<H;y++){
      for(int z=0;z<D;z++){
	int co = 0;
	//	printf("%d %d %d\n",px[x],py[y],pz[z]);
	for(int i=0;i<N;i++){
	  if(ok(x,y,z,i)){
	    co++;
	  }
	}
	//printf("%d\n",co);
	if(K<=co){
	  //	  printf("%d:%d %d:%d %d:%d\n",x,px[x],y,py[y],z,pz[z]);
	  res+=(ll)px[x]*(ll)py[y]*(ll)pz[z];
	  // printf("%lld\n",res);
	}
      }
    }
  }
  return res;
}
int main(){
  scanf("%d %d",&N,&K);
  for(int i=0;i<N;i++){
    scanf("%d %d %d %d %d %d",
	  &sx[i].F,&sy[i].F,&sz[i].F,
	  &sx[i].S,&sy[i].S,&sz[i].S);	  
  }
  printf("%lld\n",solve());
}

Measured memory_bytes: 1220
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    
    s=input()
    Q=int(input())
    A = tuple(map(int, input().split()))
    for k in A:
        dmc=0
        d=0
        m=0
        c=0
        dm=0
        mc=0
        
        for i in range(k):
            if s[i]=="D":
                d+=1
            elif s[i]=="C":
                c+=1
                mc+=m
                dmc+=dm
            
            elif s[i]=="M":
                m+=1
                dm+=d

        for i in range(1,N-k+1):
            if s[i-1]=="D":
                dm-=m
                d-=1
            elif s[i-1]=="M":
                mc-=c
                m-=1
            elif s[i-1]=="C":
                c-=1
            se=s[i+k-1]
            if se=="D":
                d+=1
            elif se=="C":
                c+=1
                mc+=m
                dmc+=dm
            
            elif se=="M":
                m+=1
                dm+=d

        print(dmc)

            




if __name__ == "__main__":
    main()

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1000000007;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

string st;

int main()
{
//    fin("t.in");
    sync;
    cin >> st;
    ri(0, st.size()) {
        if (i == 4)
            cout << " ";
        cout << st[i];
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll N;
    cin >> N;
    ll A[N];
    rep(i,N) cin >> A[i];
    sort(A,A+N);
    ll out = A[N-1];
    ll n = (N-2)/2;
    rep(i,n){
        out += A[N-2-i]*2;
    }
    if(N%2==1) out += A[(N+1)/2-1];
    cout << out << endl;
    return 0;
}



Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int k;
  cin >> k;
  int ans = 0;
  rep2(i, 1, k+1){
    rep2(j, i+1, k+1){
      if(i % 2 != j % 2) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
    int n,base;
    string a,b,c;
    cin>>a>>b;
    c = a+b;
    n = atoi(c.c_str());
    base = (int)sqrt(n);
    if(base*base==n)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

edges = []
g = Array.new(n+1){ [] }
(n-1).times do |i|
  a, b = gets.split
  a, b = a.to_i, b.to_i
  a, b = b, a if a > b # 辺は頂点 i < j の形で入れる。
  g[a] << b # 隣接リストに
  g[b] << a # 反対向きにも隣接リストに.無向グラフなので
  edges << [a,b] # 辺リストにいれる。辺が識別されてて、最後に辺リストから辺を回して色をとりだす。
end

colors = Hash.new() # Esge => color # 辺についてO(1)で使った色を見れる。O(1)はホントに?
colors_used = Array.new(n+1){Hash.new} # 頂点と色についてO(1)で使ったか確かめられる。
used = Array.new(n){false} # 頂点について探索済みかどうかO(1)でわかる。
que = [1] # 頂点1から見ていくので0が入っている # 探索待ちの未探索の頂点リスト

k = 0 # 答えとなる色の数
while v = que.shift # queにある頂点を取り出す. 破壊的メソッドなので先頭は削除される。なければnilを返す
  cur = 1 # 使ってない色がわからないので、とりあず色1から見ていく。
  g[v].each do |w| # vの隣接頂点wを見ていく。
    next if used[w] #trueで、探索済みの頂点なら見ない。
    k = g[v].size if k < g[v].size  # 隣接する頂点数より色数が小さければ色数を更新
    v<w ? (i,j = v,w) : (i,j = w,v) # i < jの並びで頂点を捉える。
    cur += 1 while colors_used[v][cur] == true # v周りの頂点で色をつかっていれば次の色に更新していく。塗る前に使ってない色にする。
    colors_used[v][cur] = true # vに色を使ったので記録する。
    colors_used[w][cur] = true # wに色を使ったので記録する。
    colors[[i,j]] = cur # 辺に使った色をいれる。
    que.push(w) #探索待ちの未探索頂点リストに頂点wを入れる。
  end
  used[v] = true # 頂点vを探索済みにする。
end

puts k
edges.each{ |e| puts colors[e] }

Measured memory_bytes: 58620
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    string S;cin>>S;
    int ans=0;
    for(int i=0;i<4;i++){
        if(S[i]=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn lsb(x: usize) -> usize {
    (x as isize & -(x as isize)) as usize
}
fn rec(x: usize, e: usize) -> Vec<usize> {
    if e.count_ones() == 1 {
        vec![0, x]
    } else {
        let m = lsb(x);
        let ne = e ^ m;
        let s = lsb(ne);
        rec(s, ne)
            .into_iter()
            .chain(rec(x ^ m ^ s, ne).into_iter().map(|i| i ^ m ^ s))
            .collect::<Vec<_>>()
    }
}
fn main() {
    input! { n, a, b };
    let m = (0..n).filter(|i| (a ^ b) & 1usize << i != 0).count();
    if m % 2 == 0 {
        println!("NO");
    } else {
        println!("YES");
        let v = rec(a ^ b, (1 << n) - 1);
        for p in v.into_iter() {
            print!("{} ", p ^ a);
        }
        println!("");
    }
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  int flag = a%b;
  int n = 1;
  string ans = "NO";
  
  if (flag == c) ans = "YES";
  while(1){
    n++;
    if(a*n%b == c){ans = "YES"; break;}
    if(a*n%b == flag){break;}
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256